Developing for Android in Eclipse: R.java not regenerating

前端 未结 30 3086
孤城傲影
孤城傲影 2020-11-21 07:04

I\'ve found out that my R.java is never updated, so it doesn\'t contain information about my new resources, so I decided to delete it and thought that Eclipse would generate

相关标签:
30条回答
  • 2020-11-21 07:48

    I had this problem. Accidentally I deleted this

    xmlns:tools="http://schemas.android.com/tools"
    

    which started causing build errors all over the project in my XML files as well as my Java files. As soon as I retyped what I deleted, it worked again :)

    0 讨论(0)
  • 2020-11-21 07:49

    There's obviously no one final answer to this, but here's another one I don't see here already:

    I've had R.java disappear after (attempting) a Team Synchronize, and there were conflict resolution files in the project (i.e., thingy.xml.mine,thingy.xml.r35, etc.). Deleting them/resolving the conflicts regenerated R.

    0 讨论(0)
  • 2020-11-21 07:51

    I had the same issue. When I checked it out I found that the name of the XML resource under layout was not having the correct naming convention. It had some capital letters. So I renamed it to make all letters lowercase and the magic worked.

    0 讨论(0)
  • 2020-11-21 07:52

    I had the same issue, and I finally found the problem: In the strings.xml, I did not keep the line <string name="app_name">program-name</string> which is present by default when creating a new Android project. I thought it was only used for the program HelloWord, which is the original program.

    However, the AndroidManifest.xml refers to this value, hence:

    => A compile error;
    => the R.java isn't updated;
    => ID are not recognized...

    0 讨论(0)
  • 2020-11-21 07:52

    You 100% have an error in an XML-file, but the XML verification does not show you the error. This is the reason why you need to check your XML files first!

    0 讨论(0)
  • One reason the R.class can go missing suddenly is when there are errors in you XML files. For instance, when you add an XML file with uppercase letters in the name like myCoolLayout.xml which is not allowed. Or when you have references that don't point to existing files, etc.

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