From 788d0d5cc5092c18ae33d8c1ddf411fa5bd4dd76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Tue, 28 Jul 2020 10:33:37 +0200 Subject: [PATCH] add ANDROID_APK_SIGNED to make unsigned builds for F-Droid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- Makefile | 1 + android/app/build.gradle | 8 +++++--- android/gradle.properties | 4 +++- nix/config.nix | 1 + nix/mobile/android/release.nix | 3 ++- scripts/release-android.sh | 1 + 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 1ab0269dc7..26f8b9a1b3 100644 --- a/Makefile +++ b/Makefile @@ -159,6 +159,7 @@ release-android: export BUILD_ENV ?= prod release-android: export BUILD_TYPE ?= nightly release-android: export BUILD_NUMBER ?= $(TMP_BUILD_NUMBER) release-android: export KEYSTORE_PATH ?= $(HOME)/.gradle/status-im.keystore +release-android: export ANDROID_APK_SIGNED ?= true release-android: export ANDROID_ABI_SPLIT ?= false release-android: export ANDROID_ABI_INCLUDE ?= armeabi-v7a;arm64-v8a;x86 release-android: keystore ##@build build release for Android diff --git a/android/app/build.gradle b/android/app/build.gradle index 814a6aa7cf..abeb15b211 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -228,6 +228,8 @@ android { keyAlias 'androiddebugkey' keyPassword 'android' } + /* Caution! In production, you need to generate your own keystore file. + * See: https://facebook.github.io/react-native/docs/signed-apk-android */ release { /* environment variables take precedence over gradle.properties file */ storeFile file(getEnvOrConfig('KEYSTORE_PATH').replaceAll("~", System.properties['user.home'])) @@ -253,11 +255,11 @@ android { resValue "string", "build_config_package", "im.status.ethereum" } release { - // Caution! In production, you need to generate your own keystore file. - // see https://facebook.github.io/react-native/docs/signed-apk-android. minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" - signingConfig signingConfigs.release + if (getEnvOrConfig('ANDROID_APK_SIGNED').toBoolean()) { + signingConfig signingConfigs.release + } } pr { initWith release diff --git a/android/gradle.properties b/android/gradle.properties index 5d9598cc6e..0be4dc61b0 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -42,10 +42,12 @@ KEYSTORE_KEY_PASSWORD=password ANDROID_ABI_SPLIT=false # Some platforms are excluded though ANDROID_ABI_INCLUDE=armeabi-v7a;arm64-v8a;x86 +# F-Droid builds need to be unsigned +ANDROID_APK_SIGNED=true org.gradle.jvmargs=-Xmx8704M versionCode=9999 # Flipper -FLIPPER_VERSION=0.35.0 \ No newline at end of file +FLIPPER_VERSION=0.35.0 diff --git a/nix/config.nix b/nix/config.nix index a17fa8b221..56c3a8f7d4 100644 --- a/nix/config.nix +++ b/nix/config.nix @@ -7,6 +7,7 @@ android = { gradle-opts = null; # Gradle options passed for Android builds keystore-path = null; # Path to keystore for signing the APK + apk-signed = true; # F-Droid builds aren't signed by us abi-split = false; # If APKs should be split based on architectures abi-include = "armeabi-v7a;arm64-v8a;x86"; # Android architectures to build for }; diff --git a/nix/mobile/android/release.nix b/nix/mobile/android/release.nix index 4e4349c116..97611579f3 100644 --- a/nix/mobile/android/release.nix +++ b/nix/mobile/android/release.nix @@ -28,7 +28,7 @@ let # If it is not we use an ad-hoc one generated with default password. keystorePath = getConfig "android.keystore-path" keystore; - baseName = "release-android"; + baseName = "${buildType}-android"; name = "status-react-build-${baseName}"; envFileName = @@ -72,6 +72,7 @@ in stdenv.mkDerivation rec { # custom env variables derived from config STATUS_GO_SRC_OVERRIDE = getConfig "nimbus.src-override" null; + ANDROID_APK_SIGNED = getConfig "android.apk-unsigned" "true"; ANDROID_ABI_SPLIT = getConfig "android.abi-split" "false"; ANDROID_ABI_INCLUDE = androidAbiInclude; diff --git a/scripts/release-android.sh b/scripts/release-android.sh index 28e747294b..863d4a4c07 100755 --- a/scripts/release-android.sh +++ b/scripts/release-android.sh @@ -33,6 +33,7 @@ fi config+="status-im.build-type=\"$(must_get_env BUILD_TYPE)\";" config+="status-im.build-number=\"$(must_get_env BUILD_NUMBER)\";" config+="status-im.android.keystore-path=\"$(must_get_env KEYSTORE_PATH)\";" +config+="status-im.android.apk-signed=\"$(must_get_env ANDROID_APK_SIGNED)\";" config+="status-im.android.abi-split=\"$(must_get_env ANDROID_ABI_SPLIT)\";" config+="status-im.android.abi-include=\"$(must_get_env ANDROID_ABI_INCLUDE)\";" nixOpts=()