在Android 4.4.2和4.2.2上使用react native组件时出错

时间:2017-04-11 08:26:34

标签: android react-native

尝试在Android应用中初始化本机组件时,在 Android操作系统版本 4.4.2 4.2.2 上出现此错误。

  

致命异常:java.lang.VerifyError:com / facebook / soloader / g at   com.facebook.soloader.SoLoader.initImpl $ 1a54e370(SoLoader.java:189)at at   com.facebook.soloader.SoLoader.init(SoLoader.java:1105)at   com.facebook.react.ReactInstanceManager.initializeSoLoaderIfNecessary(ReactInstanceManager.java:1358)   在   com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:227)

2 个答案:

答案 0 :(得分:3)

修复崩溃:

# SoLoader
-keep class com.facebook.soloader.** { *; }
-keepclassmembers class com.facebook.soloader.SoLoader {
     static <fields>;
}

参考:https://github.com/facebook/react-native/issues/7530

答案 1 :(得分:0)

Add implementation 'com.android.support:multidex:1.0.3' to dependencies in app/build.gradle

In MainApplication.java:
import androidx.multidex.MultiDex; // Note: You might need to replace this with: 

import android.support.multidex.Multidex;
import android.content.Context;

Add following to MainApplication.java:

  @Override
  protected void attachBaseContext(Context base) {
     super.attachBaseContext(base);
     MultiDex.install(this);
  }