From 5cdf9a3b7b5ee494d93da780814791a137a291af Mon Sep 17 00:00:00 2001 From: Stylianos Anastasiou Date: Thu, 2 Oct 2025 11:39:52 +0300 Subject: [PATCH 1/5] draft --- website/docs/modules/ROOT/nav.adoc | 1 + .../pages/android/android-initial-setup.adoc | 26 +-------- .../ROOT/pages/android/android-release.adoc | 58 +++++++++++++++++++ 3 files changed, 60 insertions(+), 25 deletions(-) create mode 100644 website/docs/modules/ROOT/pages/android/android-release.adoc diff --git a/website/docs/modules/ROOT/nav.adoc b/website/docs/modules/ROOT/nav.adoc index 048dd950022b..6c00a728539a 100644 --- a/website/docs/modules/ROOT/nav.adoc +++ b/website/docs/modules/ROOT/nav.adoc @@ -33,6 +33,7 @@ * Experimental Platform Support ** Building Android Apps *** xref:android/android-initial-setup.adoc[] +*** xref:android/android-release.adoc[] *** xref:android/ide.adoc[] *** xref:android/java.adoc[] *** xref:android/kotlin.adoc[] diff --git a/website/docs/modules/ROOT/pages/android/android-initial-setup.adoc b/website/docs/modules/ROOT/pages/android/android-initial-setup.adoc index 2c14c6057dbc..d75079960f37 100644 --- a/website/docs/modules/ROOT/pages/android/android-initial-setup.adoc +++ b/website/docs/modules/ROOT/pages/android/android-initial-setup.adoc @@ -57,28 +57,4 @@ If you want to start with an example project, you can use the `init` command as == 4. Use Android Studio You can use Android Studio to open and work with your Mill project. -image::android/AndroidStudio.png[AndroidStudio.png] - -== 5. Release the project -By default, mill projects are considered in debug mode, so if your project is ready for release, you should add the following to your app object in the `build.mill` file: - -[source,scala] ----- -override def androidIsDebug = Task { false } -def androidReleaseKeyName: Option[String] = Some("releaseKey.jks") -def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") } -def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") } -def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") } ----- - -Make sure to replace the values with your actual keystore information. -If you don't have a keystore yet, you can create one using the `keytool` command: - -[,console] ----- -> keytool -genkey -v -keystore releaseKey.jks \ - -storepass -keyalg RSA \ - -keysize 2048 -validity 10000 \ - -alias releaseKey -keypass ----- - +image::android/AndroidStudio.png[AndroidStudio.png] \ No newline at end of file diff --git a/website/docs/modules/ROOT/pages/android/android-release.adoc b/website/docs/modules/ROOT/pages/android/android-release.adoc new file mode 100644 index 000000000000..95e2e45b32bf --- /dev/null +++ b/website/docs/modules/ROOT/pages/android/android-release.adoc @@ -0,0 +1,58 @@ += Android Release Guide +:page-aliases: android_release.adoc + +By default, mill projects are considered in debug mode, so if your project is ready for release, you should follow the steps below to configure your project for release builds. + +The code snippets below should be added to your app object in the `build.mill` file. + +== 1. Disable debug mode +[source,scala] +---- +def androidIsDebug = Task { false } +---- + +== 2. Configure signing information +To sign your APK for release, you need to provide the keystore information. +[source,scala] +---- +def androidReleaseKeyName: Option[String] = Some("releaseKey.jks") +def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") } +def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") } +def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") } +---- + +Make sure to replace the values with your actual keystore information. +If you don't have a keystore yet, you can create one using the `keytool` command: + +[,console] +---- +> keytool -genkey -v -keystore releaseKey.jks \ + -storepass -keyalg RSA \ + -keysize 2048 -validity 10000 \ + -alias releaseKey -keypass +---- + +== 3. (Optional) Enable ProGuard +If you want to enable ProGuard for code shrinking and obfuscation, you can do so by first extending your app object with `AndroidR8AppModule`. +You can then override the following methods. + +Example configuration: +[source,scala] +---- +def androidReleaseSettings = Task { + AndroidBuildTypeSettings( + isMinifyEnabled = true, + ) +} + +// You can specify your own ProGuard rules files here +def androidProjectProguardFiles = Task.Sources("proguard-rules.pro") + +// You can specify the default ProGuard filenames to be used +// These files are in //tools/proguard/proguard*.txt +def androidDefaultProguardFileNames = Task.Anon { + Seq("proguard-android-optimize.txt") +} +---- + + From 6b3c127534c2a9203f24064f2b4f84263a0d7936 Mon Sep 17 00:00:00 2001 From: Stylianos Anastasiou Date: Mon, 13 Oct 2025 10:18:22 +0300 Subject: [PATCH 2/5] use env vars --- .../docs/modules/ROOT/pages/android/android-release.adoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/docs/modules/ROOT/pages/android/android-release.adoc b/website/docs/modules/ROOT/pages/android/android-release.adoc index 95e2e45b32bf..3bf6671b9ff7 100644 --- a/website/docs/modules/ROOT/pages/android/android-release.adoc +++ b/website/docs/modules/ROOT/pages/android/android-release.adoc @@ -17,8 +17,8 @@ To sign your APK for release, you need to provide the keystore information. ---- def androidReleaseKeyName: Option[String] = Some("releaseKey.jks") def androidReleaseKeyAlias: T[Option[String]] = Task { Some("releaseKey") } -def androidReleaseKeyPass: T[Option[String]] = Task { Some("MillBuildTool") } -def androidReleaseKeyStorePass: T[Option[String]] = Task { Some("MillBuildTool") } +def androidReleaseKeyPass: T[Option[String]] = Task.Input { Task.env.get("KEY_PASS") } +def androidReleaseKeyStorePass: T[Option[String]] = Task.Input { Task.env.get("KEYSTORE_PASS") } ---- Make sure to replace the values with your actual keystore information. @@ -27,9 +27,9 @@ If you don't have a keystore yet, you can create one using the `keytool` command [,console] ---- > keytool -genkey -v -keystore releaseKey.jks \ - -storepass -keyalg RSA \ + -storepass $KEYSTORE_PASS -keyalg RSA \ -keysize 2048 -validity 10000 \ - -alias releaseKey -keypass + -alias releaseKey -keypass $KEY_PASS ---- == 3. (Optional) Enable ProGuard From abf609e589cb85322084cdf298c18aea99d7a46f Mon Sep 17 00:00:00 2001 From: Souvlakia Date: Fri, 17 Oct 2025 11:36:24 +0300 Subject: [PATCH 3/5] fix typo --- example/androidlib/kotlin/1-hello-kotlin/build.mill | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/androidlib/kotlin/1-hello-kotlin/build.mill b/example/androidlib/kotlin/1-hello-kotlin/build.mill index c23d50cbcc8a..fa1c543c6b10 100644 --- a/example/androidlib/kotlin/1-hello-kotlin/build.mill +++ b/example/androidlib/kotlin/1-hello-kotlin/build.mill @@ -52,7 +52,7 @@ object app extends AndroidAppKotlinModule { // TODO currently instrumented tests debug mode // is coupled with the app debug mode. Fix so // that instrumented tests can be built with debug - // configuration but the apk signature will match + // configuration but the apk signature will not match // the app apk override def androidIsDebug: T[Boolean] = Task { false From eef5583afc3c14987cdecd8afe43a6572034e966 Mon Sep 17 00:00:00 2001 From: Souvlakia Date: Fri, 17 Oct 2025 11:41:11 +0300 Subject: [PATCH 4/5] fix typo --- website/docs/modules/ROOT/nav.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/modules/ROOT/nav.adoc b/website/docs/modules/ROOT/nav.adoc index 2bec536f9171..ba4a8e84dca5 100644 --- a/website/docs/modules/ROOT/nav.adoc +++ b/website/docs/modules/ROOT/nav.adoc @@ -50,7 +50,7 @@ *** xref:pythonlib/linting.adoc[] *** xref:pythonlib/testing.adoc[] *** xref:pythonlib/publishing.adoc[] -*** xref:pythonlib/web-examples.adoc +*** xref:pythonlib/web-examples.adoc[] ** xref:javascriptlib/intro.adoc[] *** xref:javascriptlib/dependencies.adoc[] *** xref:javascriptlib/module-config.adoc[] From f16dbdae43881b2f0c1cdd955b67f7e7a773a760 Mon Sep 17 00:00:00 2001 From: Souvlakia Date: Fri, 17 Oct 2025 11:49:17 +0300 Subject: [PATCH 5/5] reference examples --- website/docs/modules/ROOT/pages/android/android-release.adoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/website/docs/modules/ROOT/pages/android/android-release.adoc b/website/docs/modules/ROOT/pages/android/android-release.adoc index 3bf6671b9ff7..9fc2e1994486 100644 --- a/website/docs/modules/ROOT/pages/android/android-release.adoc +++ b/website/docs/modules/ROOT/pages/android/android-release.adoc @@ -55,4 +55,9 @@ def androidDefaultProguardFileNames = Task.Anon { } ---- +== Some examples +The release configuration in the following Java and Kotlin examples can be used as a reference. + +- xref:android/java.adoc#_simple_android_hello_world_application[Java Example] +- xref:android/kotlin.adoc#_simple_android_hello_world_application[Kotlin Example]