在本文中,我们将为您详细介绍BitmapFactory无法解码流:Android中的java.io.FileNotFoundException的相关知识,并且为您解答关于无法解析类型java.util
在本文中,我们将为您详细介绍BitmapFactory无法解码流:Android中的java.io.FileNotFoundException的相关知识,并且为您解答关于无法解析类型java.util.map$entry的疑问,此外,我们还会提供一些关于Android :: Extending MapActivity => classNotFound Exception、Android Studio更新后的Java.lang.ClassNotFoundException、android – FileNotFoundException将文件写入SD卡、android – java.io.FileNotFoundException:/file/path.jpg open failed:ENOENT(没有这样的文件或目录)的有用信息。
本文目录一览:- BitmapFactory无法解码流:Android中的java.io.FileNotFoundException(无法解析类型java.util.map$entry)
- Android :: Extending MapActivity => classNotFound Exception
- Android Studio更新后的Java.lang.ClassNotFoundException
- android – FileNotFoundException将文件写入SD卡
- android – java.io.FileNotFoundException:/file/path.jpg open failed:ENOENT(没有这样的文件或目录)
BitmapFactory无法解码流:Android中的java.io.FileNotFoundException(无法解析类型java.util.map$entry)
我试图在线从数据库中的表中的数据字段“ imagelink”中获取图片,我将上传的图片的网址放在此处,但不幸的是,它给了我这个错误。
02-08 15:05:29.432 14364-14364/com.example.jithea.testlogin E/BitmapFactory﹕ Unable to decode stream: java.io.FileNotFoundException: /http:/agustiniancampusevents.site40.net/newsDB/images/Visual%20Report%20Filipino%20Final-12%20copy.JPG: open failed: ENOENT (No such file or directory)
这是我在onPostExecute中的代码:
protected void onPostExecute(String file_url) { // dismiss the dialog after getting all products pDialog.dismiss(); // updating UI from Background Thread runOnUiThread(new Runnable() { public void run() { /** * Updating parsed JSON data into ListView * */ ListAdapter adapter = new SimpleAdapter( NewsActivity.this, productsList, R.layout.news_list_item, new String[]{TAG_PID, TAG_IMAGELINK, TAG_NEWSTITLE, TAG_DESCRIPTION}, new int[]{R.id.pid, R.id.imageView, R.id.newstitle, R.id.description}); // updating listview setListAdapter(adapter); } }); }
答案1
小编典典使用BitmapFactory.decodeStream
代替BitmapFactory.decodeFile
。
try ( InputStream is = new URL( file_url ).openStream() ) { Bitmap bitmap = BitmapFactory.decodeStream( is );}
Android :: Extending MapActivity => classNotFound Exception
我想创建一个MapView,但扩展MapActivity会抛出一个classNotFoundException:
/AndroidRuntime( 374): at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:2585)
E/AndroidRuntime( 374): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
E/AndroidRuntime( 374): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
E/AndroidRuntime( 374): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
E/AndroidRuntime( 374): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 374): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 374): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 374): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 374): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 374): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 374): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 374): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 374): Caused by: java.lang.classNotFoundException: com.androidcourse.phonemapper.view.MapShowActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.androidcourse.phonemapper-2.apk]
E/AndroidRuntime( 374): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
E/AndroidRuntime( 374): at java.lang.classLoader.loadClass(ClassLoader.java:573)
E/AndroidRuntime( 374): at java.lang.classLoader.loadClass(ClassLoader.java:532)
E/AndroidRuntime( 374): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime( 374): at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:2577)
我有一个Google Maps API密钥,我将项目设置为Google Api,我使用的是Android Google Api AVD(模拟器),我确实在AndroidManifest.xml中包含了该标记.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidcourse.phonemapper" android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<uses-library android:name="com.google.android.maps" />
……………..
<activity android:name=".view.WelcomeActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="api_key_is_here_just_wont_show_it_to_everybody"
/>
</RelativeLayout>
解决方法:
尝试将包设置为“com.androidcourse.phonemapper.view”:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidcourse.phonemapper.view" android:versionCode="1"
android:versionName="1.0">
然后引用它:
<activity android:name=".WelcomeActivity"
Android Studio更新后的Java.lang.ClassNotFoundException
com.myapp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.myapp,PID: 29605 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.myapp/com.myapp.Login}: java.lang.classNotFoundException: Didn't find class "com.myapp.Login" on path: DexPathList[[zip file "/data/app/com.myapp-1/base.apk"],nativeLibraryDirectories=[/vendor/lib,/system/lib]] at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:3023) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3294) at android.app.ActivityThread.access$1000(ActivityThread.java:210) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1704) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6938) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) Caused by: java.lang.classNotFoundException: Didn't find class "com.myapp.Login" on path: DexPathList[[zip file "/data/app/com.myapp-1/base.apk"],/system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.classLoader.loadClass(ClassLoader.java:511) at java.lang.classLoader.loadClass(ClassLoader.java:469) at android.app.Instrumentation.newActivity(Instrumentation.java:1094) at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:3013) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3294) at android.app.ActivityThread.access$1000(ActivityThread.java:210) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1704) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6938) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) Suppressed: java.lang.classNotFoundException: com.myapp.Login at java.lang.class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.classLoader.loadClass(ClassLoader.java:504) ... 13 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
这是我的gradle.build
apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' android { compileSdkVersion 'Google Inc.:Google Apis:23' buildToolsversion "22.0.1" defaultConfig { applicationId "com.myapp" minSdkVersion 14 targetSdkVersion 22 } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.txt' } } } dependencies { // compile files('libs/smack-core-4.0.7.jar') compile 'com.android.support:appcompat-v7:23.0.1' compile 'com.google.android.gms:play-services:7.8.0' compile 'com.google.maps.android:android-maps-utils:0.4+' }
到目前为止我已经尝试过
1)清理和重建项目
2)删除构建文件夹并重建项目/重启Android Studio
3)切换到金丝雀频道以及开发频道和更新
4)在“设置”中选中并取消选中离线模式
显然这是一个错误,但有解决方案吗?如何撤消最近的更新?任何帮助深表感谢.
解决方法
清除应用缓存
清除应用数据
卸载应用
再次运行/调试
希望它有效!
android – FileNotFoundException将文件写入SD卡
我正在尝试从网上下载文件并将其写入SD卡.我启用了WRITE_EXTERNAL_STORAGE权限.代码在这里失败:
OutputStream output = new FileOutputStream(filePath);
09-15 19:40:31.630: WARN/System.err(7933): java.io.FileNotFoundException: /sdcard/artoo/Customerv08.apk
09-15 19:40:31.630: WARN/System.err(7933): at org.apache.harmony.luni.platform.OSFileSystem.open(OSFileSystem.java:231)
09-15 19:40:31.630: WARN/System.err(7933): at java.io.FileOutputStream.<init>(FileOutputStream.java:96)
09-15 19:40:31.630: WARN/System.err(7933): at java.io.FileOutputStream.<init>(FileOutputStream.java:169)
09-15 19:40:31.630: WARN/System.err(7933): at java.io.FileOutputStream.<init>(FileOutputStream.java:147)
09-15 19:40:31.640: WARN/System.err(7933): at com.artoo.settings.InstallerActivity$ProgressDialogAsyncTask.doInBackground(InstallerActivity.java:148)
09-15 19:40:31.640: WARN/System.err(7933): at com.artoo.settings.InstallerActivity$ProgressDialogAsyncTask.doInBackground(InstallerActivity.java:1)
09-15 19:40:31.640: WARN/System.err(7933): at android.os.AsyncTask$2.call(AsyncTask.java:185)
09-15 19:40:31.640: WARN/System.err(7933): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:256)
09-15 19:40:31.640: WARN/System.err(7933): at java.util.concurrent.FutureTask.run(FutureTask.java:122)
09-15 19:40:31.640: WARN/System.err(7933): at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:648)
09-15 19:40:31.640: WARN/System.err(7933): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:673)
09-15 19:40:31.651: WARN/System.err(7933): at java.lang.Thread.run(Thread.java:1060)
09-15 19:40:31.670: WARN/InputManagerService(53): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@43868480
我正在尝试编写该文件,它从以前不存在.关于如何做到这一点的任何想法?
解决方法:
您收到该错误,因为指定的文件无法打开或不存在.这很简单.
我总是先创建一个文件并使用bufferedstream写入它,例如:
File file = new File(path, name);
file.createNewFile();
bufferedoutputstream out = new bufferedoutputstream(new FileOutputStream(file), BUFFER);
android – java.io.FileNotFoundException:/file/path.jpg open failed:ENOENT(没有这样的文件或目录)
private void saveImage() throws IOException { // Todo Auto-generated method stub InputStream header = new FileInputStream("/ClashMMA/res/drawable-hdpi/beatdown.jpg"); ParseFile file = new ParseFile(toByteArray(header)); try{ file.save(); } catch (ParseException e) { e.printstacktrace(); } ParSEObject displayImage = new ParSEObject("displayImage"); displayImage.put("header",file); try{ displayImage.save(); } catch (ParseException e1){ e1.printstacktrace(); } } private byte[] toByteArray(InputStream header) throws IOException { // Todo Auto-generated method stub ByteArrayOutputStream buffer = new ByteArrayOutputStream(); int l; byte[] data = new byte[1024]; while ((l = header.read(data,data.length)) != -1) { buffer.write(data,l); } buffer.flush(); return buffer.toByteArray(); }
而我的错误是这样的;
java.io.FileNotFoundException:/ClashMMA/res/drawable-hdpi/beatdown.jpg:open Failed:ENOENT(没有这样的文件或目录)
但我确信文件在那里,因为我去了我的文件目录(在eclipse中),右键单击,然后单击copy Qualified Name.这基本上复制了文件路径.我已经尝试了一些其他路径,例如关闭我的计算机,以及我的src文件夹.有人可以告诉我我做错了什么吗?为什么它不会读取文件,实际上它在那里?详细解释请.
解决方法
你基本上有两个选择:
>将它们放入APK存档中,以便您可以使用getSystemResourceAsstream加载它们:请参阅How to load image for Android ImageView from classpath?>将文件复制到Android文件系统中,以便FileInputStream可以找到它们.
今天关于BitmapFactory无法解码流:Android中的java.io.FileNotFoundException和无法解析类型java.util.map$entry的介绍到此结束,谢谢您的阅读,有关Android :: Extending MapActivity => classNotFound Exception、Android Studio更新后的Java.lang.ClassNotFoundException、android – FileNotFoundException将文件写入SD卡、android – java.io.FileNotFoundException:/file/path.jpg open failed:ENOENT(没有这样的文件或目录)等更多相关知识的信息可以在本站进行查询。
本文标签: