引起:android.content.res.Resources $ NotFoundException:来自可绘制资源ID的文件#0x7f0a0018

时间:2014-05-02 05:58:18

标签: android android-resources android-drawable

我查看了R.java文件中的资源ID,ID是一个字符串。字符串是我的应用程序的名称

<string name="AppName">Tip Calculator</string>

请帮忙。先谢谢你。

logcat的:

.MainActivity}: android.content.res.Resources$NotFoundException: File Tip Calculator from drawable resource ID #0x7f0a0018
05-01 22:37:50.979: E/AndroidRuntime(6140):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at android.app.ActivityThread.access$900(ActivityThread.java:161)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at android.os.Handler.dispatchMessage(Handler.java:102)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at android.os.Looper.loop(Looper.java:157)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at android.app.ActivityThread.main(ActivityThread.java:5356)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at java.lang.reflect.Method.invokeNative(Native Method)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at java.lang.reflect.Method.invoke(Method.java:515)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at dalvik.system.NativeStart.main(Native Method)
05-01 22:37:50.979: E/AndroidRuntime(6140): Caused by: android.content.res.Resources$NotFoundException: File Tip Calculator from drawable resource ID #0x7f0a0018
05-01 22:37:50.979: E/AndroidRuntime(6140):     at android.content.res.Resources.loadDrawable(Resources.java:3030)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at android.content.res.Resources.getDrawable(Resources.java:1586)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at com.android.internal.widget.ActionBarView.setLogo(ActionBarView.java:1031)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at com.android.internal.policy.impl.PhoneWindow.setDefaultLogo(PhoneWindow.java:1568)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at android.app.Activity.initActionBar(Activity.java:1997)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at android.app.Activity.setContentView(Activity.java:2011)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at net.jamesbrookshire.tipcalc.MainActivity.onCreate(MainActivity.java:22)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at android.app.Activity.performCreate(Activity.java:5426)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
05-01 22:37:50.979: E/AndroidRuntime(6140):     ... 11 more
05-01 22:37:50.979: E/AndroidRuntime(6140): Caused by: java.io.FileNotFoundException: Tip Calculator
05-01 22:37:50.979: E/AndroidRuntime(6140):     at android.content.res.AssetManager.openNonAssetNative(Native Method)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at android.content.res.AssetManager.openNonAsset(AssetManager.java:408)
05-01 22:37:50.979: E/AndroidRuntime(6140):     at android.content.res.Resources.loadDrawable(Resources.java:3021)
05-01 22:37:50.979: E/AndroidRuntime(6140):     ... 20 more

我通过启动一个新项目并将每次旧代码添加到项目中并每次调试来解决我的问题。我的问题的原因在于我的&#34; MainActivity.java&#34;。我有一些不好的代码,调试器没有找到它。对不起,这个并不是很清楚。感谢所有回复的人。

2 个答案:

答案 0 :(得分:0)

您需要在res/value/string.xml中添加字符串。 Drawables用于图像。

答案 1 :(得分:0)

您的短日志和不完整日志会显示.MainActivity,其中您引用的是不存在的drawable。此错误与您的AndroidManifest.xml无关。而且这与你的strings.xml文件无关,因为错误表明找不到名为Tip Calculator的drawable。

您可以从日志中提供更多行,以便明确错误。