From 120c155114e03f62bad322e146a401ca78504b7f Mon Sep 17 00:00:00 2001 From: Billy Brawner Date: Sat, 25 Jun 2022 14:18:08 -0500 Subject: [PATCH] Fix issues for release builds --- gradle/libs.versions.toml | 2 +- shared/build.gradle.kts | 5 +++++ shared/proguard-rules.pro | 26 ++++++++++++++++++++++ shared/src/androidMain/AndroidManifest.xml | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 shared/proguard-rules.pro diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e7600bd..3d1edcd 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -22,7 +22,7 @@ versionCode = "1" versionName = "1.0" [libraries] -android-gradle = { module = "com.android.tools.build:gradle", version = "7.1.2"} +android-gradle = { module = "com.android.tools.build:gradle", version = "7.2.1" } androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core" } androidx-splash = { module = "androidx.core:core-splashscreen", version.ref = "androidx-splash" } diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index d07df18..c53ea25 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -60,4 +60,9 @@ android { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } + buildTypes { + release { + consumerProguardFiles("proguard-rules.pro") + } + } } diff --git a/shared/proguard-rules.pro b/shared/proguard-rules.pro new file mode 100644 index 0000000..a071319 --- /dev/null +++ b/shared/proguard-rules.pro @@ -0,0 +1,26 @@ +-keepattributes SourceFile,LineNumberTable + +-if @kotlinx.serialization.Serializable class ** +-keepclassmembers class <1> { + static <1>$Companion Companion; +} + +# Keep `serializer()` on companion objects (both default and named) of serializable classes. +-if @kotlinx.serialization.Serializable class ** { + static **$* *; +} +-keepclassmembers class <2>$<3> { + kotlinx.serialization.KSerializer serializer(...); +} + +# Keep `INSTANCE.serializer()` of serializable objects. +-if @kotlinx.serialization.Serializable class ** { + public static ** INSTANCE; +} +-keepclassmembers class <1> { + public static <1> INSTANCE; + kotlinx.serialization.KSerializer serializer(...); +} + +# @Serializable and @Polymorphic are used at runtime for polymorphic serialization. +-keepattributes RuntimeVisibleAnnotations,AnnotationDefault diff --git a/shared/src/androidMain/AndroidManifest.xml b/shared/src/androidMain/AndroidManifest.xml index 6528d73..479380f 100644 --- a/shared/src/androidMain/AndroidManifest.xml +++ b/shared/src/androidMain/AndroidManifest.xml @@ -1,6 +1,6 @@ + package="com.wbrawner.pihelper.shared"> \ No newline at end of file