Android Resources Not Found Exception

1.1k views Asked by At

Does the following error indicate that the Resource is not available from the Java Source? I verified the R file includes the Resource ID listed below:

Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f0b0015
            at android.content.res.Resources.getValue(Resources.java:2009)
            at android.content.res.Resources.getColor(Resources.java:1691)
            at com.flatbutton.FButton.init(FButton.java:97)
            at com.flatbutton.FButton.<init>(FButton.java:47)
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at android.view.LayoutInflater.createView(LayoutInflater.java:600)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
            at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:249)
            at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
            at com.androidvoter.MainActivity.onCreate(MainActivity.java:16)

Line #97 of FButton has:

mButtonColor = resources.getColor(R.color.fbutton_default_color);

In FButton, it is importing the package's R file.

I also verified the resource R.color.fbutton_default_color in the R.java file:

public static final int fbutton_default_color=0x7f0b0015;
2

There are 2 answers

0
code On BEST ANSWER

AH, I found the solution. Apparently, inside the app/src/main/res directory, there were 2 folders:

"values"
"values-w820dp"

The colors.xml file was inside values-w820dp. This is why the resource was not able to be found. It was solved by moving it into the values directory.

3
Bidhan On

Try using getResources() instead.

mButtonColor = getResources().getColor(R.color.fbutton_default_color);