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

后端 未结 23 1581
天命终不由人
天命终不由人 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:50

    I found my solution here. In short make sure not only the Eclipse plugin(if you are using eclipse) is updated. Also ensure that the Android SDK Tools, the SDK platform-tools and the SDK Build-tools are updated. After this restart your machine.

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

    Best Solution for android studio Users :

    Goto : Menu tab - > Build - > Rebuild Project

    after rebuild Proj. your R.Java file problem will be solve automatically ..

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

    So, this is the latest solution if anyone get's stuck like I did today especially, for R.Java file.

    If you have lost the count of:

    • Clean Project
    • Rebuild Project
    • Invalidate Caches / Restart
    • deleted .gradle folder
    • deleted .idea folder
    • deleted app/build/generated folder
    • checked your xml files
    • checked your drawables and strings

    then try this:

    check your classpath dependency in your Project Gradle Scripts and if it's, this:

    classpath 'com.android.tools.build:gradle:3.3.2'
    

    then downgrade it to, this:

    classpath 'com.android.tools.build:gradle:3.2.1'
    
    0 讨论(0)
  • 2020-12-29 04:51

    I failed even if I tried to update the SDK tools as mentioned here.

    Here is how I solved the problem (for the library projects imported).

    In File -> Project Structure -> Modules, I removed the problematic projects, and added them again by selecting New Module -> Android Library Module.

    Select "Android Library Module" when adding project.

    After rebuilding the project, I got all the R.java files back.

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

    I had a similar problem within my project using Android Studio 1.5.1. For me, bulding the project from command line by using following command resolved the problem:

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