Bootstrap方法返回null-启动时Android立即崩溃

时间:2019-01-16 19:31:32

标签: android react-native react-native-navigation

React Native和react-native-navigation的新手。该应用在iOS上可以正常运行,但在启动时会很快抛出以下异常:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.engagereact, PID: 8105
    java.lang.BootstrapMethodError: Exception from call site #3 bootstrap method
        at com.reactnativenavigation.react.JsDevReloadHandler.<init>(JsDevReloadHandler.java:29)
        at com.reactnativenavigation.react.ReactGateway.<init>(ReactGateway.java:29)
        at com.engagereact.MainApplication.createReactGateway(MainApplication.java:29)
        at com.reactnativenavigation.NavigationApplication.onCreate(NavigationApplication.java:28)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1154)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5871)
        at android.app.ActivityThread.access$1100(ActivityThread.java:199)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: java.lang.ClassCastException: Bootstrap method returned null
        at com.reactnativenavigation.react.JsDevReloadHandler.<init>(JsDevReloadHandler.java:29) 
        at com.reactnativenavigation.react.ReactGateway.<init>(ReactGateway.java:29) 
        at com.engagereact.MainApplication.createReactGateway(MainApplication.java:29) 
        at com.reactnativenavigation.NavigationApplication.onCreate(NavigationApplication.java:28) 
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1154) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5871) 
        at android.app.ActivityThread.access$1100(ActivityThread.java:199) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:6669) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 

react-native-navigation / lib / android / app / source / etc确实在第29行中返回null- private ReloadListener reloadListener = () -> {};

依赖项:

engage-react@0.0.1 /Users/komara/Documents/infor-repos/EngageReact
├── @babel/plugin-proposal-decorators@7.2.3
├── @babel/runtime@7.0.0
├── axios@0.18.0
├── babel-eslint@10.0.1
├── babel-jest@23.6.0
├── babel-plugin-transform-decorators-legacy@1.3.5
├── babel-preset-react-native@4.0.1
├── eslint@5.12.0
├── eslint-config-airbnb@17.1.0
├── eslint-config-prettier@3.4.0
├── eslint-plugin-import@2.14.0
├── eslint-plugin-jsx-a11y@6.1.2
├── eslint-plugin-prettier@3.0.1
├── eslint-plugin-react@7.12.3
├── jest@23.6.0
├── metro-react-native-babel-preset@0.49.2
├── mobx@5.8.0
├── mobx-react@5.4.3
├── node@11.6.0
├── prettier@1.15.3
├── react@16.6.3
├── react-native@0.57.8
├── react-native-gesture-handler@1.0.12
├── react-native-git-upgrade@0.2.7
├── react-native-navigation@2.5.2
├── react-native-userdefaults-ios@0.1.3
├── react-navigation@3.0.9
├── react-redux@6.0.0
├── react-test-renderer@16.5.0
├── redux@4.0.1
├── redux-devtools@3.5.0
├── redux-devtools-extension@2.13.7
├── redux-logger@3.0.6
├── redux-persist@5.10.0
├── redux-thunk@2.3.0
├── remote-redux-devtools@0.5.16
├── schedule@0.4.0
└── updeep@1.1.0

我猜我的依赖关系是错误的,但不知道如何解决。

1 个答案:

答案 0 :(得分:6)

在./android/build.gradle中设置Java 8,并添加以下行

compileOptions {
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
}