Developing for Android in Eclipse: R.java not regenerating

前端 未结 30 3068
孤城傲影
孤城傲影 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:56

    For me, I had linked v7 appcompat twice. Anyhow, in Eclipse, right click the project name in Package Explorer or Navigator, go to Properties, Android, and uncheck any duplicates in the Library section. You may need to Build --> Clean afterwards.

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

    I've came across this problem a few times. I found that if I didn't import the package R through my application's name, for example, if my application had the package name example.test then I found that I had to import example.test.R in order to access any of the resources.

    If this wasn't imported then the resources that where getting returned were the default resources with none of my own included.

    With that said if you find that you are only getting a list of default resources then just check to make sure that you're importing application_package_name.R and not android.R.

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

    For me, this error was caused when I tried to duplicate an existing res/menu instead of creating one with the wizard.

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

    It is ALWAYS helpful to take a look at the Problems Tab in Eclipse. In my case, I was getting a "android unable to resolve target 'android-8'" error message that kept the R.java from being generated. So, I corrected the imported target to the one I was using in the default.properties file, then I performed a clean via Projects->Clean and voila! R.java is automatically generated! Hope it helps!

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

    My problem was that appcompat was not in the same directory as my project.

    I found this out when compiling my app with Ant.

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

    I changed my layout XML file name and found out later that of the XML file (widget provider in this case) still refers to the old layout XML which doesn't exist, and that prevented the auto generation/correction of R class.

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