Android Studio cannot resolve R in imported project?

后端 未结 30 2034
名媛妹妹
名媛妹妹 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条回答
  • 2020-11-30 02:52

    I had this same issue. The package name was wrong in two of the following three files. I manually updated the package name and everything started working again.

    gen/com/example/app/BuildConfig.java

    gen/com/example/app/Manifest.java

    gen/com/example/app/R.java

    I'm not sure what caused them to change as I've never modified these files before.

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

    This is probably due to a failed resource build

    Once the issue is fixed, a mere Build > Rebuild Project will do the trick

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

    just clean project and then sync your project with gradle file.

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

    This issue starting occurring for me when I started working with build.gradle to incorporate the data necessary (signingConfigs) to build a signed .apk. After what appeared to be a successful build from the command line, I discovered that going into any class using R.* that all R.* references were unresolved.

    The answers here didn't help me. I decided to re-import the project and it magically fixed the issue. File/Import Project... and select the build.gradle file in my apps root folder. I would love to know why re-import fixed this :)

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

    Regarding the following, from Crossle Song's answer

    1. Press F4 into Project Structure, Check SDKs on left
    2. Click Modules ---> Source Tab, check gen and src as sources

    Despite the message "We will provide a UI to configure project settings later....etc" this worked for me.

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

    For me, with Android Studio 1.5.1, the solution was to recreate the whole project with a slightly different name.

    I think it didn't handle the app name "Kommentator_AS", because several places the package was named"Kommentator" instead.

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