I looked in the R.java file for the resource ID and the ID is a string. The string is the name of my app
我查看了R.java文件中的资源ID,ID是一个字符串。字符串是我的应用程序的名称
<string name="AppName">Tip Calculator</string>
Please help. Thank you in advanced.
请帮忙。先谢谢你。
LogCat:
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.james*shire.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
I resolved my problem by starting a new project and adding my old code to the project a little each time and debugging each time. The cause of my problem was in my "MainActivity.java". I had some bad code that wasn't picked up by the debugger. Sorry this was and isn't very clear. Thanks to everyone who responded.
我通过启动一个新项目并将每次旧代码添加到项目中并每次调试来解决我的问题。我的问题的原因在于我的“MainActivity.java”。我有一些错误的代码没有被调试器拾取。对不起,这是,并不是很清楚。感谢大家的回应。
2 个解决方案
#1
0
You need to put strings in res/value/string.xml
. Drawables are for images.
您需要将字符串放在res / value / string.xml中。 Drawables用于图像。
#2
0
Your short and incomplete logs shows a .MainActivity
in which you are referencing a drawable which doesn't exists. This error has nothing to do with your AndroidManifest.xml
. And also this has nothing to do with your strings.xml file because the error states that a drawable named Tip Calculator
is not found.
您的短日志和不完整日志显示.MainActivity,您在其中引用不存在的drawable。此错误与AndroidManifest.xml无关。而且这与你的strings.xml文件无关,因为错误表明找不到名为Tip Calculator的drawable。
You may provide more lines from your logs which would give clarity to the error.
您可以从日志中提供更多行,以便明确错误。
#1
0
You need to put strings in res/value/string.xml
. Drawables are for images.
您需要将字符串放在res / value / string.xml中。 Drawables用于图像。
#2
0
Your short and incomplete logs shows a .MainActivity
in which you are referencing a drawable which doesn't exists. This error has nothing to do with your AndroidManifest.xml
. And also this has nothing to do with your strings.xml file because the error states that a drawable named Tip Calculator
is not found.
您的短日志和不完整日志显示.MainActivity,您在其中引用不存在的drawable。此错误与AndroidManifest.xml无关。而且这与你的strings.xml文件无关,因为错误表明找不到名为Tip Calculator的drawable。
You may provide more lines from your logs which would give clarity to the error.
您可以从日志中提供更多行,以便明确错误。