react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

Crash on android launch NoClassDefFoundError

Open sarykemmoun opened this issue 8 years ago • 1 comments

Hello. I've upgraded your library to the latest version and I get a crash when launching the app. Caused by java.lang.ClassNotFoundException Didn't find class "com.google.android.gms.location.ActivityRecognitionResult" on path: DexPathList[[zip file "/data/app/com.xxx-2/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx-2/lib/arm, /data/app/com.xxx-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]] I saw a similar issue that you wrote that it caused by a too low version on googlePlayServicesVersion. In my case, the version is 15.0.0 and up so it isn't the issue. (Actually, I use react-native-background-geolocation-android. But I don't see this library now) my android/app/buid.gradle is:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: "com.android.application"
apply plugin: 'io.fabric'
    repositories {
    maven { url 'https://maven.fabric.io/public' }
    }

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        applicationId "com.closapp"
        minSdkVersion 19
        multiDexEnabled true
        targetSdkVersion 26
        versionCode 20
        versionName "1.0.12"
        vectorDrawables.useSupportLibrary = true

        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

    signingConfigs {
        release {
            storeFile file("XXX.keystore")
            keyAlias "XXX"
            storePassword '$8ypB44+,88{;2w.7]7}73.Awve   7111 bkFb('
            keyPassword '$8ypB44+,88{;2w.7]7}73.Awve   7111 bkFb('
        }
    }
    dexOptions {
      jumboMode true
    }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

repositories {
    flatDir {
        dirs "../../node_modules/react-native-background-geolocation-android/android/libs"
    }
}

dependencies {
    compile project(':react-native-background-fetch')
    compile project(':react-native-fabric')
    compile project(':react-native-image-crop-picker')
    compile project(':react-native-android-location-services-dialog-box')
    compile project(':react-native-i18n')
    
    compile(project(':react-native-maps')){
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }
    compile(project(':react-native-background-geolocation-android')) {
        exclude group: 'com.squareup.okhttp3'
    }
    compile ('com.squareup.okhttp3:okhttp:3.4.1') 
    compile project(':react-native-fetch-blob')
    compile project(':react-native-vector-icons')
    
    compile project(':react-native-fcm')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:26.1.0"
    compile "com.google.firebase:firebase-core:15.0.2"
    compile 'com.google.firebase:firebase-messaging:15.0.2'
    compile 'com.google.android.gms:play-services-maps:15.0.0'
    compile 'com.google.android.gms:play-services-base:15.0.0'
    compile ("com.google.android.gms:play-services-maps:15.0.0") {
        force = true;
    } 
    compile "com.google.android.gms:play-services-gcm:15.0.0"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile 'com.facebook.fresco:animated-gif:1.0.1'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
     transitive = true;
    }
}


task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
apply plugin: "com.google.gms.google-services"

My android/build.grade:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
                google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.0.0'
        
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

Thanks!

sarykemmoun avatar Jun 17 '18 08:06 sarykemmoun

Duplicate #504. Post your info there.

christocracy avatar Jun 17 '18 08:06 christocracy