From afccd48b608853addf8b63884ef31aa09492982c Mon Sep 17 00:00:00 2001 From: Frederik Feichtmeier Date: Sat, 14 Dec 2024 16:46:35 +0100 Subject: [PATCH] chore: add android signing (#1095) --- README.md | 9 +++++++++ android/app/build.gradle | 29 +++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ddd564883..acbfa0dd4 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,15 @@ https://hosted.weblate.org/projects/musicpod/app If you find any error please feel free to report it as an issue and describe it as good as you can. If you want to contribute code, please create an issue first. +## Build + +- for Linux desktop builds: `sudo apt install libmpv-dev mpv` +- [install rust](https://www.rust-lang.org/tools/install) (for some dependencies) +- [install flutter](https://docs.flutter.dev/get-started/install) +- required for android builds: [install android-studio](https://developer.android.com/studio) +- required for macos builds: [install xcode](https://developer.apple.com/xcode/) +- as a good IDE for all builds: [install vcode](https://code.visualstudio.com/) + ## Testing Test mocks are generated with [Mockito](https://github.com/dart-lang/mockito). You need to run the `build_runner` command in order to re-generate mocks, in case you changed the signatures of service methods. diff --git a/android/app/build.gradle b/android/app/build.gradle index 4d75d6cda..a0f638e41 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -5,6 +5,13 @@ plugins { id "dev.flutter.flutter-gradle-plugin" } +def keystoreProperties = new Properties() +def keystorePropertiesFile = rootProject.file('key.properties') +if (keystorePropertiesFile.exists()) { + keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) +} + + android { namespace = "org.feichtmeier.musicpod" compileSdk = flutter.compileSdkVersion @@ -20,21 +27,31 @@ android { } defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId = "org.feichtmeier.musicpod" - // You can update the following values to match your application needs. - // For more information, see: https://flutter.dev/to/review-gradle-config. minSdk = 23 targetSdk = flutter.targetSdkVersion versionCode = flutter.versionCode versionName = flutter.versionName } + signingConfigs { + release { + keyAlias = keystoreProperties['keyAlias'] + keyPassword = keystoreProperties['keyPassword'] + storeFile = keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null + storePassword = keystoreProperties['storePassword'] + } + } + buildTypes { release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig = signingConfigs.debug + if (keystorePropertiesFile.exists()) { + println "🗝 Keystore.properties found, loading config" + signingConfig = signingConfigs.release + } else { + println "⚠️ No Keystore.properties found, loading debug config" + signingConfig = signingConfigs.debug + } } } }