Android Studio don't generate R.java for my import project

后端 未结 23 1578
天命终不由人
天命终不由人 2020-12-29 04:20

I import a project to Android Studio , but the R.java is always empty.

public final class R {
}

I have tried:

  1. Make project,ma
相关标签:
23条回答
  • 2020-12-29 04:25

    When I was trying to add another flavour I face same situation.

    I found in one of post and I gave successful try and it work. Following I did: File -> Invalidate Cached/Restart.

    0 讨论(0)
  • 2020-12-29 04:25
    File->Invalide Cahces / Restart
    
    0 讨论(0)
  • 2020-12-29 04:25

    I had a similar problem in a large multi-module project with many dependencies among the modules. What worked for me, was to attempt to build separately from command line all the modules that failed to build within Android Studio. That gave me indications on resources missing in each project. From the project level in my console I did:

    $ cd moduleName
    $ ../gradlew assembleDebug
    

    This provided me with a number of 'No resource found that matches the given name' errors, that weren't shown before, when I build the project as a whole.

    0 讨论(0)
  • 2020-12-29 04:25

    I had this problem after update gradle...

    There are several reasons that causes the project not to be built:

    1-Unknown error in drawable or xml files

    2-Update gradle or libraries and etc ...

    Solution :

    1-Clean and rebuild project

    2-Delete .idea and build folders in project file(shown in picture) then goto "File/Invalidate catch-restart"

    3-Roll back to previous gradle version and libraries.

    0 讨论(0)
  • 2020-12-29 04:26

    I had a lot of problems exporting a project from Eclipse (assuming that is where you are exporting from). It was much easier for me to create a new project in Android Studio, then copy over the java files, xml files, layout directories, etc, and the AndroidManifest, into the appropriate location in the new project.

    If you already have an R.java file for your project, you could try just copying it over to the new project. In Android Studio the R.java file seems to reside in build/source/r/debug/your-package-name/

    0 讨论(0)
  • 2020-12-29 04:28

    Had the same problem and solved it by:

    1. running / building the project (it was deployed to the device, in my case)
    2. right-clicking on the Project/Module/build folder
    3. choose: Synchronize 'build' - then i found

    Project/Module/build/source/r/debug/package/R.java

    Probably it was even there before the project was build, but I didn't test that.

    I hope this was helpful, even though the answer comes a bit late and by now the bug with the

    Settings->Compiler->[ ] Use external build

    should be fixed afaik ;-)

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