PostHog / posthog-flutter

PostHog Flutter SDK
https://posthog.com/docs/libraries/flutter
MIT License
52 stars 37 forks source link

Android Release Builds needs proguard-rules.pro when minifyEnabled #107

Closed TobiasHeidingsfeld closed 3 months ago

TobiasHeidingsfeld commented 4 months ago

Version

4.4.1

Steps to Reproduce

When adding Posthog and minifyEnabled is true in Gradle on Android the app breaks on startup. Solution is to add the following rules to proguard-rules.pro


# posthog
-keep class com.posthog.** { *; }
-keep interface com.posthog.** { *; }

Feel free to add this to your documentation and let us know if there is anything else needed.

Expected Result

Posthog not breaking the app

Actual Result

Posthog breaking the app which can not start

marandaneto commented 4 months ago

Hey @TobiasHeidingsfeld The PH Android SDK already ships all the rules https://github.com/PostHog/posthog-android/blob/main/posthog-android/consumer-rules.pro Strange that it's still crashing, do you know what exactly is causing this? what is the error? can you check logcat and copy paste the details? What is the AGP version? what is the Gradle version? etc.

TobiasHeidingsfeld commented 4 months ago

Could it be related to us using

proguardFiles getDefaultProguardFile('proguard-android.txt')

in our build.gradle ? Will this override your consumer-rules.pro?

marandaneto commented 4 months ago

Could it be related to us using

proguardFiles getDefaultProguardFile('proguard-android.txt')

in our build.gradle ? Will this override your consumer-rules.pro?

I don't think so, the proguard rules are merged and taken into account. https://github.com/PostHog/posthog-flutter/pull/108 works just fine for me (even with android.enableR8.fullMode=true). Can you answer the questions above so I can check if I spot anything strange in your config at least?

marandaneto commented 4 months ago

Can be related to https://github.com/PostHog/posthog-android/issues/135 but we have not found out yet why nor if it's a one-off because no one else is reporting this nor I can reproduce it locally.

marandaneto commented 3 months ago

@TobiasHeidingsfeld did you manage to reproduce the issue?

marandaneto commented 3 months ago

Closing the issue as a part of large repository cleanup, due to it being inactive and/or outdated. Please do not hesitate to ping me if it is still relevant, and I will happily reopen and work on it. Cheers!