【问题标题】:Syntax error on token "int" , VariableDeclarationId expected after this token R.java error令牌“int”上的语法错误,此令牌 R.java 错误后预期的 VariableDeclarationId
【发布时间】:2013-07-26 12:40:16
【问题描述】:

这是一次又一次产生的错误。 我已经清理了我的项目。

 public static final class id {
        public static final int  =0x7f07005b;
        public static final int button1=0x7f070004;
        public static final int button2=0x7f070005;
        public static final int frameLayout1hardMatchup=0x7f070009;

String.xml 没有错误,这是我的String.xml。

<string name="hello">Hello World, MemoryCardsActivity!</string>
<string name="app_name">Princess  Memory Cards</string>
<string name="text_name">Congrates</string>
 <string name="text_help">Turn over pairs of matching cards, tap to flip two cards, as the match happens, they get removed from the screen.Try to get all cards match in minimum moves and proceed to next level</string>

而且也没有任何@+id 类型的错误。 还有什么可能是这个原因。 任何积极的回应将不胜感激.. :(

【问题讨论】:

    标签: android android-xml r.java-file


    【解决方案1】:

    你缺少一个变量名

    public static final int  = 0x7f07005b;
    

    改为

    public static final int variableName = 0x7f07005b;
    

    【讨论】:

    • @blackbelt 谢谢,我不喜欢没有详细解释的答案,但是... ;)
    • 它的名字很清楚,但我检查了我所有的类和 xml 文件,我没有发现任何问题。如果我错过了,有什么方法可以检测到我会错过它的地方。 :(
    • @VaishaliSharma 你必须检查你的xml里面是否放了一个像android:id=""这样的项目
    • “id”类是在 R.java 文件中自动生成的,所以:即使手动修复这个文件也不能解决问题!
    • 在我的一个布局中,我错过了分配 imageView 的 id,就像“@+id/”在那里,我将其更改为“@+id/imgView”。它解决了我的问题。
    【解决方案2】:

    我通过更改我的一个布局 XML 文件产生了类似的错误。我变了

    android:id="@+id/image_frame"
    

    android:id="@+id/ " 
    

    我看到此更改的错误是

    public static final int  =0x7f080010; 
    // Syntax error on token "int", VariableDeclaratorId expected after this token
    

    这似乎是@codeMagic 所描述的。

    【讨论】:

      猜你喜欢
      • 2013-03-27
      • 1970-01-01
      • 1970-01-01
      • 2013-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多