简体   繁体   中英

Android Studio generates R file only for modules with no module dependencies in multi-module project

After updating to AS 3.3.1 from 3.2.something I've got a strange bug: R file is generated only for modules that do not implement any other modules. via cmd+B, but every resource file like R.layout.activity_main is highlited with an "unresolved reference" message, until I remove every module implementation from module build.gradle and resync the project. 通过cmd + B ,但是每个资源文件(如R.layout.activity_main都带有“未解析的引用”消息,直到我从build.gradle模块中删除每个模块实现并重新同步项目build.gradle

As far as I've noticed, the problem does not related with android gradle 3.3.0 or kotlin 1.3, since my old projects are affected as well.

What I've already tried:

  • Clean/Rebuild project
  • Invalidate cache
  • Resync Gradle
  • Switch to Android Gradle 3.2.1
  • delete .idea directory

Here's my project , module build.gradle example and used libraries . For example, if I comment implementation(project(":presentation")) line in mainscreen/build.gradle.kts , the error disappears. Obviously, it isn't the solution.

UPD: SOLVED

Solution: you have to specify different package names in each AndroidManifest.xml files, ie com.mycompany.example.launcher for launcher module, com.mycompany.example.presentation for presentation module et cetera .

[solution1] You can delete the old version of gradle from your system and start installing its new version.

[solution2] Or remove Android Studio and reinstall it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM