From ef0dd331ad017402155b33969625da3423ece5d7 Mon Sep 17 00:00:00 2001 From: melad Date: Thu, 26 Sep 2024 14:40:36 +0300 Subject: [PATCH 1/3] use the correct "Keep" class reference --- .../simprints/infra/images/metadata/database/DbImageMetadata.kt | 2 +- .../infra/images/metadata/database/ImageMetadataDatabase.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/infra/images/src/main/java/com/simprints/infra/images/metadata/database/DbImageMetadata.kt b/infra/images/src/main/java/com/simprints/infra/images/metadata/database/DbImageMetadata.kt index 81e2b3ff8c..2eb6e53a0e 100644 --- a/infra/images/src/main/java/com/simprints/infra/images/metadata/database/DbImageMetadata.kt +++ b/infra/images/src/main/java/com/simprints/infra/images/metadata/database/DbImageMetadata.kt @@ -1,7 +1,7 @@ package com.simprints.infra.images.metadata.database +import androidx.annotation.Keep import androidx.room.Entity -import com.google.errorprone.annotations.Keep @Entity( tableName = "DbImageMetadata", diff --git a/infra/images/src/main/java/com/simprints/infra/images/metadata/database/ImageMetadataDatabase.kt b/infra/images/src/main/java/com/simprints/infra/images/metadata/database/ImageMetadataDatabase.kt index 39c9340574..d6c34f5983 100644 --- a/infra/images/src/main/java/com/simprints/infra/images/metadata/database/ImageMetadataDatabase.kt +++ b/infra/images/src/main/java/com/simprints/infra/images/metadata/database/ImageMetadataDatabase.kt @@ -1,10 +1,10 @@ package com.simprints.infra.images.metadata.database import android.content.Context +import androidx.annotation.Keep import androidx.room.Database import androidx.room.Room import androidx.room.RoomDatabase -import com.google.errorprone.annotations.Keep @Database( entities = [DbImageMetadata::class], From 6d7a34b1daa03e790077105568a8b622f41bab44 Mon Sep 17 00:00:00 2001 From: melad Date: Thu, 26 Sep 2024 14:41:06 +0300 Subject: [PATCH 2/3] rename ConfigManagerModule to ConfigStoreModule --- .../com/simprints/infra/config/store/ConfigStoreModule.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infra/config-store/src/main/java/com/simprints/infra/config/store/ConfigStoreModule.kt b/infra/config-store/src/main/java/com/simprints/infra/config/store/ConfigStoreModule.kt index f5ab71096f..a14ddc02e3 100644 --- a/infra/config-store/src/main/java/com/simprints/infra/config/store/ConfigStoreModule.kt +++ b/infra/config-store/src/main/java/com/simprints/infra/config/store/ConfigStoreModule.kt @@ -35,11 +35,11 @@ private const val DEVICE_CONFIG_DATA_STORE_FILE_NAME = "device_config_prefs.pb" @Module @InstallIn(SingletonComponent::class) -abstract class ConfigManagerModule { +abstract class ConfigStoreModule { @Binds - internal abstract fun provideconfigService(service: ConfigRepositoryImpl): ConfigRepository + internal abstract fun provideConfigRepository(service: ConfigRepositoryImpl): ConfigRepository @Binds internal abstract fun provideConfigRemoteDataSource(remoteDataSource: ConfigRemoteDataSourceImpl): ConfigRemoteDataSource From 17c39cb4c00e7e298343186b1c364b2f76e2dda6 Mon Sep 17 00:00:00 2001 From: melad Date: Fri, 27 Sep 2024 21:39:11 +0300 Subject: [PATCH 3/3] [MS-742] Use a single ProGuard Rules File --- .../kotlin/AndroidLibraryConventionPlugin.kt | 32 ++++++++----------- build-logic/proguard-rules.pro | 25 --------------- fingerprint/infra/scanner/build.gradle.kts | 3 -- fingerprint/infra/scanner/consumer-rules.pro | 22 ------------- .../infra/simafis-wrapper/build.gradle.kts | 4 --- .../infra/simafis-wrapper/consumer-rules.pro | 20 ------------ id/proguard-rules.pro | 26 ++++----------- infra/config-store/build.gradle.kts | 3 -- infra/config-store/consumer-rules.pro | 4 --- infra/config-sync/consumer-rules.pro | 4 --- infra/recent-user-activity/build.gradle.kts | 5 --- infra/recent-user-activity/consumer-rules.pro | 4 --- infra/sync/consumer-rules.pro | 4 --- 13 files changed, 19 insertions(+), 137 deletions(-) delete mode 100644 build-logic/proguard-rules.pro delete mode 100644 fingerprint/infra/scanner/consumer-rules.pro delete mode 100644 fingerprint/infra/simafis-wrapper/consumer-rules.pro delete mode 100644 infra/config-store/consumer-rules.pro delete mode 100644 infra/config-sync/consumer-rules.pro delete mode 100644 infra/recent-user-activity/consumer-rules.pro delete mode 100644 infra/sync/consumer-rules.pro diff --git a/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt index d26a49dcc2..5ed48adc3e 100644 --- a/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt @@ -29,26 +29,20 @@ class AndroidLibraryConventionPlugin : Plugin { } buildFeatures.buildConfig = true - buildTypes { - getByName(BuildTypes.release) { - isMinifyEnabled = true - proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), - "$rootDir/build-logic/proguard-rules.pro" - ) - } - create(BuildTypes.staging) { - isMinifyEnabled = true - proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), - "$rootDir/build-logic/proguard-rules.pro" - ) - } - getByName(BuildTypes.debug) { - isMinifyEnabled = false + buildTypes { + // In a library module, we generally don’t need to + // add any specific configurations here because the app module handles shrinking, + // obfuscation, and signing. Leaving this block empty means the default behavior is inherited. + getByName(BuildTypes.release) { + } + + create(BuildTypes.staging) { + } + + getByName(BuildTypes.debug) { + } + configureDebugModeBuildTypes() } - configureDebugModeBuildTypes() - } } dependencies { diff --git a/build-logic/proguard-rules.pro b/build-logic/proguard-rules.pro deleted file mode 100644 index 77c15a71c7..0000000000 --- a/build-logic/proguard-rules.pro +++ /dev/null @@ -1,25 +0,0 @@ -# Dont warn about the missing files during the obfuscation --dontwarn com.simprints.** -# Do not obfuscate the simprints package --keep class com.simprints.** { *; } -# Hilt --keep class dagger.hilt.** { *; } --keep class javax.inject.** { *; } --keep class dagger.** { *; } - -# Prevent ProGuard from removing @Module, @Inject, @Binds, etc. --keep class **Module { *; } --keep class **Inject { *; } --keep class **Provides { *; } --keep class **Binds { *; } --keep class **Hilt_** { *; } - -# Keep generated Hilt components --keep class * implements dagger.hilt.internal.GeneratedComponent { *; } - -# Keep classes annotated with @InstallIn to prevent them from being removed --keep @dagger.hilt.InstallIn class * { *; } - -# Keep Hilt components and related Dagger generated code --keep class * extends dagger.hilt.internal.GeneratedComponentManager { *; } --keep class * extends dagger.hilt.internal.GeneratedComponent { *; } diff --git a/fingerprint/infra/scanner/build.gradle.kts b/fingerprint/infra/scanner/build.gradle.kts index c051e88928..2d59ea323d 100644 --- a/fingerprint/infra/scanner/build.gradle.kts +++ b/fingerprint/infra/scanner/build.gradle.kts @@ -5,9 +5,6 @@ plugins { android { namespace = "com.simprints.fingerprint.infra.scanner" - defaultConfig { - consumerProguardFiles("consumer-rules.pro") - } } dependencies { diff --git a/fingerprint/infra/scanner/consumer-rules.pro b/fingerprint/infra/scanner/consumer-rules.pro deleted file mode 100644 index cd93590a82..0000000000 --- a/fingerprint/infra/scanner/consumer-rules.pro +++ /dev/null @@ -1,22 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /home/ethiery/Android/Sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# 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 *; -#} - -# We need to keep the vero and UN20 models because the scanner sdk uses reflection to create these -# classes from the message stream. --keep class com.simprints.fingerprint.infra.scanner.v2.domain.main.message.vero.models.* { *; } --keep class com.simprints.fingerprint.infra.scanner.v2.domain.main.message.un20.models.* { *; } diff --git a/fingerprint/infra/simafis-wrapper/build.gradle.kts b/fingerprint/infra/simafis-wrapper/build.gradle.kts index 0a940ce853..4aec712f05 100644 --- a/fingerprint/infra/simafis-wrapper/build.gradle.kts +++ b/fingerprint/infra/simafis-wrapper/build.gradle.kts @@ -4,10 +4,6 @@ plugins { android { namespace = "com.simprints.fingerprint.infra.simafiswrapper" - - defaultConfig { - consumerProguardFiles("consumer-rules.pro") - } } dependencies { diff --git a/fingerprint/infra/simafis-wrapper/consumer-rules.pro b/fingerprint/infra/simafis-wrapper/consumer-rules.pro deleted file mode 100644 index 3924b97619..0000000000 --- a/fingerprint/infra/simafis-wrapper/consumer-rules.pro +++ /dev/null @@ -1,20 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /Users/alan/Library/Android/sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# 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 *; -#} - -# We need to keep the simAFIS classes for the JNI --keep class com.simprints.fingerprint.infra.simafiswrapper** { *; } diff --git a/id/proguard-rules.pro b/id/proguard-rules.pro index f9ec12dc8e..4265b99fe6 100644 --- a/id/proguard-rules.pro +++ b/id/proguard-rules.pro @@ -58,6 +58,9 @@ #net.zetetic:android-database-sqlcipher -keep class net.sqlcipher.** { *; } +# Dont warn about the missing files during the obfuscation +-dontwarn com.simprints.** + # Do not obfuscate names in simprints package -keep class com.simprints.** { *; } # Keep all marshallable classes as-is @@ -67,24 +70,7 @@ -keep class retrofit2.** { *; } -keep interface retrofit2.** { *; } -# Hilt --keep class dagger.hilt.** { *; } --keep class javax.inject.** { *; } --keep class dagger.** { *; } - -# Prevent ProGuard from removing @Module, @Inject, @Binds, etc. --keep class **Module { *; } --keep class **Inject { *; } --keep class **Provides { *; } --keep class **Binds { *; } --keep class **Hilt_** { *; } - -# Keep generated Hilt components --keep class * implements dagger.hilt.internal.GeneratedComponent { *; } -# Keep classes annotated with @InstallIn to prevent them from being removed --keep @dagger.hilt.InstallIn class * { *; } - -# Keep Hilt components and related Dagger generated code --keep class * extends dagger.hilt.internal.GeneratedComponentManager { *; } --keep class * extends dagger.hilt.internal.GeneratedComponent { *; } +-keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite { + ; +} diff --git a/infra/config-store/build.gradle.kts b/infra/config-store/build.gradle.kts index 24170d5d10..f236d94452 100644 --- a/infra/config-store/build.gradle.kts +++ b/infra/config-store/build.gradle.kts @@ -6,9 +6,6 @@ plugins { android { namespace = "com.simprints.infra.config.store" - defaultConfig { - consumerProguardFiles("consumer-rules.pro") - } } dependencies { diff --git a/infra/config-store/consumer-rules.pro b/infra/config-store/consumer-rules.pro deleted file mode 100644 index db498be940..0000000000 --- a/infra/config-store/consumer-rules.pro +++ /dev/null @@ -1,4 +0,0 @@ -# Protobuf files --keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite { - ; -} diff --git a/infra/config-sync/consumer-rules.pro b/infra/config-sync/consumer-rules.pro deleted file mode 100644 index db498be940..0000000000 --- a/infra/config-sync/consumer-rules.pro +++ /dev/null @@ -1,4 +0,0 @@ -# Protobuf files --keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite { - ; -} diff --git a/infra/recent-user-activity/build.gradle.kts b/infra/recent-user-activity/build.gradle.kts index 131720c149..666ef16f87 100644 --- a/infra/recent-user-activity/build.gradle.kts +++ b/infra/recent-user-activity/build.gradle.kts @@ -5,13 +5,8 @@ plugins { android { namespace = "com.simprints.infra.recent.user.activity" - - defaultConfig { - consumerProguardFiles("consumer-rules.pro") - } } - dependencies { implementation(libs.datastore) } diff --git a/infra/recent-user-activity/consumer-rules.pro b/infra/recent-user-activity/consumer-rules.pro deleted file mode 100644 index db498be940..0000000000 --- a/infra/recent-user-activity/consumer-rules.pro +++ /dev/null @@ -1,4 +0,0 @@ -# Protobuf files --keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite { - ; -} diff --git a/infra/sync/consumer-rules.pro b/infra/sync/consumer-rules.pro deleted file mode 100644 index db498be940..0000000000 --- a/infra/sync/consumer-rules.pro +++ /dev/null @@ -1,4 +0,0 @@ -# Protobuf files --keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite { - ; -}