android.content.res.Resources$NotFoundException: String array resource ID #0x7f070002

后端 未结 6 1053
不知归路
不知归路 2020-12-14 23:33

I\'m having problem getting a string array for strings.xml .

The error is:

android.content.res.Resources$NotFoundException: String array resource ID         


        
相关标签:
6条回答
  • 2020-12-15 00:13

    Make sure you don't have variants of the values resources, with the string array defined only for a subset of the variants. For example:

    values-v21/strings.xml - defined
    values/strings.xml - not defined
    

    If the resource is present in at least one variant, you get the entry in R and can refer to it in code, but the runtime resource file variant does not necessarily have the resource.

    0 讨论(0)
  • 2020-12-15 00:13

    I also have the same error. I simply Invalidated caches and restart android studio and everything works fine then. To Invalidated caches and restart Goto Files > Invalidate Caches/restart. This is some sort of bug of the android studio it happens to me several times.

    0 讨论(0)
  • 2020-12-15 00:15

    I got this error because I used TextView.setText(int) to set a number in the text. The problem is that Android thinks that the integer is a ressource id. Therefore I should encapsulate the interger inside of String.valueOf(int) so the code becomes TextView.setText(String.valueOf(int));

    0 讨论(0)
  • 2020-12-15 00:15

    in my case array.xml was in w820dp version. i just created another in values.xml without w820dp. Works!!!

    0 讨论(0)
  • 2020-12-15 00:19

    Do this to render Integer to textview

    TextView.setText(String.valueOf(int));
    
    0 讨论(0)
  • 2020-12-15 00:25

    I solve the problem. Juste create a values/strings.xml file with all your string values define in values-v21/strings.xml.

    0 讨论(0)
提交回复
热议问题