开发者

Unable to start activity ComponentInfo{...}: android.content.res.Resources$NotFoundException: Resource ID

I'm new to Android application development and I recently downloaded & installed Android 3.1 platform (API 12).

I'm going through the tutorial and I'm trying to run the 'Hello world' program (http://developer.android.com/resources/tutorials/hello-world.html)

But it doesn't work, I end up seeing the locked screen on the emulator. When I try to unlock it, it shows the:

"Force close"

error message & button.

I went through this forum for answers and I checked the LogCat output. I found an exception there but I'm not sure how to fix the issue. Can some one please help me out?

Exception stack trace:

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.j开发者_开发问答ava: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 program:

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);
    }
}

layout/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" />

Thank you Keerthi

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜