Bootstrap 方法返回 null - Android 在启动时立即崩溃
Posted
技术标签:
【中文标题】Bootstrap 方法返回 null - Android 在启动时立即崩溃【英文标题】:Bootstrap method returned null - Android crash immediately on launch 【发布时间】:2019-06-10 22:52:19 【问题描述】: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】:在 ./android/build.gradle 中设置 Java 8 并添加这些行
compileOptions
sourceCompatibility = 1.8
targetCompatibility = 1.8
【讨论】:
男人!甘尼萨勋爵给你这个世界上的每一个幸福,我被困了 4 个小时。以上是关于Bootstrap 方法返回 null - Android 在启动时立即崩溃的主要内容,如果未能解决你的问题,请参考以下文章
选择下拉组合框在 codeigniter 和 bootstrap 上返回 null
isNull(NULL +" and"," on") 在 PHP MSSQL 中返回 "and"
在 AND 内具有多个 OR 条件的 SQL 查询返回 null 或空
日期 bootsrtap-datatimepicker and bootstrap-datepicker 控件支持中文