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

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

    Goto File -> Settings -> Compiler now check use external build

    then rebuild project

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

    I managed to regenerate R: File->Settings->Compiler

    then UNCHECK "Use in-process build"

    Rebuild Project

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

    Just use the 'Rebuild Project' from the 'Build' menu from the top menu bar.

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

    In my case I had an empty line prior a drawable definition in xml. This was braking aapt essentially not allowing to generate R.java .

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

    For me the problem with the R class has been related to automatically organized imports.

    As AndroidStudio has the option to allow the automatic imports, it took the wrong R class and thats why the ids have not been found and Gradle was throwing errors!

    So check if the import to the R class is referencing to the one you need.

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

    If you are facing this problem in a specific module in your project, you could try opening just that module as a project and then build it. This worked for me. It was failing to generate the R file for the module when I was trying to re-build the entire project.

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