3

您好,我在 react native 0.63.4 中运行应用程序时遇到了一些崩溃问题

这是我的崩溃错误

E/ReactNativeJNI: logMarker CREATE_REACT_CONTEXT_END
E/unknown:ReactNative: ReactInstanceManager.createReactContext: mJSIModulePackage not null
E/AndroidRuntime: FATAL EXCEPTION: create_react_context
    Process: com.apps, PID: 20635
    java.lang.AssertionError: Could not find module with name ReanimatedModule
        at com.facebook.infer.annotation.Assertions.assertNotNull(Assertions.java:35)
        at com.facebook.react.bridge.NativeModuleRegistry.getModule(NativeModuleRegistry.java:148)
        at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:596)
        at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:566)
        at com.facebook.react.bridge.ReactContext.getNativeModule(ReactContext.java:165)
        at com.swmansion.reanimated.ReanimatedJSIModulePackage.getJSIModules(ReanimatedJSIModulePackage.java:17)
        at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1256)
        at com.facebook.react.ReactInstanceManager.access$1100(ReactInstanceManager.java:131)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1016)
        at java.lang.Thread.run(Thread.java:764)

这是我的 package.json

{
  "name": "Apps",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "axios": "^0.19.0",
    "core-js": "^3.3.5",
    "lodash": "4.17.15",
    "moment": "2.24.0",
    "phoenix": "^1.4.10",
    "phoenix-channels": "^1.0.0",
    "querystring": "^0.2.0",
    "react": "16.13.1",
    "react-native": "0.63.4",
    "react-native-countdown-component": "2.5.2",
    "react-native-datepicker": "1.7.2",
    "react-native-device-info": "^8.0.1",
    "react-native-elements": "^1.2.7",
    "react-native-fbsdk": "^3.0.0",
    "react-native-gesture-handler": "^1.10.2",
    "react-native-google-places-autocomplete": "1.3.9",
    "react-native-google-signin": "1.2.3",
    "react-native-htmlview": "0.15.0",
    "react-native-image-picker": "0.28.0",
    "react-native-image-zoom-viewer": "2.2.26",
    "react-native-insider": "^4.1.1",
    "react-native-maps": "0.24.2",
    "react-native-number-stepper": "0.0.2",
    "react-native-onesignal": "^3.6.0",
    "react-native-reanimated": "^2.0.0-rc.3",
    "react-native-router-flux": "^4.2.0",
    "react-native-screens": "^2.18.1",
    "react-native-share": "^1.2.1",
    "react-native-star-rating": "1.1.0",
    "react-native-url-preview": "^1.1.4",
    "react-native-vector-icons": "6.6.0",
    "react-native-version-check": "^3.3.1",
    "react-native-view-more-text": "2.1.0",
    "react-native-webview": "^10.3.2",
    "recyclerlistview": "^2.0.12"
  },
  "devDependencies": {
    "@babel/core": "^7.13.1",
    "@babel/runtime": "^7.13.6",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "eslint": "^7.20.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.65.1",
    "react-test-renderer": "16.13.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

这是我的 MainApplication.java

package com.apps;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.geektime.rnonesignalandroid.ReactNativeOneSignalPackage;
import cl.json.RNSharePackage;
import com.imagepicker.ImagePickerPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import co.apptailor.googlesignin.RNGoogleSigninPackage;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.react.bridge.JSIModulePackage;
import com.swmansion.reanimated.ReanimatedJSIModulePackage;
import com.airbnb.android.react.maps.MapsPackage;
import io.xogus.reactnative.versioncheck.RNVersionCheckPackage;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  private static CallbackManager mCallbackManager = CallbackManager.Factory.create();

  protected static CallbackManager getCallbackManager() {
    return mCallbackManager;
  }

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
            new RNDeviceInfo(),
            new ReactNativeOneSignalPackage(),
            new RNSharePackage(),
            new ImagePickerPackage(),
            new VectorIconsPackage(),
            new RNGoogleSigninPackage(),
            new RNVersionCheckPackage(),
          new FBSDKPackage(),
          new MapsPackage()
      );
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }

    @Override
    protected JSIModulePackage getJSIModulePackage() {
      return new ReanimatedJSIModulePackage();
    }

  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    FacebookSdk.sdkInitialize(getApplicationContext());
    SoLoader.init(this, /* native exopackage */ false);
  }
}

这是我的 MainActivity.java

package com.apps;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
import android.content.Intent;
import android.os.Bundle;

public class MainActivity extends ReactActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "Apps";
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(null);
    }

    @Override
    protected ReactActivityDelegate createReactActivityDelegate() {
    return new ReactActivityDelegate(this, getMainComponentName()) {
        @Override
        protected ReactRootView createRootView() {
            return new RNGestureHandlerEnabledRootView(MainActivity.this);
            }
        };
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data);
    }

    @Override
    public void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
    }
}

我已经启用了我的爱马仕并按照文档 react-native-reanimated 中的说明进行操作,但仍然崩溃并出现类似的错误,我已经坚持了 1 周来解决这个问题,但仍然无法正常工作。请帮我 :)

4

1 回答 1

0

如果您使用的是 proguard,那么这个 https://github.com/software-mansion/react-native-reanimated/issues/1314可能会对您有所帮助。

基本上,您需要在 proguard 文件中添加此规则。

-keep class com.facebook.react.turbomodule.** { *; }
于 2022-02-05T13:05:45.410 回答