我是Android应用程序开发的新手,我最近下载了&安装了Android 3.1平台(API 12)。
我正在阅读教程,我正在尝试运行'Hello world'程序(http://developer.android.com/resources/tutorials/hello-world.html)
但它不起作用,我最终看到模拟器上的锁定屏幕。当我尝试解锁时,它显示“强制关闭”错误消息&按钮。
我通过这个论坛寻找答案,并检查了LogCat输出。我在那里发现了一个例外,但我不确定如何解决这个问题。有人可以帮帮我吗?
异常堆栈跟踪:
WARN/ResourceType(162): Failure getting entry for 0x7f030015 (t=2 e=21) in package 0 (error -75) DEBUG/AndroidRuntime(162): Shutting down VM WARN/dalvikvm(162): threadid=1: thread exiting with uncaught exception (group=0x40014760) ERROR/AndroidRuntime(162): FATAL EXCEPTION: main ERROR/AndroidRuntime(162): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.launcher/com.android.launcher2.Launcher}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030015 ERROR/AndroidRuntime(162): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1748) ERROR/AndroidRuntime(162): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764) ERROR/AndroidRuntime(162): at android.app.ActivityThread.access$1500(ActivityThread.java:122) ERROR/AndroidRuntime(162): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002) ERROR/AndroidRuntime(162): at android.os.Handler.dispatchMessage(Handler.java:99) ERROR/AndroidRuntime(162): at android.os.Looper.loop(Looper.java:132) ERROR/AndroidRuntime(162): at android.app.ActivityThread.main(ActivityThread.java:4025) ERROR/AndroidRuntime(162): at java.lang.reflect.Method.invokeNative(Native Method) ERROR/AndroidRuntime(162): at java.lang.reflect.Method.invoke(Method.java:491) ERROR/AndroidRuntime(162): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) ERROR/AndroidRuntime(162): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) ERROR/AndroidRuntime(162): at dalvik.system.NativeStart.main(Native Method) ERROR/AndroidRuntime(162): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030015 ERROR/AndroidRuntime(162): at android.content.res.Resources.getValue(Resources.java:1014) ERROR/AndroidRuntime(162): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2039) ERROR/AndroidRuntime(162): at android.content.res.Resources.getLayout(Resources.java:853) ERROR/AndroidRuntime(162): at android.view.LayoutInflater.inflate(LayoutInflater.java:389) ERROR/AndroidRuntime(162): at android.view.LayoutInflater.inflate(LayoutInflater.java:347) ERROR/AndroidRuntime(162): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:223) ERROR/AndroidRuntime(162): at android.app.Activity.setContentView(Activity.java:1780) ERROR/AndroidRuntime(162): at com.android.launcher2.Launcher.onCreate(Launcher.java:336) ERROR/AndroidRuntime(162): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048) ERROR/AndroidRuntime(162): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712) ERROR/AndroidRuntime(162): ... 11 more WARN/dalvikvm(162): threadid=3: spin on suspend #1 threadid=10 (pcf=0)
Hello World计划:
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); } }
布局/ main.xml中:
<?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