IntelliJ IDEA - Can't build anything, always get “package R does not exist”

前端 未结 13 510
轻奢々
轻奢々 2020-12-16 09:32

I\'m trying to use IntelliJ IDEA to work on an Android app with a colleague that swears by it, but I\'m unable to build any of the Android projects he sends me because whene

相关标签:
13条回答
  • 2020-12-16 09:48

    Had same issue - the issue was the Manifest file was did not have the default Activity setup properly.

    0 讨论(0)
  • 2020-12-16 09:57

    If you run into this with a package that has been building before you need to "Rebuild". Build->Rebuild Project . Deleting gen does not do it since IDEA saves the actual generated R somewhere else.

    0 讨论(0)
  • 2020-12-16 09:57

    To all the hopeless people who have reached this far down the answers: I feel your pain. I have spent an hour doing nothing but trying all those things above as well as proposals from other sources. I have checked all my xml resources twice, cleaned caches, rebuilt a dozen times, even restarted the entire machine. Here is what actually worked for me:

    Under 'Build Variants' (lower left corner), I selected a different Build Variant (in my case release instead of debug) for the target that had the missing R problem. Solved it.

    0 讨论(0)
  • 2020-12-16 09:58

    Try create new project and select "Create project from existing sources"

    0 讨论(0)
  • 2020-12-16 10:02

    I just restart IntelliJ and it magically solved. Try it first.

    0 讨论(0)
  • 2020-12-16 10:07

    In my case, I added some classes from another project and I had to add the import to the R package from my actual project:

    import com.youcompanyname.yourprojectname.R;
    
    0 讨论(0)
提交回复
热议问题