bugsnag / bugsnag-react-native

Error monitoring and reporting tool for native exceptions and JS errors in React Native apps
https://docs.bugsnag.com/platforms/react-native
MIT License
370 stars 121 forks source link

Where is proguard mapping.txt? #66

Closed pewh closed 7 years ago

pewh commented 7 years ago

Hello, from the tutorial I've read on https://docs.bugsnag.com/api/proguard-upload/, the param -F proguard=@/path/to/mapping.txt should include proguard mapping file. My question is: where I can get this file? I've search this and didn't see any mapping.txt. I also have make sure to enable enableProguardInReleaseBuilds and execute ./gradlew assembleRelease && ./gradlew installRelease to generate app-release.apk. Maybe am I doing misconfiguration on react native project?

This is my proguard file for reference:

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

# Disabling obfuscation is useful if you collect stack traces from production crashes
# (unless you are using a system that supports de-obfuscate the stack traces).
-dontobfuscate

# React Native

# Keep our interfaces so they can be used by other ProGuard rules.
# See http://sourceforge.net/p/proguard/bugs/466/
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip

# Do not strip any method/class that is annotated with @DoNotStrip
-keep @com.facebook.proguard.annotations.DoNotStrip class *
-keep @com.facebook.common.internal.DoNotStrip class *
-keepclassmembers class * {
    @com.facebook.proguard.annotations.DoNotStrip *;
    @com.facebook.common.internal.DoNotStrip *;
}

-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
  void set*(***);
  *** get*();
}

-keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
-keep class * extends com.facebook.react.bridge.NativeModule { *; }
-keepclassmembers,includedescriptorclasses class * { native <methods>; }
-keepclassmembers class *  { @com.facebook.react.uimanager.UIProp <fields>; }
-keepclassmembers class *  { @com.facebook.react.uimanager.annotations.ReactProp <methods>; }
-keepclassmembers class *  { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; }

-dontwarn com.facebook.react.**

# okhttp

-keepattributes Signature
-keepattributes *Annotation*
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**

# okio

-keep class sun.misc.Unsafe { *; }
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn okio.**

# react-native-facebook-account-kit
-keep class com.facebook.FacebookSdk {
   boolean isInitialized();
}
-keep class com.facebook.appevents.AppEventsLogger {
   com.facebook.appevents.AppEventsLogger newLogger(android.content.Context);
   void logSdkEvent(java.lang.String, java.lang.Double, android.os.Bundle);
}

# react-native-config
-keep class com.gokuliner.BuildConfig { *; }

# react-native-background-geolocation
-dontwarn ch.qos.logback.core.**

# bugsnag-react-native
-keepattributes LineNumberTable,SourceFile

-dontwarn sun.misc.Unsafe
kattrali commented 7 years ago

Thanks for the report, @pewh. I built a new project and couldn't find the mapping where I expected it (somewhere around build/outputs/proguard/...). You could try adding -printmapping path/in/project/mapping.txt and see if its generated?

pewh commented 7 years ago

Hello @kattrali, thanks for the response. I've try to add -printmapping build/outputs/mapping/release/mapping.txt, then ./gradlew assembleRelease && ./gradlew installRelease, but still not generate mapping.txt. I'm test again with -printmapping mapping.txt and still no luck.

bullmo commented 7 years ago

Hi @pewh if you remove the -dontobfuscate line from the proguard configuration file it should obfuscate the code and generate a mapping file containing the mappings between the original names and the obfuscated names

pewh commented 7 years ago

Ah, it's generated now. Thanks @bullmo :beers: