首页 > 解决方案 > React 本机项目未在 android 上启动

问题描述

java.lang.NoSuchMethodError:Lcom/google/android/gms/common/internal/Preconditions 类中没有静态方法 checkHandlerThread(Landroid/os/Handler;Ljava/lang/String;)V;或其超类(“com.google.android.gms.common.internal.Preconditions”的声明出现在 com.google 的 /data/app/tv.ampz-xq0syKD7zk1lwewrOmiHaw==/base.apk!classes35.dex 中)。 android.gms.common.internal.GmsClientEventManager.onConnectionSuccess(Unknown Source:20) at com.google.android.gms.common.api.internal.zaaw.zab(Unknown Source:292) at com.google.android.gms。 common.api.internal.zaak.zaaq(Unknown Source:125) at com.google.android.gms.common.api.internal.zaak.onConnected(Unknown Source:105) at com.google.android.gms.common。 com.google 上的 api.internal.zabe.onConnected(未知来源:101)。

我的应用程序/build.gradle

compile project(':react-native-maps')
compile project(':react-native-camera')
compile project(':react-native-linear-gradient')
compile project(':react-native-push-notification')
implementation (project(':react-native-camera')) {
  implementation "com.android.support:appcompat-v7:26.1.0"
  implementation "com.facebook.react:react-native:+"  
}
implementation(project(':react-native-maps')){
   exclude group: 'com.google.android.gms', module: 'play-services-base'
   exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation ("com.google.android.gms:play-services-basement:${rootProject.ext.googleFirebaseVersion}") {
    force = true
}
implementation "com.google.android.gms:play-services-location:${rootProject.ext.googlePlayServicesVersion}" 
implementation "com.google.android.gms:play-services-base:${rootProject.ext.googlePlayServicesVersion}"
implementation "com.google.android.gms:play-services-maps:${rootProject.ext.googlePlayServicesVersion}"
implementation "com.google.firebase:firebase-core:${rootProject.ext.googleFirebaseVersion}"
compile project(':instabug-reactnative')
compile project(':react-native-video')
compile project(':react-native-svg')
compile project(':react-native-picker')
compile project(':react-native-image-crop-picker')
compile project(':react-native-google-places')
compile project(':react-native-fast-image')
compile project(':react-native-exit-app')
compile project(':react-native-device-info')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" 

标签: androidreact-nativereact-native-androidgoogle-play-services

解决方案


您必须在标签中添加resolutionStrategy到您的 app/build.gradleandroid

android {
....
configurations.all {
            resolutionStrategy {
                force "com.google.android.gms:play-services-basement:16.2.0"
            }
        }

...
}

推荐阅读