java.lang.RuntimeException:无法调用RNGoogleFit.authorize

时间:2018-09-10 10:27:23

标签: java android google-maps react-native-android google-fit

我安装了react-native-maps程序包后,尽管构建成功,但应用程序只是停止了工作,但出现了异常。 在真实设备上测试:Samsung s9,Samsung s7,Huawei Honor 9,Android 7、8。 我在开发和发布模式上都遇到过这种情况,而且只有在手机上安装了GoogleFit应用程序时,这种情况才会发生。

java.lang.RuntimeException: Could not invoke RNGoogleFit.authorize
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.fitness.request.OnDataPointListener" on path: DexPathList[[zip file "/data/app/com.myapp-zNOyxL_4OhdJigH7nWT8oA==/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp-zNOyxL_4OhdJigH7nWT8oA==/lib/arm, /data/app/com.myapp-zNOyxL_4OhdJigH7nWT8oA==/base.apk!/lib/armeabi-v7a, /system/lib, /system/vendor/lib]]

我的android/build.gradle

   buildscript {
        repositories {
            jcenter()
            google()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.2'
        }
    }

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

    subprojects {
        afterEvaluate {project ->
            if (project.hasProperty("android")) {
                android {
                    compileSdkVersion 27
                    buildToolsVersion "27.0.3"
                }
            }
        }
    }

    ext {
        buildToolsVersion = "26.0.3"
        minSdkVersion = 16
        compileSdkVersion = 26
        targetSdkVersion = 26
        supportLibVersion = "27+"
    }

和我的android/app/build.gralde

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.myapp"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        multiDexEnabled = true
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

buildscript {
  repositories {
    maven { url 'https://maven.fabric.io/public' }
  }
  dependencies {
    // The Fabric Gradle plugin uses an open ended version to react
    // quickly to Android tooling updates
    classpath 'io.fabric.tools:gradle:1.+'
  }
}

apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    compile project(':react-native-check-app-install')
    compile (project(':react-native-camera')) {
        exclude group: "com.google.android.gms"
        exclude group: "com.android.support"
    }
    compile project(':react-native-fabric')
    compile project(':react-native-picker')
    compile project(':react-native-image-sequence')
    compile project(':react-native-google-fit')
    compile project(':react-native-webview-android')
    compile 'com.android.support:multidex:1.0.0'
    compile project(':react-native-vector-icons')
    compile project(':react-native-i18n')
    compile project(':react-native-pdf')
    compile project(':react-native-fetch-blob')
    compile project(':react-native-svg')
    compile project(':react-native-splash-screen')
    compile(project(':react-native-device-info')) {
        exclude group: 'com.google.android.gms'
    }
    compile project(':react-native-maps')

    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
        transitive = true;
    }

    compile "com.google.android.gms:play-services-base:+"
    compile "com.google.android.gms:play-services-maps:+"
}

我没有发现任何与此类似的问题。 麻烦可能出在不同的必需google-play-services版本中,但我不知道确切如何解决。

0 个答案:

没有答案