Android Studio cannot resolve R in imported project?

后端 未结 30 2033
名媛妹妹
名媛妹妹 2020-11-30 02:27

I\'m trying the new Android Studio. I\'ve exported a project from eclipse, using the build gradle option. I\'ve then imported it in Android Studio. The R.java file under gen

相关标签:
30条回答
  • Goto File -> Settings -> Compiler now check use external build

    then rebuild project

    0 讨论(0)
  • 2020-11-30 02:58

    The solution is to open project structure window. [by press command+; on mac ox s. i don't what's the key shortcut for other platforms. you should be able to find it under "File" menu.] and click "Modules" under "Project settings" section, then your project is revealed, finally mark the generated R.java as Sources.

    I am using Intellij idea 14.0 CE. The generated R.java is located at build/generated/source/r/debug/com/example/xxx

    Really not easy to find for the first time.

    0 讨论(0)
  • 2020-11-30 03:00

    File -> invalidate caches

    then

    Restart application

    0 讨论(0)
  • 2020-11-30 03:00

    check the build tools version in build.gradle(for module app). Then go to android sdk manager see if the version is installed if not install it or change the build tools version to the one which is installed like below.

        android {
              buildToolsVersion "22.0.1"
              ..
              ..
              ..
         }
    
    0 讨论(0)
  • 2020-11-30 03:01

    In my case I had an Activity file imported from Eclipse that had the line:

    import android.R;
    

    So all of my R classes were resolving to the SDK, as soon as I commented out that line everything compiled correctly to my package. I only noticed the issue when I was moving the project from my Mac to my Windows machine.

    0 讨论(0)
  • 2020-11-30 03:02

    Had this error when importing project from Eclipse. The reason was some of the xml files had errors. Check ALL your XML files for errors. Including androidmanifest.xml, and values, themes, styles, layouts folders, etc. Warnings in xml are ok, but errors will generate this error.

    Afterwards, do a Clean Project and rebuild.

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