From a10f76637295629c9b17659fb3e66af606ca08b3 Mon Sep 17 00:00:00 2001 From: Masashi Katsumata Date: Sun, 7 Sep 2025 01:11:27 +0900 Subject: [PATCH] Apply Proguard --- example-app/build.gradle.kts | 133 +++++++++++++++++- example-app/proguard-rules.pro | 86 ++++++++--- gradle.properties | 8 +- mapconductor-core/build.gradle.kts | 14 +- mapconductor-core/consumer-rules.pro | 3 + mapconductor-core/proguard-rules.pro | 61 +++++--- mapconductor-for-arcgis/build.gradle.kts | 14 +- mapconductor-for-arcgis/proguard-rules.pro | 43 +++--- mapconductor-for-googlemaps/build.gradle.kts | 14 +- .../proguard-rules.pro | 54 ++++--- mapconductor-for-here/build.gradle.kts | 14 +- mapconductor-for-here/proguard-rules.pro | 43 +++--- mapconductor-for-mapbox/build.gradle.kts | 14 +- mapconductor-for-mapbox/proguard-rules.pro | 54 ++++--- mapconductor-icons/build.gradle.kts | 14 +- mapconductor-icons/proguard-rules.pro | 33 ++--- 16 files changed, 442 insertions(+), 160 deletions(-) create mode 100644 mapconductor-core/consumer-rules.pro diff --git a/example-app/build.gradle.kts b/example-app/build.gradle.kts index bb1ea10c..b8d62080 100644 --- a/example-app/build.gradle.kts +++ b/example-app/build.gradle.kts @@ -1,120 +1,249 @@ -plugins { +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.compose) + id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin") + id("org.jlleitschuh.gradle.ktlint") } ktlint { + android.set(true) + reporters { + reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType.PLAIN) + reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType.CHECKSTYLE) } } android { + namespace = "com.mapconductor.example" + compileSdk = project.property("compileSdk").toString().toInt() defaultConfig { + applicationId = "com.mapconductor.example" + minSdk = project.property("minSdk").toString().toInt() + targetSdk = project.property("targetSdk").toString().toInt() + ndk { abiFilters += listOf("arm64-v8a") } + vectorDrawables { + useSupportLibrary = true + } + versionCode = 1 + versionName = "1.0" + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } composeOptions { + kotlinCompilerExtensionVersion = + project.property("kotlinCompilerExtensionVersion").toString() } buildTypes { + + debug { + + isMinifyEnabled = false + + proguardFiles( + getDefaultProguardFile("proguard-android.txt"), + "proguard-rules.pro", + ) + } + release { - isMinifyEnabled = project.property("isMinifyEnabled").toString().toBoolean() + + isMinifyEnabled = true + + isShrinkResources = true + proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", ) + + // Force legacy ProGuard instead of R8 + + buildConfigField("String", "BUILD_CONFIG_VERSION", "\"release\"") + signingConfig = signingConfigs.getByName("debug") } } + + packaging { + + resources { + + excludes += "META-INF/versions/9/previous-compilation-data.bin" + excludes += "META-INF/*.kotlin_module" + excludes += "META-INF/AL2.0" + excludes += "META-INF/LGPL2.1" + excludes += "META-INF/androidx.*.version" + excludes += "**/*.proto" + } + + jniLibs { + useLegacyPackaging = true + } + } + compileOptions { + sourceCompatibility = JavaVersion.toVersion(project.property("javaVersion").toString()) + targetCompatibility = JavaVersion.toVersion(project.property("javaVersion").toString()) } + kotlinOptions { + jvmTarget = project.property("jvmTarget").toString() } + buildFeatures { + compose = true + + buildConfig = true } + + bundle { + language { + enableSplit = true + } + density { + enableSplit = true + } + abi { + enableSplit = true + } + } + testOptions { + unitTests { + isIncludeAndroidResources = true } } } + secrets { + // To add your Maps API key to this project: + // 1. If the secrets.properties file does not exist, create it in the same folder as the local.properties file. + // 2. Add this line, where YOUR_API_KEY is your API key: + // MAPS_API_KEY=YOUR_API_KEY + propertiesFileName = "secrets.properties" // A properties file containing default secret values. This file can be + // checked in version control. + defaultPropertiesFileName = "local.defaults.properties" } dependencies { implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.activity.compose) + implementation(libs.androidx.lifecycle.viewmodel.compose) + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.ui) + implementation(libs.androidx.ui.graphics) + implementation(libs.androidx.ui.tooling.preview) + implementation(libs.androidx.material3) + implementation(libs.androidx.appcompat) + implementation(platform(libs.firebase.bom)) // Google Maps SDK + implementation(libs.play.services.maps) + // Here Maps SDK + val hereSdkAarName: String by project + implementation(files("${rootProject.projectDir}/libs/$hereSdkAarName.aar")) + // Mapbox SDK + implementation(libs.mapbox.android) // ArcGIS Maps for Kotlin - SDK dependency + implementation(libs.arcgis.maps.kotlin) + implementation(platform(libs.arcgis.maps.kotlin.toolkit.bom)) + implementation(libs.arcgis.maps.kotlin.toolkit.geoview.compose) + implementation(libs.arcgis.maps.kotlin.toolkit.authentication) // Map Conductor + implementation(project(":mapconductor-core")) + implementation(project(":mapconductor-icons")) + implementation(project(":mapconductor-for-googlemaps")) + implementation(project(":mapconductor-for-here")) + implementation(project(":mapconductor-for-mapbox")) + implementation(project(":mapconductor-for-arcgis")) + implementation(libs.androidx.vectordrawable) + implementation(libs.androidx.room.runtime.android) testImplementation(libs.junit) + testImplementation(libs.androidx.core) + testImplementation(libs.androidx.junit) + testImplementation(libs.androidx.runner) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.androidx.espresso.core) + androidTestImplementation(platform(libs.androidx.compose.bom)) + androidTestImplementation(libs.androidx.ui.test.junit4) + debugImplementation(libs.androidx.ui.tooling) + debugImplementation(libs.androidx.ui.test.manifest) } diff --git a/example-app/proguard-rules.pro b/example-app/proguard-rules.pro index 481bb434..6af4d2f5 100644 --- a/example-app/proguard-rules.pro +++ b/example-app/proguard-rules.pro @@ -1,21 +1,65 @@ -# 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 +# MapConductor Example App ProGuard Rules + +# Keep line number information for debugging stack traces +-keepattributes SourceFile,LineNumberTable + +# Optimization settings +-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/* +-optimizationpasses 5 +-allowaccessmodification +-dontpreverify + +# Obfuscation settings (remove -dontobfuscate for better compression) +-repackageclasses '' +-allowaccessmodification + +# Keep essential Android classes +-keep public class * extends android.app.Activity +-keep public class * extends android.app.Application +-keep public class * extends android.app.Service +-keep public class * extends android.content.BroadcastReceiver +-keep public class * extends android.content.ContentProvider + +# Keep Compose essentials only +-keep class androidx.compose.runtime.Composable +-keep class * extends androidx.activity.ComponentActivity { + public (...); +} + +# Keep ViewModel constructors +-keep class * extends androidx.lifecycle.ViewModel { + (...); +} + +# Keep only essential MapConductor classes +-keep class com.mapconductor.example.MainActivity { *; } +-keep class com.mapconductor.example.MapConductorExampleApplication { *; } + +# Keep data classes used in UI +-keepclassmembers class com.mapconductor.example.pages.stores.DemoData { + ; + ; +} + +# Keep Parcelable implementations +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} + +# Keep serialization +-keepattributes Signature +-keepclassmembers class * implements java.io.Serializable { + static final long serialVersionUID; + private static final java.io.ObjectStreamField[] serialPersistentFields; + private void writeObject(java.io.ObjectOutputStream); + private void readObject(java.io.ObjectInputStream); + java.lang.Object writeReplace(); + java.lang.Object readResolve(); +} + +# Remove logging in release builds +-assumenosideeffects class android.util.Log { + public static *** d(...); + public static *** v(...); + public static *** i(...); +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 2a998503..cd1e2b3a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -# Project-wide Gradle settings. +# Project-wide Gradle settings. # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. @@ -32,4 +32,8 @@ versionCode=1 versionName=1.0.0 javaVersion=11 jvmTarget=11 -isMinifyEnabled=false +isMinifyEnabled=true +# R8 settings for handling duplicate classes +android.enableR8.fullMode=true +android.r8.ignoreAllowListBinaryFiles=true +android.enableJetifier=true diff --git a/mapconductor-core/build.gradle.kts b/mapconductor-core/build.gradle.kts index 08b32848..209a62c7 100644 --- a/mapconductor-core/build.gradle.kts +++ b/mapconductor-core/build.gradle.kts @@ -1,4 +1,4 @@ -plugins { +plugins { id("com.android.library") id("org.jetbrains.kotlin.android") id("maven-publish") @@ -21,6 +21,7 @@ android { defaultConfig { minSdk = project.property("minSdk").toString().toInt() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") } buildFeatures { @@ -32,10 +33,17 @@ android { } buildTypes { + debug { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android.txt"), + "proguard-rules.pro", + ) + } release { - isMinifyEnabled = project.property("isMinifyEnabled").toString().toBoolean() + isMinifyEnabled = false proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), + getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro", ) } diff --git a/mapconductor-core/consumer-rules.pro b/mapconductor-core/consumer-rules.pro new file mode 100644 index 00000000..30027fe3 --- /dev/null +++ b/mapconductor-core/consumer-rules.pro @@ -0,0 +1,3 @@ +# Keep Settings and its nested classes for consumers +-keep class com.mapconductor.settings.Settings { *; } +-keep class com.mapconductor.settings.Settings$* { *; } \ No newline at end of file diff --git a/mapconductor-core/proguard-rules.pro b/mapconductor-core/proguard-rules.pro index 481bb434..62bc5a3e 100644 --- a/mapconductor-core/proguard-rules.pro +++ b/mapconductor-core/proguard-rules.pro @@ -1,21 +1,40 @@ -# 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 +# MapConductor Core ProGuard Rules + +# Keep line number information for debugging +-keepattributes SourceFile,LineNumberTable + +# Keep all public API classes and interfaces +-keep public class com.mapconductor.core.** { public *; } + +# Keep all controller interfaces and their implementations +-keep interface com.mapconductor.core.controller.** { *; } +-keep class * implements com.mapconductor.core.controller.** { *; } + +# Keep all marker, circle, polyline, and overlay classes +-keep class com.mapconductor.core.marker.** { *; } +-keep class com.mapconductor.core.circle.** { *; } +-keep class com.mapconductor.core.polyline.** { *; } +-keep class com.mapconductor.core.polygon.** { *; } +-keep class com.mapconductor.core.groundimage.** { *; } + +# Keep projection and geocell utilities +-keep class com.mapconductor.core.projection.** { *; } +-keep class com.mapconductor.core.geocell.** { *; } +-keep class com.mapconductor.core.spherical.** { *; } + +# Keep map view components +-keep class com.mapconductor.core.map.** { *; } + +# Keep features and state classes +-keep class com.mapconductor.core.features.** { *; } +-keep class com.mapconductor.core.state.** { *; } + +# Keep Compose-related classes +-keep class * extends androidx.compose.runtime.** { *; } + +# Keep Kotlin coroutines +-keep class kotlinx.coroutines.** { *; } + +# Fix for Java 11+ StringConcatFactory issue +-dontwarn java.lang.invoke.StringConcatFactory +-keep class java.lang.invoke.StringConcatFactory { *; } \ No newline at end of file diff --git a/mapconductor-for-arcgis/build.gradle.kts b/mapconductor-for-arcgis/build.gradle.kts index 6d3004ba..670c4a02 100644 --- a/mapconductor-for-arcgis/build.gradle.kts +++ b/mapconductor-for-arcgis/build.gradle.kts @@ -1,4 +1,4 @@ -plugins { +plugins { id("com.android.library") id("org.jetbrains.kotlin.android") id("maven-publish") @@ -22,6 +22,7 @@ android { minSdk = project.property("minSdk").toString().toInt() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") } buildFeatures { @@ -34,10 +35,17 @@ android { } buildTypes { + debug { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android.txt"), + "proguard-rules.pro", + ) + } release { - isMinifyEnabled = project.property("isMinifyEnabled").toString().toBoolean() + isMinifyEnabled = false proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), + getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro", ) } diff --git a/mapconductor-for-arcgis/proguard-rules.pro b/mapconductor-for-arcgis/proguard-rules.pro index 481bb434..0d1b5d58 100644 --- a/mapconductor-for-arcgis/proguard-rules.pro +++ b/mapconductor-for-arcgis/proguard-rules.pro @@ -1,21 +1,28 @@ -# 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 +# MapConductor ArcGIS ProGuard Rules -# 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 *; -#} +# Keep line number information for debugging +-keepattributes SourceFile,LineNumberTable -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable +# Keep all public API classes +-keep public class com.mapconductor.arcgis.** { public *; } -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +# Keep ArcGIS specific implementations +-keep class com.mapconductor.arcgis.ArcGISMapViewController { *; } +-keep class com.mapconductor.arcgis.ArcGISMapViewControllerImpl { *; } +-keep class com.mapconductor.arcgis.ArcGISMapView { *; } + +# Keep marker, circle, polyline implementations +-keep class com.mapconductor.arcgis.marker.** { *; } +-keep class com.mapconductor.arcgis.circle.** { *; } +-keep class com.mapconductor.arcgis.polyline.** { *; } +-keep class com.mapconductor.arcgis.polygon.** { *; } + +# Keep ArcGIS SDK classes +-keep class com.esri.arcgisruntime.** { *; } + +# Compose integration +-keep class * extends androidx.compose.runtime.** { *; } + +# Fix for Java 11+ StringConcatFactory issue +-dontwarn java.lang.invoke.StringConcatFactory +-keep class java.lang.invoke.StringConcatFactory { *; } \ No newline at end of file diff --git a/mapconductor-for-googlemaps/build.gradle.kts b/mapconductor-for-googlemaps/build.gradle.kts index 18649ef4..221719bc 100644 --- a/mapconductor-for-googlemaps/build.gradle.kts +++ b/mapconductor-for-googlemaps/build.gradle.kts @@ -1,4 +1,4 @@ -plugins { +plugins { id("com.android.library") id("org.jetbrains.kotlin.android") id("maven-publish") @@ -22,6 +22,7 @@ android { minSdk = project.property("minSdk").toString().toInt() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") } buildFeatures { @@ -34,10 +35,17 @@ android { } buildTypes { + debug { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android.txt"), + "proguard-rules.pro", + ) + } release { - isMinifyEnabled = project.property("isMinifyEnabled").toString().toBoolean() + isMinifyEnabled = false proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), + getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro", ) } diff --git a/mapconductor-for-googlemaps/proguard-rules.pro b/mapconductor-for-googlemaps/proguard-rules.pro index 481bb434..ecd83028 100644 --- a/mapconductor-for-googlemaps/proguard-rules.pro +++ b/mapconductor-for-googlemaps/proguard-rules.pro @@ -1,21 +1,33 @@ -# 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 +# MapConductor Google Maps ProGuard Rules + +# Keep line number information for debugging +-keepattributes SourceFile,LineNumberTable + +# Keep all public API classes +-keep public class com.mapconductor.googlemaps.** { public *; } + +# Keep Google Maps specific implementations +-keep class com.mapconductor.googlemaps.GoogleMapViewController { *; } +-keep class com.mapconductor.googlemaps.GoogleMapViewControllerImpl { *; } +-keep class com.mapconductor.googlemaps.GoogleMapView { *; } + +# Keep marker, circle, polyline implementations +-keep class com.mapconductor.googlemaps.marker.** { *; } +-keep class com.mapconductor.googlemaps.circle.** { *; } +-keep class com.mapconductor.googlemaps.polyline.** { *; } +-keep class com.mapconductor.googlemaps.polygon.** { *; } +-keep class com.mapconductor.googlemaps.groundimage.** { *; } + +# Keep Google Maps SDK classes +-keep class com.google.android.gms.maps.** { *; } +-keep class com.google.maps.android.** { *; } + +# Keep Google Maps model classes +-keep class com.google.android.gms.maps.model.** { *; } + +# Compose integration +-keep class * extends androidx.compose.runtime.** { *; } + +# Fix for Java 11+ StringConcatFactory issue +-dontwarn java.lang.invoke.StringConcatFactory +-keep class java.lang.invoke.StringConcatFactory { *; } \ No newline at end of file diff --git a/mapconductor-for-here/build.gradle.kts b/mapconductor-for-here/build.gradle.kts index 1eddb4b4..6c88c4bd 100644 --- a/mapconductor-for-here/build.gradle.kts +++ b/mapconductor-for-here/build.gradle.kts @@ -1,4 +1,4 @@ -plugins { +plugins { id("com.android.library") id("org.jetbrains.kotlin.android") id("maven-publish") @@ -22,6 +22,7 @@ android { minSdk = project.property("minSdk").toString().toInt() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") } buildFeatures { @@ -34,10 +35,17 @@ android { } buildTypes { + debug { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android.txt"), + "proguard-rules.pro", + ) + } release { - isMinifyEnabled = project.property("isMinifyEnabled").toString().toBoolean() + isMinifyEnabled = false proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), + getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro", ) } diff --git a/mapconductor-for-here/proguard-rules.pro b/mapconductor-for-here/proguard-rules.pro index 481bb434..8621d348 100644 --- a/mapconductor-for-here/proguard-rules.pro +++ b/mapconductor-for-here/proguard-rules.pro @@ -1,21 +1,28 @@ -# 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 +# MapConductor HERE Maps ProGuard Rules -# 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 *; -#} +# Keep line number information for debugging +-keepattributes SourceFile,LineNumberTable -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable +# Keep all public API classes +-keep public class com.mapconductor.here.** { public *; } -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +# Keep HERE Maps specific implementations +-keep class com.mapconductor.here.HereMapViewController { *; } +-keep class com.mapconductor.here.HereMapViewControllerImpl { *; } +-keep class com.mapconductor.here.HereMapView { *; } + +# Keep marker, circle, polyline implementations +-keep class com.mapconductor.here.marker.** { *; } +-keep class com.mapconductor.here.circle.** { *; } +-keep class com.mapconductor.here.polyline.** { *; } +-keep class com.mapconductor.here.polygon.** { *; } + +# Keep HERE SDK classes +-keep class com.here.sdk.** { *; } + +# Compose integration +-keep class * extends androidx.compose.runtime.** { *; } + +# Fix for Java 11+ StringConcatFactory issue +-dontwarn java.lang.invoke.StringConcatFactory +-keep class java.lang.invoke.StringConcatFactory { *; } \ No newline at end of file diff --git a/mapconductor-for-mapbox/build.gradle.kts b/mapconductor-for-mapbox/build.gradle.kts index bb431e33..ebcca1d2 100644 --- a/mapconductor-for-mapbox/build.gradle.kts +++ b/mapconductor-for-mapbox/build.gradle.kts @@ -1,4 +1,4 @@ -plugins { +plugins { id("com.android.library") id("org.jetbrains.kotlin.android") id("maven-publish") @@ -22,6 +22,7 @@ android { minSdk = project.property("minSdk").toString().toInt() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") } buildFeatures { @@ -33,10 +34,17 @@ android { } buildTypes { + debug { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android.txt"), + "proguard-rules.pro", + ) + } release { - isMinifyEnabled = project.property("isMinifyEnabled").toString().toBoolean() + isMinifyEnabled = false proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), + getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro", ) } diff --git a/mapconductor-for-mapbox/proguard-rules.pro b/mapconductor-for-mapbox/proguard-rules.pro index 481bb434..2d335693 100644 --- a/mapconductor-for-mapbox/proguard-rules.pro +++ b/mapconductor-for-mapbox/proguard-rules.pro @@ -1,21 +1,33 @@ -# 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 +# MapConductor Mapbox ProGuard Rules + +# Keep line number information for debugging +-keepattributes SourceFile,LineNumberTable + +# Keep all public API classes +-keep public class com.mapconductor.mapbox.** { public *; } + +# Keep Mapbox specific implementations +-keep class com.mapconductor.mapbox.MapboxMapViewController { *; } +-keep class com.mapconductor.mapbox.MapboxMapViewControllerImpl { *; } +-keep class com.mapconductor.mapbox.MapboxMapView { *; } + +# Keep marker, circle, polyline implementations +-keep class com.mapconductor.mapbox.marker.** { *; } +-keep class com.mapconductor.mapbox.circle.** { *; } +-keep class com.mapconductor.mapbox.polyline.** { *; } +-keep class com.mapconductor.mapbox.polygon.** { *; } + +# Keep Mapbox SDK classes +-keep class com.mapbox.maps.** { *; } +-keep class com.mapbox.geojson.** { *; } +-keep class com.mapbox.android.** { *; } + +# Keep Mapbox style classes +-keep class com.mapbox.maps.extension.style.** { *; } + +# Compose integration +-keep class * extends androidx.compose.runtime.** { *; } + +# Fix for Java 11+ StringConcatFactory issue +-dontwarn java.lang.invoke.StringConcatFactory +-keep class java.lang.invoke.StringConcatFactory { *; } \ No newline at end of file diff --git a/mapconductor-icons/build.gradle.kts b/mapconductor-icons/build.gradle.kts index 32d761c8..9278dfa8 100644 --- a/mapconductor-icons/build.gradle.kts +++ b/mapconductor-icons/build.gradle.kts @@ -1,4 +1,4 @@ -plugins { +plugins { id("com.android.library") id("org.jetbrains.kotlin.android") id("maven-publish") @@ -22,6 +22,7 @@ android { minSdk = project.property("minSdk").toString().toInt() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") } buildFeatures { @@ -34,10 +35,17 @@ android { } buildTypes { + debug { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android.txt"), + "proguard-rules.pro", + ) + } release { - isMinifyEnabled = project.property("isMinifyEnabled").toString().toBoolean() + isMinifyEnabled = false proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), + getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro", ) } diff --git a/mapconductor-icons/proguard-rules.pro b/mapconductor-icons/proguard-rules.pro index 481bb434..3d5c1784 100644 --- a/mapconductor-icons/proguard-rules.pro +++ b/mapconductor-icons/proguard-rules.pro @@ -1,21 +1,18 @@ -# 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 +# MapConductor Icons ProGuard Rules -# 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 *; -#} +# Keep line number information for debugging +-keepattributes SourceFile,LineNumberTable -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable +# Keep all public icon classes +-keep public class com.mapconductor.icons.** { public *; } -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +# Keep all icon implementations +-keep class com.mapconductor.icons.CircleIcon { *; } +-keep class com.mapconductor.icons.FlagIcon { *; } + +# Compose integration +-keep class * extends androidx.compose.runtime.** { *; } + +# Fix for Java 11+ StringConcatFactory issue +-dontwarn java.lang.invoke.StringConcatFactory +-keep class java.lang.invoke.StringConcatFactory { *; } \ No newline at end of file