I have migrated my 2.3 settings to 3.1.2, and for testing I have opened a smaller project of mine, "proj2", in Android Studio 3.1.2. Structure of my projects:
AndroidDir/
proj1/
app
lib
proj2
app
In proj2, I refer to proj1 lib, an Android library, with proj2/settings.gradle:
include ':lib', ':app'
project(':lib').projectDir = new File(settingsDir, '../proj1/lib')
In 2.3 this worked without any problems, and I could edit my lib code in both proj1 and proj2.
In 3.1.2, proj2 is treated as if I had loaded proj1, while I have opened the proj1 path. Android Studio shows the path of proj2 in the title bar, but the project overview shows all modules of proj1. And it tries to build proj1 instead of proj2. Restarting does not help.
Remove the proj2/.idea directory, then, in Android Studio, choose "File -> Invalide Caches / Restart..."
I am having this problem as well on Android Studio 3.4 and 3.5 canary 13.
More specifically, when I try to share gradle modules between different projects using the .projectDir
directive in settings.gradle as described above, any attempt to load a second project that shares that gradle module will fail.
My current workaround is to use Git to load the shared gradle module into a different folder so that each project winds up with its own copy of that shared Gradle module like so:
Project A:
include ':lib', ':app'
project(':lib').projectDir = new File("./path/to/proj1/lib")
Project B:
include ':lib', ':app'
project(':lib').projectDir = new File( "../different/path/to/copy/of/proj1/lib")
Yes, this workaround brings with it its own set of problems like having to constantly sync the 2 folders, so please,
Please upvote this issue here to give it more priority.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With