Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix demo crash when using R8 full mode (close #652) #663

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ POM_LICENCE_DIST=repo

POM_DEVELOPER_ID=snowplow
POM_DEVELOPER_NAME=Snowplow Analytics
android.enableR8.fullMode=true
8 changes: 7 additions & 1 deletion snowplow-demo-compose/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ android {

buildTypes {
release {
minifyEnabled false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Expand Down Expand Up @@ -60,6 +61,11 @@ dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':snowplow-android-tracker')

implementation 'com.google.android.gms:play-services-appset:16.0.2'
implementation 'com.google.android.gms:play-services-ads:22.6.0'
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
implementation "com.android.installreferrer:installreferrer:2.2"

implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.0.0"
Expand Down
17 changes: 16 additions & 1 deletion snowplow-demo-compose/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,19 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add these to the setup section in the docs.

# Fixes R8 full mode crash
# Also see https://github.com/square/retrofit/issues/3751
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
-keep,allowobfuscation,allowshrinking class retrofit2.Response
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation

# Reflection for the appSetId
-keep class com.google.android.gms.appset.AppSet { *; }
-keep class com.google.android.gms.appset.AppSetIdInfo { *; }
-keep class com.google.android.gms.internal.appset.zzr { *; }
-keep class com.google.android.gms.tasks.Tasks { *; }

# Reflection for the AAID (AndroidIdfa)
-keep class com.google.android.gms.ads.identifier.** { *; }
5 changes: 4 additions & 1 deletion snowplow-demo-compose/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Snowplowandroidtracker">
<!-- Sample Ad Manager app ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
<activity
android:name=".MainActivity"
android:exported="true"
Expand All @@ -24,5 +28,4 @@
</intent-filter>
</activity>
</application>

</manifest>
11 changes: 10 additions & 1 deletion snowplow-demo-kotlin/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

# Reflection for the appSetId
-keep class com.google.android.gms.appset.AppSet { *; }
-keep class com.google.android.gms.appset.AppSetIdInfo { *; }
-keep class com.google.android.gms.internal.appset.zzr { *; }
-keep class com.google.android.gms.tasks.Tasks { *; }

# Reflection for the AAID (AndroidIdfa)
-keep class com.google.android.gms.ads.identifier.** { *; }
Loading