From a95c96ed722646645484f19802c9ebbdfa1ca68d Mon Sep 17 00:00:00 2001 From: Ahmed El-Helw Date: Thu, 17 Oct 2024 12:04:19 +0300 Subject: [PATCH] Fix proguard/r8 rules for Android Libraries that require proguard rules should publish them automatically to r8 by using consumerProguardFiles. Currently, Ferrostar declared this, but left the corresponding rules files empty. This patch moves the rules from proguard-rules.pro so that R8 automatically picks them up without apps using Ferrostar needing to do anything. Moreover, it removes proguard-rules.pro and the corresponding release block from Android libraries, since whether the build type is release or debug (and whether or not r8 is enabled) is dependant on the app module. --- android/composeui/build.gradle | 6 ---- android/composeui/proguard-rules.pro | 21 ------------- android/core/build.gradle | 6 ---- android/core/consumer-rules.pro | 8 +++++ android/core/proguard-rules.pro | 30 ------------------- android/google-play-services/build.gradle | 6 ---- .../google-play-services/proguard-rules.pro | 21 ------------- android/maplibreui/build.gradle | 6 ---- android/maplibreui/proguard-rules.pro | 21 ------------- 9 files changed, 8 insertions(+), 117 deletions(-) delete mode 100644 android/composeui/proguard-rules.pro delete mode 100644 android/core/proguard-rules.pro delete mode 100644 android/google-play-services/proguard-rules.pro delete mode 100644 android/maplibreui/proguard-rules.pro diff --git a/android/composeui/build.gradle b/android/composeui/build.gradle index fb371e33..06941ed3 100644 --- a/android/composeui/build.gradle +++ b/android/composeui/build.gradle @@ -21,12 +21,6 @@ android { consumerProguardFiles "consumer-rules.pro" } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } compileOptions { coreLibraryDesugaringEnabled true sourceCompatibility JavaVersion.VERSION_1_8 diff --git a/android/composeui/proguard-rules.pro b/android/composeui/proguard-rules.pro deleted file mode 100644 index 481bb434..00000000 --- a/android/composeui/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/android/core/build.gradle b/android/core/build.gradle index cbc1e228..51771902 100644 --- a/android/core/build.gradle +++ b/android/core/build.gradle @@ -23,12 +23,6 @@ android { consumerProguardFiles "consumer-rules.pro" } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } compileOptions { coreLibraryDesugaringEnabled true sourceCompatibility JavaVersion.VERSION_1_8 diff --git a/android/core/consumer-rules.pro b/android/core/consumer-rules.pro index e69de29b..a6fc9749 100644 --- a/android/core/consumer-rules.pro +++ b/android/core/consumer-rules.pro @@ -0,0 +1,8 @@ +# Ferrostar & JNA +# TODO: This needs validation from a publishing app. Ticket https://github.com/stadiamaps/ferrostar/issues/185 +-keep class com.sun.jna.** { *; } +-keep class uniffi.ferrostar.** { *; } +-dontwarn java.awt.Component +-dontwarn java.awt.GraphicsEnvironment +-dontwarn java.awt.HeadlessException +-dontwarn java.awt.Window \ No newline at end of file diff --git a/android/core/proguard-rules.pro b/android/core/proguard-rules.pro deleted file mode 100644 index a431dfa7..00000000 --- a/android/core/proguard-rules.pro +++ /dev/null @@ -1,30 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile - -# Ferrostar & JNA -# TODO: This needs validation from a publishing app. Ticket https://github.com/stadiamaps/ferrostar/issues/185 --keep class com.sun.jna.** { *; } --keep class uniffi.ferrostar.** { *; } --dontwarn java.awt.Component --dontwarn java.awt.GraphicsEnvironment --dontwarn java.awt.HeadlessException --dontwarn java.awt.Window \ No newline at end of file diff --git a/android/google-play-services/build.gradle b/android/google-play-services/build.gradle index ca7501c9..5ef53a92 100644 --- a/android/google-play-services/build.gradle +++ b/android/google-play-services/build.gradle @@ -19,12 +19,6 @@ android { consumerProguardFiles "consumer-rules.pro" } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } compileOptions { coreLibraryDesugaringEnabled true sourceCompatibility JavaVersion.VERSION_1_8 diff --git a/android/google-play-services/proguard-rules.pro b/android/google-play-services/proguard-rules.pro deleted file mode 100644 index 481bb434..00000000 --- a/android/google-play-services/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/android/maplibreui/build.gradle b/android/maplibreui/build.gradle index b4ec2717..6e9b7534 100644 --- a/android/maplibreui/build.gradle +++ b/android/maplibreui/build.gradle @@ -21,12 +21,6 @@ android { consumerProguardFiles "consumer-rules.pro" } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } compileOptions { coreLibraryDesugaringEnabled true sourceCompatibility JavaVersion.VERSION_1_8 diff --git a/android/maplibreui/proguard-rules.pro b/android/maplibreui/proguard-rules.pro deleted file mode 100644 index 481bb434..00000000 --- a/android/maplibreui/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file