android.content.res.Resources$NotFoundException


Last Updated:

  1. wertyu

    wertyu Member This Topic's Starter

    Joined:
    Oct 5, 2009
    Messages:
    13
    Likes Received:
    0
    Hi,

    Hope someone can help here, I'm seeing the below stack trace when running my app (it crashes immeadiately);

    02-03 11:36:54.490: WARN/ResourceType(694): Resources don't contain package for resource number 0xff00ff00
    02-03 11:36:54.499: DEBUG/AndroidRuntime(694): Shutting down VM
    02-03 11:36:54.499: WARN/dalvikvm(694): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
    02-03 11:36:54.499: ERROR/AndroidRuntime(694): Uncaught handler: thread main exiting due to uncaught exception
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): java.lang.RuntimeException: Unable to start activity ComponentInfo{src.com.example.ChronoTest/src.com.example.ChronoTest.ChronoTest}: android.content.res.Resources$NotFoundException: Resource ID #0xff00ff00
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2454)
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470)
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): at android.os.Handler.dispatchMessage(Handler.java:99)
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): at android.os.Looper.loop(Looper.java:123)
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): at android.app.ActivityThread.main(ActivityThread.java:4310)
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): at java.lang.reflect.Method.invokeNative(Native Method)
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): at java.lang.reflect.Method.invoke(Method.java:521)
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): at dalvik.system.NativeStart.main(Native Method)
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0xff00ff00
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): at android.content.res.Resources.getValue(Resources.java:891)
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): at android.content.res.Resources.getDrawable(Resources.java:579)
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): at android.view.View.setBackgroundResource(View.java:7187)
    02-03 11:36:54.509: ERROR/AndroidRuntime(694): at src.com.example.ChronoTest.ChronoTest.onCreate(ChronoTest.java:85)

    I know the offending line is;

    startButton.setBackgroundResource(Color.GREEN);

    but I done know why. Here is a snippet of the code (basically just changing the colour of the button). If I dont put in that line above it all works fine;


    protected
    void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);

    TextView syTxt= new TextView(layout.getContext());
    TextView hoursTxt= new TextView(layout.getContext());
    TextView symbolTxt= new TextView(layout.getContext());

    layout.addView(syTxt);
    layout.addView(hoursTxt);
    layout.addView(symbolTxt);

    startButton = new Button(this);
    startButton.setText("Start");


    startButton.setBackgroundResource(Color.GREEN);
    setContentView(layout);

    }

     

    Advertisement
  2. wertyu

    wertyu Member This Topic's Starter

    Joined:
    Oct 5, 2009
    Messages:
    13
    Likes Received:
    0
    Please close this thread. Noob mistake;

    I meant to use;

    setBackgroundColor() and not setBackgroundResource
     

Share This Page

Loading...