Skip to content
2 changes: 1 addition & 1 deletion example/androidlib/java/1-hello-world/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was intended to match for the compile task and should have failed when we defaulted BuildConfig to true in #6145 as a second source was being added, but it coincidentaly matched with the androidCompiledRClasses

compiling 1 Java sources to out/app/test/androidCompiledRClasses.dest/classes

Now we explicitly match for the compile task


> cat out/app/test/testForked.dest/out.json
["",[{"fullyQualifiedName":"com.helloworld.ExampleUnitTest.textSize_isCorrect","selector":"com.helloworld.ExampleUnitTest.textSize_isCorrect","duration":...,"status":"Success"}]]
Expand Down
4 changes: 4 additions & 0 deletions libs/androidlib/src/mill/androidlib/AndroidAppModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
32 changes: 21 additions & 11 deletions libs/androidlib/src/mill/androidlib/AndroidModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a TODO here to clean up, once we rewire the submodule sources to go to the app module

// TODO: cleanup once we properly pass resources from dependencies
val extraPackages = moduleDeps.collect {
Copy link
Contributor

@vaslabs vaslabs Nov 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe here we need transitive modules.

Also for better customisation , we can make this into a task.

androidAaptLinkExtraPackages

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 {
Expand Down Expand Up @@ -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

Expand All @@ -519,7 +529,7 @@ trait AndroidModule extends JavaModule { outer =>
)
} yield PathRef(libRClassPath)

libClasses :+ PathRef(mainRClassPath)
libClasses ++ rSources.map(PathRef(_))
}

/**
Expand Down
Loading