无法启动活动组件信息{…}:android.content.res.Resources$NotFoundException:资源ID
我是Android应用程序开发新手,最近下载并安装了Android 3.1平台(API 12) 我正在阅读教程,并尝试运行“Hello world”程序() 但它不起作用,我最终在模拟器上看到了锁定的屏幕。当我尝试解锁时,它会显示: “强制关闭” 错误消息和按钮 我通过这个论坛寻找答案,并检查了LogCat输出。我在那里发现了一个异常,但我不确定如何修复该问题。谁能帮我一下吗 异常堆栈跟踪:无法启动活动组件信息{…}:android.content.res.Resources$NotFoundException:资源ID,android,Android,我是Android应用程序开发新手,最近下载并安装了Android 3.1平台(API 12) 我正在阅读教程,并尝试运行“Hello world”程序() 但它不起作用,我最终在模拟器上看到了锁定的屏幕。当我尝试解锁时,它会显示: “强制关闭” 错误消息和按钮 我通过这个论坛寻找答案,并检查了LogCat输出。我在那里发现了一个异常,但我不确定如何修复该问题。谁能帮我一下吗 异常堆栈跟踪: package com.example.helloandroid; import android.ap
package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText(R.string.hello);
setContentView(tv);
}
}
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/hello" />
WARN/ResourceType(162):获取包0中0x7f030015(t=2 e=21)的条目失败(错误-75)
调试/AndroidRuntime(162):关闭虚拟机
WARN/dalvikvm(162):threadid=1:线程以未捕获异常退出(组=0x40014760)
错误/AndroidRuntime(162):致命异常:主
错误/AndroidRuntime(162):java.lang.RuntimeException:无法启动活动组件信息{com.android.launcher/com.android.launcher.launcher}:android.content.res.Resources$NotFoundException:资源ID#0x7f030015
错误/AndroidRuntime(162):位于android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1748)
错误/AndroidRuntime(162):位于android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
错误/AndroidRuntime(162):位于android.app.ActivityThread.access$1500(ActivityThread.java:122)
错误/AndroidRuntime(162):位于android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
错误/AndroidRuntime(162):位于android.os.Handler.dispatchMessage(Handler.java:99)
ERROR/AndroidRuntime(162):位于android.os.Looper.loop(Looper.java:132)
错误/AndroidRuntime(162):位于android.app.ActivityThread.main(ActivityThread.java:4025)
错误/AndroidRuntime(162):位于java.lang.reflect.Method.Invokenactive(本机方法)
ERROR/AndroidRuntime(162):位于java.lang.reflect.Method.invoke(Method.java:491)
ERROR/AndroidRuntime(162):位于com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
ERROR/AndroidRuntime(162):位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
错误/AndroidRuntime(162):位于dalvik.system.NativeStart.main(本机方法)
错误/AndroidRuntime(162):由以下原因引起:android.content.res.Resources$NotFoundException:资源ID#0x7f030015
错误/AndroidRuntime(162):位于android.content.res.Resources.getValue(Resources.java:1014)
错误/AndroidRuntime(162):位于android.content.res.Resources.loadXmlResourceParser(Resources.java:2039)
错误/AndroidRuntime(162):位于android.content.res.Resources.getLayout(Resources.java:853)
错误/AndroidRuntime(162):在android.view.LayoutInflater.充气(LayoutInflater.java:389)
错误/AndroidRuntime(162):在android.view.LayoutInflater.inflate处(LayoutInflater.java:347)
错误/AndroidRuntime(162):位于com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:223)
错误/AndroidRuntime(162):位于android.app.Activity.setContentView(Activity.java:1780)
错误/AndroidRuntime(162):位于com.android.Launcher.2.Launcher.onCreate(Launcher.java:336)
错误/AndroidRuntime(162):位于android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
错误/AndroidRuntime(162):位于android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
错误/AndroidRuntime(162):。。。还有11个
WARN/dalvikvm(162):threadid=3:挂起时旋转#1 threadid=10(pcf=0)
你好世界节目:
package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText(R.string.hello);
setContentView(tv);
}
}
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/hello" />
layout/main.xml:
package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText(R.string.hello);
setContentView(tv);
}
}
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/hello" />
多谢各位
Keerthi您的/res/values/string.xml文件中是否有字符串“hello”?查找此问题的最佳方法是在R文件中搜索0x7f030015,并找到问题所在“string.xml”中有什么“文件?如果不是xml格式,它将无法编译。my strings.xml文件的内容粘贴在Hello World,HelloAndroid下面!”!HelloAndroid