Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions website/docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <PASS> -keyalg RSA \
-keysize 2048 -validity 10000 \
-alias releaseKey -keypass <PASS>
----

image::android/AndroidStudio.png[AndroidStudio.png]
58 changes: 58 additions & 0 deletions website/docs/modules/ROOT/pages/android/android-release.adoc
Original file line number Diff line number Diff line change
@@ -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 /<sdk_path>/tools/proguard/proguard*.txt
def androidDefaultProguardFileNames = Task.Anon {
Seq("proguard-android-optimize.txt")
}
----