question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

App crash when trying to load react native component in release mode

See original GitHub issue

Description

I am trying to add a react native component in my native Android app. It work fine when I am using debug build type. But when I use release build type with minifyEnabled true and shrinkResources true. Try to load react native component app crash with below error.

I/art: Thread[1,tid=7118,Native,Thread*=0xadd8b400,peer=0x73df36f0,"main"] recursive attempt to load library "/data/app/{package name}-1/lib/x86/libfb.so"

Reproduction

Integrate a react native component in native Android app. Enable proguard and use minifyEnabled true and shrinkResources true. Try to load the component app will crash with above mentioned error.

Solution

Please let me know how can I fix this issue. Please find below proguard entries.

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. -dontwarn android.text.StaticLayout

okhttp

-keep class com.squareup.okhttp.** { ; } -keep interface com.squareup.okhttp.* { ; } -dontwarn com.squareup.okhttp.*

okio

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

stetho

-dontwarn com.facebook.stetho.**

Additional Information

  • React Native version: “react”: “^15.4.1”, “react-native”: “0.42.0”
  • Platform: Android
  • Operating System: MacOS
  • Dev tools: Android Studio 2.3

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nikith050commented, May 15, 2017

react-native app crashes on android phone. App gets hanged on listview scrolling.

“react”: “16.0.0-alpha.6” “react-native”: “0.43.3”

1reaction
shahbaz07commented, Apr 4, 2017

@alloy, thanks you very much for your reply. I will try to provide sample APK and also try to post the same issue on StackOverflow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android app crashes on release build but works in debug build
Currently react-native-gesture-handler has to be imported before everything for the release build to work without crashing.
Read more >
App crashes in release mode #954 - GitHub
When it's built, and when trying to use the camera, the apk crashes every time. This works perfectly on debug mode.
Read more >
Fixing React-Native android release build - wesionaryTEAM
Android release build crashes on launch but works fine in development mode. After months of research and development, your app is finally ready...
Read more >
Using Hermes - React Native
Hermes is an open-source JavaScript engine optimized for React Native. For many apps, using Hermes will result in improved start-up time, ...
Read more >
Crashes - Android Developers
There are many situations that can cause a crash in your app. Some reasons are obvious, like checking for a null value or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found