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

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

    I will answer the question even though it has been a long time since it was thrown, just in case someone else get to it.

    Tested on Android Studio ONLY (but I guess it could work for Eclipse as well) :

    Check your build/source/r folder. In there, you should find some directories labelled under the name of your gradle build name (default : debug). Verify that the name of the package associated with R is the one you want.

    I know this trick solves the problem of switching namespace, because Android Studio (or Gradle I don't know who is responsible for that) seems not to regenerate it in that case.

    I haven't tried it when importing a project from Eclipse though.

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

    Did you follow steps here? First update your Eclipse ADT plugin, then export project and the import in Android Studio.

    http://developer.android.com/sdk/installing/migrate.html

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

    Check your project package! I had brought some classes over from another project and did not notice the subtle change in the package name. See top of your AndroidManifest.xml

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

    Go to File → Settings → Editor → Auto Import and at java tab you should have:

    Insert imports on paste: ASK.
    If you have import for ALL, then Android Studio import other file.

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

    As for me, the problem was in this superfluous line:

    import android.R;

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

    Go to Menu-Tab -> Project -> Build -> Automatically(check this option). and than reopen a new project.

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