From 0876a3dc3585157633cbeeae3d83915b2504ced6 Mon Sep 17 00:00:00 2001 From: TheOneWithTheBraid Date: Tue, 28 Jun 2022 15:04:05 +0200 Subject: [PATCH] fix: F-Droid builds won't start Signed-off-by: TheOneWithTheBraid --- .gitlab-ci.yml | 14 +++++ android/app/build.gradle | 7 +++ android/app/proguard-rules.pro | 41 ++++++++++++ pubspec.yaml | 2 +- scripts/enable-android-google-services.patch | 65 +------------------- scripts/prepare-android-release.sh | 1 - 6 files changed, 66 insertions(+), 64 deletions(-) create mode 100644 android/app/proguard-rules.pro diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 46abae8e..b167ef8e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -108,6 +108,20 @@ build_android_debug: - tags build_android_apk: + stage: coverage + before_script: + - git apply ./scripts/enable-android-google-services.patch + - ./scripts/prepare-android-release.sh + script: [./scripts/build-android-apk.sh] + artifacts: + when: on_success + paths: + - build/android/app-release.apk + only: + - main + - tags + +build_android_apk_floss: stage: coverage before_script: [./scripts/prepare-android-release.sh] script: [./scripts/build-android-apk.sh] diff --git a/android/app/build.gradle b/android/app/build.gradle index 001fbd72..3a1f9293 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -68,6 +68,10 @@ android { } release { signingConfig signingConfigs.release + minifyEnabled false + shrinkResources false + + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } @@ -79,6 +83,9 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" //implementation 'com.google.firebase:firebase-messaging:19.0.1' // Workaround for https://github.com/microg/android_packages_apps_GmsCore/issues/313#issuecomment-617651698 + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' implementation 'androidx.multidex:multidex:2.0.1' } diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro new file mode 100644 index 00000000..40570865 --- /dev/null +++ b/android/app/proguard-rules.pro @@ -0,0 +1,41 @@ +-optimizationpasses 5 +## Flutter wrapper +-keep class io.flutter.app.** { *; } +-keep class io.flutter.plugin.** { *; } +-keep class io.flutter.util.** { *; } +-keep class io.flutter.view.** { *; } +-keep class io.flutter.** { *; } +-keep class io.flutter.plugins.** { *; } +-dontwarn io.flutter.embedding.** + +##---------------Begin: proguard configuration for Gson (Needed for flutter_local_notifications) ---------- +# Gson uses generic type information stored in a class file when working with fields. Proguard +# removes such information by default, so configure it to keep all of it. +-keepattributes Signature + +# For using GSON @Expose annotation +-keepattributes *Annotation* + +# Gson specific classes +-dontwarn sun.misc.** + +# Application classes that will be serialized/deserialized over Gson +-keep class com.google.gson.examples.android.model.** { ; } + +# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory, +# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter) +-keep class * extends com.google.gson.TypeAdapter +-keep class * implements com.google.gson.TypeAdapterFactory +-keep class * implements com.google.gson.JsonSerializer +-keep class * implements com.google.gson.JsonDeserializer + +# Prevent R8 from leaving Data object members always null +-keepclassmembers,allowobfuscation class * { + @com.google.gson.annotations.SerializedName ; +} + +# Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher. +-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken +-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken + +##---------------End: proguard configuration for Gson (Needed for flutter_local_notifications) ---------- \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 1672723d..9fda0344 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -25,7 +25,7 @@ dependencies: email_validator: ^2.0.1 emoji_picker_flutter: ^1.1.2 encrypt: ^5.0.1 - #fcm_shared_isolate: ^0.1.0 + fcm_shared_isolate: ^0.1.0 file_picker_cross: ^4.6.0 flutter: sdk: flutter diff --git a/scripts/enable-android-google-services.patch b/scripts/enable-android-google-services.patch index a190cbc3..16cb6fff 100644 --- a/scripts/enable-android-google-services.patch +++ b/scripts/enable-android-google-services.patch @@ -11,79 +11,20 @@ index 001fbd72..339b35af 100644 targetSdkVersion 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName -@@ -68,6 +68,10 @@ android { - } - release { - signingConfig signingConfigs.release -+ minifyEnabled false -+ shrinkResources false -+ -+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - } @@ -78,8 +82,11 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - //implementation 'com.google.firebase:firebase-messaging:19.0.1' // Workaround for https://github.com/microg/android_packages_apps_GmsCore/issues/313#issuecomment-617651698 + implementation 'com.google.firebase:firebase-messaging:19.0.1' // Workaround for https://github.com/microg/android_packages_apps_GmsCore/issues/313#issuecomment-617651698 -+ testImplementation 'junit:junit:4.12' -+ androidTestImplementation 'androidx.test:runner:1.1.1' -+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test:runner:1.1.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' implementation 'androidx.multidex:multidex:2.0.1' } -//apply plugin: 'com.google.gms.google-services' +apply plugin: 'com.google.gms.google-services' -diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro -new file mode 100644 -index 00000000..40570865 ---- /dev/null -+++ b/android/app/proguard-rules.pro -@@ -0,0 +1,41 @@ -+-optimizationpasses 5 -+## Flutter wrapper -+-keep class io.flutter.app.** { *; } -+-keep class io.flutter.plugin.** { *; } -+-keep class io.flutter.util.** { *; } -+-keep class io.flutter.view.** { *; } -+-keep class io.flutter.** { *; } -+-keep class io.flutter.plugins.** { *; } -+-dontwarn io.flutter.embedding.** -+ -+##---------------Begin: proguard configuration for Gson (Needed for flutter_local_notifications) ---------- -+# Gson uses generic type information stored in a class file when working with fields. Proguard -+# removes such information by default, so configure it to keep all of it. -+-keepattributes Signature -+ -+# For using GSON @Expose annotation -+-keepattributes *Annotation* -+ -+# Gson specific classes -+-dontwarn sun.misc.** -+ -+# Application classes that will be serialized/deserialized over Gson -+-keep class com.google.gson.examples.android.model.** { ; } -+ -+# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory, -+# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter) -+-keep class * extends com.google.gson.TypeAdapter -+-keep class * implements com.google.gson.TypeAdapterFactory -+-keep class * implements com.google.gson.JsonSerializer -+-keep class * implements com.google.gson.JsonDeserializer -+ -+# Prevent R8 from leaving Data object members always null -+-keepclassmembers,allowobfuscation class * { -+ @com.google.gson.annotations.SerializedName ; -+} -+ -+# Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher. -+-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken -+-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken -+ -+##---------------End: proguard configuration for Gson (Needed for flutter_local_notifications) ---------- -\ No newline at end of file diff --git a/android/app/src/main/kotlin/chat/fluffy/fluffychat/FcmPushService.kt b/android/app/src/main/kotlin/chat/fluffy/fluffychat/FcmPushService.kt index d9930f55..510e9845 100644 --- a/android/app/src/main/kotlin/chat/fluffy/fluffychat/FcmPushService.kt diff --git a/scripts/prepare-android-release.sh b/scripts/prepare-android-release.sh index 8204f7ca..a2a11dcb 100755 --- a/scripts/prepare-android-release.sh +++ b/scripts/prepare-android-release.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -git apply ./scripts/enable-android-google-services.patch cd android echo $FDROID_KEY | base64 --decode --ignore-garbage > key.jks echo "storePassword=${FDROID_KEY_PASS}" >> key.properties