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

KitKat crash when ProGuard is enabled #678

Closed
eduardb opened this issue Aug 16, 2021 · 5 comments · Fixed by #690
Closed

KitKat crash when ProGuard is enabled #678

eduardb opened this issue Aug 16, 2021 · 5 comments · Fixed by #690
Assignees
Labels
bug Something isn't working
Milestone

Comments

@eduardb
Copy link

eduardb commented Aug 16, 2021

Describe what happened

Crash stack trace:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.***, PID: 10436
    java.lang.VerifyError: com/datadog/android/rum/tracking/ActivityViewTrackingStrategy
        at com.datadog.android.core.configuration.Configuration.<clinit>(Configuration.kt:633)
        at com.datadog.android.core.configuration.Configuration$Builder.<init>(Configuration.kt:125)
        at app code

The following logs can be observed in LogCat:

I/dalvikvm: Could not find method android.app.Application$ActivityLifecycleCallbacks.onActivityPostResumed, referenced from method com.datadog.android.rum.tracking.ActivityViewTrackingStrategy.onActivityPostResumed
W/dalvikvm: VFY: unable to resolve virtual method 257: Landroid/app/Application$ActivityLifecycleCallbacks;.onActivityPostResumed (Landroid/app/Activity;)V
W/dalvikvm: VFY:  rejecting opcode 0x6f at 0x0005
W/dalvikvm: VFY:  rejected Lcom/datadog/android/rum/tracking/ActivityViewTrackingStrategy;.onActivityPostResumed (Landroid/app/Activity;)V
W/dalvikvm: Verifier rejected class Lcom/datadog/android/rum/tracking/ActivityViewTrackingStrategy;
W/dalvikvm: Exception Ljava/lang/VerifyError; thrown while initializing Lcom/datadog/android/core/configuration/Configuration;
D/AndroidRuntime: Shutting down VM

Steps to reproduce the issue:

Enable ProGuard by setting isMinifyEnabled to true in the release build type, run release variant on KitKat, observe crash when DataDog SDK is initialised.

Describe what you expected:

No crash.

Additional context

  • Android OS version: 4.4 KitKat
  • Device Model: any
  • Datadog SDK version: 1.8.1 and newer
  • Versions of any other relevant dependencies (OkHttp, …): OkHttp 3.12.13
  • Proguard configuration:
Click to expand
-dontobfuscate

-keepattributes SourceFile,LineNumberTable

-dontnote com.google.android.gms.maps.internal.zzy

-keepclassmembers,includedescriptorclasses public class * extends android.view.View {
 void set*(***);
 *** get*();
}

-dontwarn org.apache.commons.compress.archivers.sevenz.**
-dontwarn org.apache.commons.compress.compressors.lzma.**
-dontnote org.apache.commons.compress.compressors.lzma.**
-dontwarn org.apache.commons.compress.compressors.xz.**
-dontnote org.apache.commons.compress.compressors.xz.**

-dontwarn org.joda.time.**

-keep class org.joda.time.tz.Provider
-keep class org.joda.time.tz.NameProvider

-dontnote com.daimajia.swipe.SwipeLayout

-dontnote com.koushikdutta.async.http.SSLEngineSNIConfigurator$EngineHolder
-dontnote com.koushikdutta.async.http.spdy.SpdyMiddleware

-dontnote okhttp3.internal.platform.Platform
-dontnote okhttp3.internal.platform.AndroidPlatform
-dontnote okhttp3.internal.platform.AndroidPlatform$CloseGuard

-dontwarn java.nio.file.**
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

-dontnote android.net.http.**
-dontnote org.apache.http.**

-dontnote sun.misc.Unsafe

-dontnote com.google.android.gms.security.ProviderInstaller

-dontnote kotlin.internal.**
-dontnote kotlin.reflect.jvm.internal.**

-dontwarn javax.lang.model.**
-dontwarn com.squareup.javapoet.**
-dontwarn com.squareup.moshi.**
-dontwarn org.jetbrains.annotations.**

-dontnote androidx.work.impl.**
-dontwarn sun.misc.Unsafe
-dontwarn android.app.job.JobParameters
-keep class androidx.work.WorkerParameters
-dontnote androidx.work.WorkParameters

-keepclassmembers class * extends androidx.work.Worker {
  <init>(...);
}

-keep class kotlin.coroutines.CoroutineContext*
-keep class kotlin.jvm.internal.DefaultConstructorMarker
-keep class kotlin.jvm.functions.Function2
-keep class androidx.lifecycle.**
-dontwarn kotlinx.atomicfu.AtomicBoolean
-keep class kotlinx.coroutines.android.AndroidExceptionPreHandler
-keep class kotlinx.coroutines.android.AndroidDispatcherFactory

-dontwarn org.slf4j.**

-keepattributes Signature,InnerClasses,EnclosingMethod

-dontwarn androidx.work.impl.background.firebase.*
-dontwarn kotlinx.atomicfu.*

-keep class * implements com.apollographql.apollo.api.InputType { *; }

-keepnames class * implements com.apollographql.apollo.api.internal.ResponseFieldMapper

  • Gradle Plugins: Android Gradle Plugin 7.0
@eduardb eduardb added the bug Something isn't working label Aug 16, 2021
@xgouchet
Copy link
Member

Hi @eduardb , and thanks for reporting this issue. It seems weird as the missing method (android.app.Application.ActivityLifecycleCallbacks.onActivityPostResumed()) is part of the Android Framework itself, and not something we implemented. We're going to take a look at this.

In the meantime, did you try using the -keep class android.app.Application$ActivityLifecycleCallbacks { *; } line to see if that solves the issue ?

@eduardb
Copy link
Author

eduardb commented Aug 17, 2021

Hi, @xgouchet! Thanks for your response. Unfortunately, your suggestion didn't work :( android.app.Application.ActivityLifecycleCallbacks.onActivityPostResumed() is a method that has been added to Android in API level 29, so I imagine that -keep class android.app.Application$ActivityLifecycleCallbacks { *; } has no effect in this regards on KitKat.

I will try later and create a minimum reproducible project, in case that it helps.

@xgouchet
Copy link
Member

Yes that would definitely help.

@eduardb
Copy link
Author

eduardb commented Aug 17, 2021

Here it is: https://github.com/eduardb/datadog-crash-repro

Just try running the release variant on KitKat, and the crash should occur.

@0xnm
Copy link
Member

0xnm commented Sep 2, 2021

Hello @eduardb. Thanks for reporting the issue. It was fixed and should be available in the upcoming 1.11 release.

@xgouchet xgouchet added this to the 1.11.0 milestone Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants