diff --git a/website/docs/modules/ROOT/nav.adoc b/website/docs/modules/ROOT/nav.adoc index f45eb00f826..2bec536f917 100644 --- a/website/docs/modules/ROOT/nav.adoc +++ b/website/docs/modules/ROOT/nav.adoc @@ -36,6 +36,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 2c14c6057db..d75079960f3 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 00000000000..3bf6671b9ff --- /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.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. +If you don't have a keystore yet, you can create one using the `keytool` command: + +[,console] +---- +> keytool -genkey -v -keystore releaseKey.jks \ + -storepass $KEYSTORE_PASS -keyalg RSA \ + -keysize 2048 -validity 10000 \ + -alias releaseKey -keypass $KEY_PASS +---- + +== 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") +} +---- + +