当前位置: 代码迷 >> Android >> 读取assets文件夹下的文件失败,该如何处理
  详细解决方案

读取assets文件夹下的文件失败,该如何处理

热度:96   发布时间:2016-05-01 21:21:16.0
读取assets文件夹下的文件失败
assets文件夹下面有png图标:pause.png

(别讨论其他方法~~俺知道这是个麻烦的方法~~没办法项目需要)

Java code
try {    AssetManager am = context.getAssets();            InputStream ipause = am.open("pause.png");            Bitmap bpause =BitmapFactory.decodeStream(ipause);           dpause = new BitmapDrawable(bpause);         mStartButton.setBackgroundDrawable(dplay);  } catch (IOException e) {    // TODO Auto-generated catch block    e.printStackTrace();  }


在InputStream ipause = am.open("pause.png"); 处出错

提示文件没有找到,

log:
05-16 09:40:46.200: WARN/System.err(541): java.io.FileNotFoundException: pause.png
05-16 09:40:46.217: WARN/System.err(541): at android.content.res.AssetManager.openAsset(Native Method)
05-16 09:40:46.226: WARN/System.err(541): at android.content.res.AssetManager.open(AssetManager.java:313)
05-16 09:40:46.257: WARN/System.err(541): at android.content.res.AssetManager.open(AssetManager.java:287)
05-16 09:40:46.277: WARN/System.err(541): at PluginTest.test.VideoSurface.<init>(VideoSurface.java:120)
05-16 09:40:46.286: WARN/System.err(541): at PluginTest.test.PluginTest.onCreate(PluginTest.java:18)
05-16 09:40:46.306: WARN/System.err(541): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-16 09:40:46.306: WARN/System.err(541): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-16 09:40:46.339: WARN/System.err(541): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-16 09:40:46.347: WARN/System.err(541): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-16 09:40:46.356: WARN/System.err(541): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-16 09:40:46.356: WARN/System.err(541): at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 09:40:46.386: WARN/System.err(541): at android.os.Looper.loop(Looper.java:123)
05-16 09:40:46.386: WARN/System.err(541): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-16 09:40:46.407: WARN/System.err(541): at java.lang.reflect.Method.invokeNative(Native Method)
05-16 09:40:46.407: WARN/System.err(541): at java.lang.reflect.Method.invoke(Method.java:521)
05-16 09:40:46.426: WARN/System.err(541): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-16 09:40:46.426: WARN/System.err(541): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-16 09:40:46.436: WARN/System.err(541): at dalvik.system.NativeStart.main(Native Method)


求助

------解决方案--------------------
能放- -
------解决方案--------------------
clean project and then rebuild
  相关解决方案