使用rn.30版本与native混编出现Didn't find class错误是什么情况?



  • 之前也试用过29.2的版本debug模式可以正常运行。但那个版本热更新好像有点问题我就换了最新的30版本。
    结果出现:

    java.lang.ClassNotFoundException: Didn't find class "com.facebook.jni.IteratorHelper" on path: DexPathList[[zip file "/data/app/com.aoliday.android.phone-1/base.apk"],nativeLibraryDirectories=[/data/app/com.aoliday.android.phone-1/lib/arm, /data/app/com.aoliday.android.phone-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
    at com.facebook.react.cxxbridge.ModuleRegistryHolder.initHybrid(Native Method)
    at com.facebook.react.cxxbridge.ModuleRegistryHolder.<init>(ModuleRegistryHolder.java:26)
    at com.facebook.react.cxxbridge.NativeModuleRegistry.getModuleRegistryHolder(NativeModuleRegistry.java:63)
    at com.facebook.react.cxxbridge.CatalystInstanceImpl.<init>(CatalystInstanceImpl.java:106)
    at com.facebook.react.cxxbridge.CatalystInstanceImpl.<init>(CatalystInstanceImpl.java:50)
    at com.facebook.react.cxxbridge.CatalystInstanceImpl$Builder.build(CatalystInstanceImpl.java:484)
    at com.facebook.react.XReactInstanceManagerImpl.createReactContext(XReactInstanceManagerImpl.java:860)
    at com.facebook.react.XReactInstanceManagerImpl.access$600(XReactInstanceManagerImpl.java:103)
    at com.facebook.react.XReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(XReactInstanceManagerImpl.java:203)
    at com.facebook.react.XReactInstanceManagerImpl$ReactContextInitAsyncTask.doInBackground(XReactInstanceManagerImpl.java:182)
    at android.os.AsyncTask$2.call(AsyncTask.java:307)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:246)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    at java.lang.Thread.run(Thread.java:833)
    Suppressed: java.lang.ClassNotFoundException: com.facebook.jni.IteratorHelper
    at java.lang.Class.classForName(Native Method)
    at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
    at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
    ... 17 more
    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
    有没大手知道原因呢?
    以下是我activity的代码

    public class MyReactActivity extends Activity implements DefaultHardwareBackBtnHandler {
    private ReactRootView mReactRootView;
    private ReactInstanceManager mReactInstanceManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        mReactRootView = new ReactRootView(this);
        mReactInstanceManager = ReactInstanceManager.builder()
                .setApplication(getApplication())
                .setBundleAssetName("index.android.bundle")
                .setJSMainModuleName("index.android")
                .addPackage(new MainReactPackage())
                .setUseDeveloperSupport(true)
                .setInitialLifecycleState(LifecycleState.RESUMED)
                .build();
        mReactRootView.startReactApplication(mReactInstanceManager, "MyAwesomeApp", null);
    
        setContentView(mReactRootView);
    }