From d39e2ec21e93d8289ee8ba9c5b3bd75b3bd32ab4 Mon Sep 17 00:00:00 2001 From: ardocrat Date: Sat, 14 Sep 2024 02:06:35 +0300 Subject: [PATCH] build: android signed release --- android/app/build.gradle | 30 +++++++++++++++++++----------- scripts/android.sh | 4 ++-- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 98a54b8..71d2129 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -2,10 +2,6 @@ plugins { id 'com.android.application' } -def keystorePropertiesFile = rootProject.file("keystore.properties") -def keystoreProperties = new Properties() -keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) - android { compileSdk 33 ndkVersion '26.0.10792818' @@ -18,20 +14,32 @@ android { versionName "0.1.3" } - signingConfigs { - release { - keyAlias keystoreProperties['keyAlias'] - keyPassword keystoreProperties['keyPassword'] - storeFile file(keystoreProperties['storeFile']) - storePassword keystoreProperties['storePassword'] + def keystorePropertiesFile = rootProject.file("keystore.properties") + def keystoreProperties = new Properties() + if (keystorePropertiesFile.exists()) { + keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) + + signingConfigs { + release { + keyAlias keystoreProperties['keyAlias'] + keyPassword keystoreProperties['keyPassword'] + storeFile file(keystoreProperties['storeFile']) + storePassword keystoreProperties['storePassword'] + } } + } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - signingConfig signingConfigs.release + } + if (keystorePropertiesFile.exists()) { + signedRelease { + initWith release + signingConfig signingConfigs.release + } } debug { minifyEnabled false diff --git a/scripts/android.sh b/scripts/android.sh index 519ce6c..d377e70 100755 --- a/scripts/android.sh +++ b/scripts/android.sh @@ -59,12 +59,12 @@ function build_apk() { cd android ./gradlew clean - ./gradlew assembleRelease + ./gradlew assembleSignedRelease # Setup release file name if [ -n $1 ]; then rm -rf grim-${version}-$1.apk - mv app/build/outputs/apk/release/app-release.apk grim-${version}-$1.apk + mv app/build/outputs/apk/signedRelease/app-signedRelease.apk grim-${version}-$1.apk fi cd ..