diff --git a/example/androidlib/java/1-hello-world/build.mill b/example/androidlib/java/1-hello-world/build.mill index 3d6a9be7d269..6a651f95bdf6 100644 --- a/example/androidlib/java/1-hello-world/build.mill +++ b/example/androidlib/java/1-hello-world/build.mill @@ -99,7 +99,7 @@ object app extends AndroidAppModule { /** Usage > ./mill show app.test -...compiling 1 Java source... +...compiling 2 Java sources to out/app/test/compile.dest/classes... > cat out/app/test/testForked.dest/out.json ["",[{"fullyQualifiedName":"com.helloworld.ExampleUnitTest.textSize_isCorrect","selector":"com.helloworld.ExampleUnitTest.textSize_isCorrect","duration":...,"status":"Success"}]] diff --git a/libs/androidlib/src/mill/androidlib/AndroidAppModule.scala b/libs/androidlib/src/mill/androidlib/AndroidAppModule.scala index 5bab22d92083..f4caaaf5449d 100644 --- a/libs/androidlib/src/mill/androidlib/AndroidAppModule.scala +++ b/libs/androidlib/src/mill/androidlib/AndroidAppModule.scala @@ -235,6 +235,10 @@ trait AndroidAppModule extends AndroidModule { outer => ) } + override def androidAaptOptions: T[Seq[String]] = Task { + super.androidAaptOptions().filterNot(_ == "--non-final-ids") + } + /** * Regex patterns of files to be excluded from packaging into the APK. */ diff --git a/libs/androidlib/src/mill/androidlib/AndroidModule.scala b/libs/androidlib/src/mill/androidlib/AndroidModule.scala index 264e9aa0600d..52516f81522f 100644 --- a/libs/androidlib/src/mill/androidlib/AndroidModule.scala +++ b/libs/androidlib/src/mill/androidlib/AndroidModule.scala @@ -131,15 +131,24 @@ trait AndroidModule extends JavaModule { outer => * Specifies AAPT options for Android resource compilation. */ def androidAaptOptions: T[Seq[String]] = Task { - if (androidIsDebug()) { - Seq( - "--proguard-minimal-keep-rules", - "--debug-mode", - "--auto-add-overlay" - ) - } else { - Seq("--auto-add-overlay") - } + val debugOptions = Seq( + "--proguard-minimal-keep-rules", + "--debug-mode" + ) + + // Add module dependencies' namespaces as extra packages + // TODO: cleanup once we properly pass resources from dependencies + val extraPackages = moduleDeps.collect { + case p: AndroidModule => Seq("--extra-packages", p.androidNamespace) + }.flatten + + Seq( + "--auto-add-overlay", + "--no-version-vectors", + "--no-proguard-location-reference", + "--non-final-ids" + ) ++ extraPackages + ++ Option.when(androidIsDebug())(debugOptions).toSeq.flatten } def androidProviderProguardConfigRules: T[Seq[String]] = Task { @@ -498,7 +507,8 @@ trait AndroidModule extends JavaModule { outer => // * it will generate R.java for the library even library has no resources declared // * R.java will have not only resource ID from this library, but from other libraries as well. They should be stripped. val rClassDir = androidLinkedResources().path / "generatedSources/java" - val mainRClassPath = os.walk(rClassDir) + val rSources = os.walk(rClassDir).filter(p => os.isFile(p) && p.ext == "java") + val mainRClassPath = rSources .find(_.last == "R.java") .get @@ -519,7 +529,7 @@ trait AndroidModule extends JavaModule { outer => ) } yield PathRef(libRClassPath) - libClasses :+ PathRef(mainRClassPath) + libClasses ++ rSources.map(PathRef(_)) } /**