gpt4 book ai didi

android - 安装Firebase和 map 后,应对 native fatal error 和应用程序崩溃

转载 作者:行者123 更新时间:2023-12-03 03:46:41 29 4
gpt4 key购买 nike

我正在创建一个简单的应用程序,它将使用react-native-firebase和react-native-maps。按照安装文档的说明,我已经启动并运行了 map ,没有任何问题。接下来,我已经安装了Firebase,并且还遵循了该教程。我在途中遇到了一些错误,但是清理gradle build等最终使我得到了“build success”的信息。但是,该应用在启动时始终崩溃。 Android Studio的logcat指出了此错误:

 FATAL EXCEPTION: create_react_context
Process: com.demoapp, PID: 13267
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zzbfm;
at com.airbnb.android.react.maps.MapsPackage.createViewManagers(MapsPackage.java:39)
at com.facebook.react.ReactInstanceManager.getOrCreateViewManagers(ReactInstanceManager.java:770)
at com.facebook.react.CoreModulesPackage.createUIManager(CoreModulesPackage.java:170)
at com.facebook.react.CoreModulesPackage.access$200(CoreModulesPackage.java:53)
at com.facebook.react.CoreModulesPackage$7.get(CoreModulesPackage.java:128)
at com.facebook.react.CoreModulesPackage$7.get(CoreModulesPackage.java:125)
at com.facebook.react.LazyReactPackage$2$1.next(LazyReactPackage.java:102)
at com.facebook.react.LazyReactPackage$2$1.next(LazyReactPackage.java:89)
at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:44)
at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1212)
at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1182)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1120)
at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:123)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:943)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.internal.zzbfm" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.demoapp-0Fn4BfYJM0KChb969SjTxA==/base.apk"],nativeLibraryDirectories=[/data/app/com.demoapp-0Fn4BfYJM0KChb969SjTxA==/lib/x86, /data/app/com.demoapp-0Fn4BfYJM0KChb969SjTxA==/base.apk!/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)

这是我的build.gradle
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 27
supportLibVersion = "28.0.0"
googlePlayServicesVersion = "11.8.0"
androidMapsUtilsVersion = "0.5+"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}

}

allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}



task wrapper(type: Wrapper) {
gradleVersion = '4.7'
distributionUrl = distributionUrl.replace("bin", "all")
}

apply plugin: 'com.google.gms.google-services'

如果有必要,这也是我的package-json文件,其中包含我正在使用的所有版本的库:
{
"name": "DemoApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.6.3",
"react-native": "0.58.4",
"react-native-firebase": "^5.2.2",
"react-native-gesture-handler": "^1.0.15",
"react-native-maps": "^0.23.0",
"react-navigation": "^3.2.1"
},
"devDependencies": {
"babel-core": "7.0.0-bridge.0",
"babel-jest": "24.1.0",
"jest": "24.1.0",
"metro-react-native-babel-preset": "0.51.1",
"react-test-renderer": "16.6.3"
},
"jest": {
"preset": "react-native"
}
}

任何帮助,将不胜感激! Google Play服务版本是否错误?是什么导致此问题?

编辑:添加multidex后的完整错误日志。设备已连接,从cmd运行adb设备后即可看到它。
    Building and installing the app on the device (cd android && gradlew.bat installDebug)...

> Configure project :
Warning: Please apply google-services plugin at the bottom of the build file.

> Configure project :react-native-firebase
react-native-firebase: using React Native prebuilt binary from C:\workspace\copleybros\DemoApp\node_modules\react-native\android

> Task :app:compileDebugJavaWithJavac
C:\workspace\copleybros\DemoApp\android\app\src\main\java\com\demoapp\MainApplication.java:4: error: cannot find symbol
import android.app.MultiDexApplication;
^
symbol: class MultiDexApplication
location: package android.app
C:\workspace\copleybros\DemoApp\android\app\src\main\java\com\demoapp\MainApplication.java:17: error: cannot find symbo
public class MainApplication extends MultiDexApplication implements ReactApplication {
^
symbol: class MultiDexApplication
C:\workspace\copleybros\DemoApp\android\app\src\main\java\com\demoapp\MainApplication.java:19: error: incompatible types: MainApplication cannot be converted to Application
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
^
C:\workspace\copleybros\DemoApp\android\app\src\main\java\com\demoapp\MainApplication.java:19: error: cannot find symbol private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
^
symbol: constructor (MainApplication)
C:\workspace\copleybros\DemoApp\android\app\src\main\java\com\demoapp\MainApplication.java:46: error: method does not override or implement a method from a supertype
@Override
^
C:\workspace\copleybros\DemoApp\android\app\src\main\java\com\demoapp\MainApplication.java:48: error: cannot find symbol super.onCreate();
^
symbol: variable super
location: class MainApplication
C:\workspace\copleybros\DemoApp\android\app\src\main\java\com\demoapp\MainApplication.java:49: error: no suitable method found for init(MainApplication,boolean)
SoLoader.init(this, /* native exopackage */ false);
^
method SoLoader.init(Context,int) is not applicable
(argument mismatch; MainApplication cannot be converted to Context)
method SoLoader.init(Context,boolean) is not applicable
(argument mismatch; MainApplication cannot be converted to Context)
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
7 errors


> Task :app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 9s
48 actionable tasks: 1 executed, 47 up-to-date
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

Command failed: gradlew.bat installDebug

Error: Command failed: gradlew.bat installDebug
at checkExecSyncError (child_process.js:601:13)
at Object.execFileSync (child_process.js:621:13)
at runOnAllDevices (C:\workspace\copleybros\DemoApp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
at buildAndRun (C:\workspace\copleybros\DemoApp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12) at isPackagerRunning.then.result (C:\workspace\copleybros\DemoApp\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)

最佳答案

由于Android X,React Native和Flutter中的大多数开发人员都面临着问题。您可以通过这个https://developer.android.com/jetpack/androidx/migrate

或者您可以使用库并构建与27而不是28相关的工具版本。

关于android - 安装Firebase和 map 后,应对 native fatal error 和应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54782056/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com