0

After I've installed react-native-maps package, despite the build is successful, application just stoped work with an exception. Tested on real devices: Samsung s9, Samsung s7, Huawei Honor 9. Android 7, 8. I happens on both: dev and release mode, And it happens only if you have installed GoogleFit app on your phone.

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]]

my 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+"
    }

and my 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:+"
}

I Didn't find any issue similar to this one. Probably the trouble may be in different required google-play-services versions, but I don't know exactly, how to solve this.

korgara
  • 359
  • 2
  • 6
  • This [SO post](https://stackoverflow.com/questions/47393625/google-fit-android-plug-in-for-unity3d/47394038#47394038) could be a help for your problem since you have the same error as this one. It was suggested there to run [proguard](https://developer.android.com/studio/build/shrink-code.html) on your library, add `minifyEnabled` `true` to the appropriate build type in your `build.gradle file`. Also another suggestion is the [implementation](https://stackoverflow.com/questions/44493378/whats-the-difference-between-implementation-and-compile-in-gradle) setting for your fit dependency. – MαπμQμαπkγVπ.0 Sep 11 '18 at 11:22
  • @MαπμQμαπkγVπ.0 thanks for comment i resolve my issue after disable proguard. – Lalit kumar Mar 27 '19 at 11:40

0 Answers0