Developing for Android in Eclipse: R.java not regenerating

前端 未结 30 3085
孤城傲影
孤城傲影 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 08:05

    Cleaning project, closing Eclipse, re-opening it and launching my project finally made my R.java to reappear... Hope it helps

    0 讨论(0)
  • 2020-11-21 08:05

    OK so it's clear that there can be a lot of causes for this problem. If you're on a 64 bit linux machine and you are just setting up the ADT for the first time, you may get this problem where R is not automatically generating. Check the console tab and you may see an error similar to:

     'No such file or directory' while attempting to get adb version from '/home/patrick/code/android-sdks/platform-tools/adb'
    

    If that's the case you need to install ia32-libs, using something like:

     sudo apt-get install ia32-libs
    

    See here for details: Android adb not found

    0 讨论(0)
  • 2020-11-21 08:05

    Also make sure that you have the latest version of the ADT plugin, and open the Android SDK manager to update all SDK tools to the latest version. Check for updates in Eclipse itself as well. Non-matching versions caused the problem for me.

    0 讨论(0)
  • 2020-11-21 08:06

    In Eclipse, simply use Project --> clean to clean the project. The R.java is going to be automaticly (re)-created.

    If for some reason that dosn't work: Make sure your layout.xml files don't contains errors. Eclipse seems to be a bit buggy here: sometimes it doesn't mark the errors within the XML nor the package explorer. In such a case: Take a look at the "console" or "problems" view after using "clean". All errors should be displayed there. Fix them and redo a clean.

    NOTE: It is NOT neccessary to fix the errors you get because of a missing R file! Just fix the XML files and other project errors and use clean!

    0 讨论(0)
  • 2020-11-21 08:06

    If your OS is Ubuntu, I can provide some suggestion:

    1. Install or upgrade ia32-lib:

      sudo apt-get upgrade ia32-libs
      
    2. Check if you have the right permission on the aapt folder:

      cd ANDROID/adt-bundle-linux-x86_64-20130522/sdk/build-tools/android-4.2.2
      chmod 777 aapt
      
    3. Start Eclipse:

      sudo eclipse
      
    4. Run Project -> Clean in Eclipse

    0 讨论(0)
  • 2020-11-21 08:06

    I found a solution why R.class is not made by Eclipse after making it again - 2 clean, build, etc.

    The problem is here in strings.xml:

    <string name="hello">Hello World, HelloAutoComplete!</string>
    
    <string name="app_name">HelloAutoComplete</string>
    

    These are by default created by Eclipse when you create projects.

    Definitely you are changing the strings.xml for your own requirement. Sometimes you clear the string.xmls these two lines from your code:

    It is making a problem in the AndroidManifest.xml file:

    <application android:icon="@drawable/icon"  android:label="@string/app_name">
    <activity android:name=".HelloAutoComplete" android:label="@string/app_name">
    

    So it can't communicate with strings.xml.

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