Files
dioxus/packages/cli/assets/android/gen/app/build.gradle.kts.hbs
T
FontlosandJonathan Kelley 7d5bd44791 feat(cli): add bundle.android config to build and sign the apk file in release mode (#4062)
* feat(cli): add `bundle.android` config to build and sign the apk file in release mode

Add this to `Dioxus.toml`

```toml
[bundle.android]
jks_file = "path/to/jks file relative to Dioxus.toml"
jks_password = "jks_password "
key_alias = "key_alias"
key_password = "key_password "
```

When release flag is enabled and this configuration exists  at the same time, use `gradlew assembleRelease` build and sign apk file

* fix merge conflict

* only run assembleRelease when bundle exists

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
2025-05-07 14:22:59 -07:00

63 lines
1.8 KiB
Handlebars

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}
android {
namespace="{{ application_id }}"
compileSdk = 33
defaultConfig {
applicationId = "{{ application_id }}"
minSdk = 24
targetSdk = 33
versionCode = 1
versionName = "1.0"
}
{{#if android_bundle}}
signingConfigs {
create("release") {
storeFile = file("../../../../../../../{{ android_bundle.jks_file }}")
storePassword = "{{ android_bundle.jks_password }}"
keyAlias = "{{ android_bundle.key_alias }}"
keyPassword = "{{ android_bundle.key_password }}"
}
}
{{/if}}
buildTypes {
getByName("debug") {
isDebuggable = true
isJniDebuggable = true
isMinifyEnabled = false
packaging {
jniLibs.keepDebugSymbols.add("*/arm64-v8a/*.so")
jniLibs.keepDebugSymbols.add("*/armeabi-v7a/*.so")
jniLibs.keepDebugSymbols.add("*/x86/*.so")
jniLibs.keepDebugSymbols.add("*/x86_64/*.so")
}
}
getByName("release") {
isMinifyEnabled = true
{{#if android_bundle}}
signingConfig = signingConfigs.getByName("release")
{{/if}}
proguardFiles(
*fileTree(".") { include("**/*.pro") }
.plus(getDefaultProguardFile("proguard-android-optimize.txt"))
.toList().toTypedArray()
)
}
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
buildConfig = true
}
}
dependencies {
implementation("androidx.webkit:webkit:1.6.1")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.8.0")
}