diff --git a/CHANGELOG.md b/CHANGELOG.md index dee16c79..38b978ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Change Log ========== +Next version +------------------------------------ +- Fix: Added ProGuard rules so that SDK clients can use R8 to shrink their apps +- Updated dependencies + Version 1.3.0-beta19 *(2021-11-22)* ------------------------------------ - New: Updated checkpoints for Mainnet and Testnet diff --git a/demo-app/build.gradle.kts b/demo-app/build.gradle.kts index 01425019..b8aed5fb 100644 --- a/demo-app/build.gradle.kts +++ b/demo-app/build.gradle.kts @@ -36,7 +36,7 @@ android { buildTypes { getByName("release").apply { - isMinifyEnabled = project.property("IS_MINIFY_ENABLED").toString().toBoolean() + isMinifyEnabled = project.property("IS_MINIFY_APP_ENABLED").toString().toBoolean() proguardFiles.addAll( listOf( getDefaultProguardFile("proguard-android-optimize.txt"), diff --git a/demo-app/proguard-project.txt b/demo-app/proguard-project.txt new file mode 100644 index 00000000..d371ddc5 --- /dev/null +++ b/demo-app/proguard-project.txt @@ -0,0 +1,3 @@ +# Allow for debuggable stacktraces +-keepattributes SourceFile,LineNumberTable +-renamesourcefileattribute SourceFile diff --git a/demo-app/proguard-rules.pro b/demo-app/proguard-rules.pro deleted file mode 100644 index 2f9dc5a4..00000000 --- a/demo-app/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.kts. -# -# 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 diff --git a/gradle.properties b/gradle.properties index 04d2791a..61070c14 100644 --- a/gradle.properties +++ b/gradle.properties @@ -41,7 +41,10 @@ IS_COVERAGE_ENABLED=false IS_USE_TEST_ORCHESTRATOR=false # Optionally configure minification -IS_MINIFY_ENABLED=false +# For now, don't minify the SDK but do minify the app. Minifying the app helps us test +# the proguard-consumer rules in the SDK. +IS_MINIFY_SDK_ENABLED=false +IS_MINIFY_APP_ENABLED=true # Set keystore details to enable build signing. Typically these # are overridden via ~/.gradle/gradle.properties to allow secure injection. diff --git a/sdk-lib/build.gradle.kts b/sdk-lib/build.gradle.kts index 187d332f..f9c7c599 100644 --- a/sdk-lib/build.gradle.kts +++ b/sdk-lib/build.gradle.kts @@ -38,6 +38,8 @@ android { argument("room.schemaLocation", "$projectDir/schemas") } } + + consumerProguardFiles("proguard-consumer.txt") } buildTypes { @@ -45,20 +47,14 @@ android { // test builds exceed the dex limit because they pull in large test libraries multiDexEnabled = true isMinifyEnabled = false - proguardFiles.addAll( - listOf( - getDefaultProguardFile("proguard-android-optimize.txt"), - File("proguard-rules.pro") - ) - ) } getByName("release").apply { multiDexEnabled = false - isMinifyEnabled = project.property("IS_MINIFY_ENABLED").toString().toBoolean() + isMinifyEnabled = project.property("IS_MINIFY_SDK_ENABLED").toString().toBoolean() proguardFiles.addAll( listOf( getDefaultProguardFile("proguard-android-optimize.txt"), - File("proguard-rules.pro") + File("proguard-project.txt") ) ) } diff --git a/sdk-lib/proguard-consumer.txt b/sdk-lib/proguard-consumer.txt new file mode 100644 index 00000000..5f747167 --- /dev/null +++ b/sdk-lib/proguard-consumer.txt @@ -0,0 +1,11 @@ +-keepclasseswithmembernames,includedescriptorclasses class * { + native ; +} + +# https://github.com/grpc/grpc-java/blob/master/android/proguard-rules.txt +-keepclassmembers class io.grpc.okhttp.OkHttpChannelBuilder { + io.grpc.okhttp.OkHttpChannelBuilder forTarget(java.lang.String); + io.grpc.okhttp.OkHttpChannelBuilder scheduledExecutorService(java.util.concurrent.ScheduledExecutorService); + io.grpc.okhttp.OkHttpChannelBuilder sslSocketFactory(javax.net.ssl.SSLSocketFactory); + io.grpc.okhttp.OkHttpChannelBuilder transportExecutor(java.util.concurrent.Executor); +} \ No newline at end of file diff --git a/sdk-lib/proguard-project.txt b/sdk-lib/proguard-project.txt new file mode 100644 index 00000000..771dd1fc --- /dev/null +++ b/sdk-lib/proguard-project.txt @@ -0,0 +1,24 @@ +# This improves obfuscation and moves non-public classes to their own namespace. +-repackageclasses 'cash.z.ecc.android.sdk.internal' + +# This makes it easier to autocomplete methods in an IDE using this obfuscated library. +-keepparameternames + +# The ProGuard manual recommends keeping these attributes for libraries. +-keepattributes EnclosingMethod,InnerClasses,Signature,Exceptions,*Annotation* + +# Ensure that stacktraces are reversible. +-renamesourcefileattribute SourceFile +-keepattributes SourceFile,LineNumberTable + +# Keep the public interface of the library. +# Some of these will need to be tuned in the future, as they shouldn't ALL be considered part of the +# public API. Much of this will be improved by further repackaging of the classes. +-keep public class cash.z.ecc.android.sdk.* { public protected *; } +-keep public class cash.z.ecc.android.sdk.block.* { public protected *; } +-keep public class cash.z.ecc.android.sdk.db.entity.* { public protected *; } +-keep public class cash.z.ecc.android.sdk.exception.* { public protected *; } +-keep public class cash.z.ecc.android.sdk.ext.* { public protected *; } +-keep public class cash.z.ecc.android.sdk.jni.* { public protected *; } +-keep public class cash.z.ecc.android.sdk.tool.* { public protected *; } +-keep public class cash.z.ecc.android.sdk.type.* { public protected *; } \ No newline at end of file diff --git a/sdk-lib/proguard-rules.pro b/sdk-lib/proguard-rules.pro deleted file mode 100644 index 2f9dc5a4..00000000 --- a/sdk-lib/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.kts. -# -# 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