DataDog / dd-sdk-android-gradle-plugin

The Datadog Gradle Plugin for Android
Apache License 2.0
14 stars 9 forks source link

De-obfuscation not working for debug variant. #146

Closed andresgleztelo-proteus closed 1 year ago

andresgleztelo-proteus commented 1 year ago

Thanks for taking the time for reporting an issue!

Describe what happened We've enabled obfuscation for debug variant and are trying to get the de-obfuscation to work by uploading the mapping file for that variant ./gradlew uploadMappingDebug

The upload succeeds but the plugin logs suggest the variant is not correctly configured, because it looks empty:

Uploading mapping file for com.proteus.proteuskiosk.debug:2.4.3-PRERELEASE {variant:} (site=datadoghq.com):

Mapping file upload successful for com.proteus.proteuskiosk.debug:2.4.3-PRERELEASE {variant:}
:app:uploadMappingDebug (Thread[Execution worker for ':',5,main]) completed. Took 30.152 secs.
producer locations for task group 0 (Thread[Execution worker for ':',5,main]) started.
producer locations for task group 0 (Thread[Execution worker for ':',5,main]) completed. Took 0.0 secs.

BUILD SUCCESSFUL in 39s

Specifically, we're expecting to see {variant:debug} instead of empty variant.

Stack traces are still obfuscated and we wonder whether it may have something to do with this. This is our configuration and Datadog initialization:

        plugins {
            id "com.datadoghq.dd-sdk-android-gradle-plugin" version "1.6.0"
            id "com.android.application"
            id "dagger.hilt.android.plugin"
            id "kotlin-android"
            id "kotlin-kapt"
            id "androidx.navigation.safeargs"
            id "kotlinx-serialization"
        }

        debug {
            resValue "string", "app_name", "ProteusKioskDebug"
            applicationIdSuffix ".debug"
            versionNameSuffix "-PRERELEASE"
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            renderscriptDebuggable false
            debuggable false
            pseudoLocalesEnabled true
            zipAlignEnabled true
        }
val credentials = Credentials(clientToken = BuildConfig.DATADOG_CLIENT_TOKEN, envName = "development", variant = BuildConfig.BUILD_TYPE, rumApplicationId = BuildConfig.DATADOG_APPLICATION_ID)
Datadog.initialize(this, credentials, configuration, TrackingConsent.GRANTED)

We've tried explicitly setting the service name in the Datadog initialization as well as in the plugin configuration, to no avail.

Steps to reproduce the issue:

Describe what you expected:

Additional context

If your project uses WebView with JS, uncomment the following

and specify the fully qualified class name to the JavaScript interface

class:

-keepclassmembers class com.proteus.proteuskiosk.core.webview.ApplicationJavaScriptInterface { public *; }

-keepclassmembers class com.proteus.proteuskiosk.* { ; }

-keepclassmembers enum com.proteus.proteuskiosk.data.model. { public ; }

-keepclassmembers enum { ; }

Uncomment this to preserve the line number information for

debugging stack traces.

-keepattributes SourceFile,LineNumberTable

If you keep the line number information, uncomment this to

hide the original source file name.

-renamesourcefileattribute SourceFile


 - Other Gradle Plugins:
andresgleztelo-proteus commented 1 year ago

Update: I see these for other variants as well

Uploading mapping file for com.proteus.proteuskiosk.staging:2.4.3-STAGING {variant:} (site=datadoghq.com):

Mapping file upload successful for com.proteus.proteuskiosk.staging:2.4.3-STAGING {variant:}
xgouchet commented 1 year ago

Hi @andresgleztelo-proteus , the build type (debug/release) is not something that we include in the variant used to identify and match errors with mapping files, mostly because debug versions very rarely have obfuscation, and are not deployed to end users. In your case, the main issue is that you configure the SDK with variant set to debug, when you should leave it as an empty string. The good thing is that you're using a different package name, meaning there are no conflicts between your release and debug mapping files.

andresgleztelo-proteus commented 1 year ago

I see. Thank you 👍