我的一位用户报告了以下堆栈跟踪错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.javaexp.batterysaver/com.javaexp.batterysaver.MainActivity}: android.view.InflateException: Binary XML file line #16: Error inflating class android.widget.Button
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class android.widget.Button
at android.view.LayoutInflater.createView(LayoutInflater.java:606)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(ActionBarSherlockNative.java:133)
at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:229)
at com.javaexp.batterysaver.MainActivity.onCreate(MainActivity.java:44)
at android.app.Activity.performCreate(Activity.java:4465)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:586)
... 26 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-hdpi/uninstallapps80.png from drawable resource ID #0x7f02007f
at android.content.res.Resources.loadDrawable(Resources.java:1973)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.widget.TextView.<init>(TextView.java:624)
at android.widget.Button.<init>(Button.java:108)
at android.widget.Button.<init>(Button.java:104)
... 29 more
Caused by: java.io.FileNotFoundException: res/drawable-hdpi/uninstallapps80.png
at android.content.res.AssetManager.openNonAssetNative(Native Method)
at android.content.res.AssetManager.openNonAsset(AssetManager.java:407)
at android.content.res.Resources.loadDrawable(Resources.java:1965)
... 33 more
在我的应用程序中,我可以看到res / drawable-hdpi文件夹中存在图像uninstallapps80.png。任何分析问题的指针都会有所帮助。他的设备是Nexus One。
答案 0 :(得分:1)
Android应用程序有超过1个可绘制文件夹,将图像复制并粘贴到所有这些文件夹中然后应解决您的问题(hdpi ldpi mdpi xhdpi)
drawable-ldpi is for low density screens
drawable-mdpi is for medium density screens
drawable-hdpi is for high resolution screens
drawable-xhdpi is for extra high resolution screens