Skip to content

Commit

Permalink
Pick up consumer proguard rules correctly (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto authored Nov 14, 2023
1 parent 8a905bc commit 0e1fb69
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Next

- Expose and allow to enable and disable the debug mode at runtime ([#60](https://github.com/PostHog/posthog-android/pull/60))
- Pick up consumer proguard rules correctly ([#62](https://github.com/PostHog/posthog-android/pull/62))

## 3.0.0-beta.4 - 2023-11-08

Expand Down
6 changes: 0 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,9 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true

android.defaults.buildfeatures.buildconfig=true
android.defaults.buildfeatures.renderscript=false
android.defaults.buildfeatures.shaders=false
android.defaults.buildfeatures.aidl=false
android.defaults.buildfeatures.resvalues=false

# Release
Expand Down
3 changes: 1 addition & 2 deletions posthog-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ android {
minSdk = PosthogBuildConfig.Android.MIN_SDK

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")

buildFeatures {
buildConfig = true
Expand All @@ -32,7 +31,7 @@ android {

buildTypes {
release {
consumerProguardFiles("proguard-rules.pro")
consumerProguardFiles("consumer-rules.pro")
}
}
compileOptions {
Expand Down
15 changes: 11 additions & 4 deletions posthog-android/consumer-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.posthog.PostHogEvent { <fields>; }
-keep class com.posthog.internal.PostHogBatchEvent { <fields>; }
-keep class com.posthog.internal.PostHogDecideRequest { <fields>; }
-keep class com.posthog.internal.PostHogDecideResponse { <fields>; }
-keep class com.posthog.PostHogEvent { *; }
-keep class com.posthog.PostHogEvent { <init>(); }

-keep class com.posthog.internal.PostHogBatchEvent { *; }
-keep class com.posthog.internal.PostHogBatchEvent { <init>(); }

-keep class com.posthog.internal.PostHogDecideRequest { *; }
-keep class com.posthog.internal.PostHogDecideRequest { <init>(); }

-keep class com.posthog.internal.PostHogDecideResponse { *; }
-keep class com.posthog.internal.PostHogDecideResponse { <init>(); }

# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
Expand Down
4 changes: 3 additions & 1 deletion posthog-samples/posthog-android-sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ android {

buildTypes {
release {
isMinifyEnabled = false
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
)
signingConfig = signingConfigs.getByName("debug")
}
}
compileOptions {
Expand Down

0 comments on commit 0e1fb69

Please sign in to comment.