Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android crash on init() when using react-native-maps #576

Closed
red62labs opened this issue Jun 30, 2018 · 5 comments
Closed

Android crash on init() when using react-native-maps #576

red62labs opened this issue Jun 30, 2018 · 5 comments

Comments

@red62labs
Copy link

crashes immediately on calling init() on android while using react-native-maps also

"react-native-onesignal": "^3.2.5",
"react-native-maps": "^0.16.4",

android/build.gradle


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

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

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

android/app/build.gradle


buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal 
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.10.0, 0.99.99]'
    }
}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

apply plugin: "com.android.application"

import com.android.build.OutputFile


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

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"
   
    defaultConfig {
        applicationId "com.leads"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        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
            }
        }
    }
}

dependencies {
    compile project(':react-native-onesignal')
    compile project(':rn-fetch-blob')
    compile project(':react-native-image-picker')
    compile project(':react-native-vector-icons')
    //compile project(':react-native-maps')
    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 'com.google.android.gms:play-services-base:+'
  compile 'com.google.android.gms:play-services-maps:+'
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

@juliancorrea
Copy link

Same here.

@lcszulpo
Copy link

lcszulpo commented Jul 1, 2018

In my case, the error that I caught in logcat is this:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbq;
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:2)
at android.app.ActivityThread.installProvider(ActivityThread.java:6285)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5851)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5772)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbq" on path: DexPathList[[zip file "/data/app/<applicationId>-6gwkTImqSL8afZp13N80wA==/base.apk"],nativeLibraryDirectories=[/data/app/<applicationId>-6gwkTImqSL8afZp13N80wA==/lib/x86, /data/app/<applicationId>-6gwkTImqSL8afZp13N80wA==/base.apk!/lib/x86, /system/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 12 more

@red62labs
Copy link
Author

I get this error

06-30 23:07:07.370 10872 10956 E AndroidRuntime: FATAL EXCEPTION: pool-7-thread-1
06-30 23:07:07.370 10872 10956 E AndroidRuntime: Process: com.leads, PID: 10872
06-30 23:07:07.370 10872 10956 E AndroidRuntime: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.leads. Make sure to call FirebaseApp.initializeApp(Context) first.
06-30 23:07:07.370 10872 10956 E AndroidRuntime: 	at com.google.firebase.FirebaseApp.getInstance(Unknown Source:60)
06-30 23:07:07.370 10872 10956 E AndroidRuntime: 	at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source:0)
06-30 23:07:07.370 10872 10956 E AndroidRuntime: 	at com.google.firebase.iid.FirebaseInstanceIdService.zza(Unknown Source:19)
06-30 23:07:07.370 10872 10956 E AndroidRuntime: 	at com.google.firebase.iid.FirebaseInstanceIdService.handleIntent(Unknown Source:158)
06-30 23:07:07.370 10872 10956 E AndroidRuntime: 	at com.google.firebase.iid.zzc.run(Unknown Source:4)
06-30 23:07:07.370 10872 10956 E AndroidRuntime: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
06-30 23:07:07.370 10872 10956 E AndroidRuntime: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
06-30 23:07:07.370 10872 10956 E AndroidRuntime: 	at java.lang.Thread.run(Thread.java:764)
06-30 23:07:07.374  1109  2307 W ActivityManager:   Force finishing activity com.leads/.MainActivity
06-30 23:07:07.381  1109  1155 I ActivityManager: Showing crash dialog for package com.leads u0

@red62labs
Copy link
Author

red62labs commented Jul 1, 2018

#515
fixed my issue all working now

@lcszulpo
Copy link

lcszulpo commented Jul 1, 2018

in my case I fixed the problem as follow:

implementation ('com.google.android.gms:play-services-base:12.0.1') {
    force = true
}
implementation ('com.google.android.gms:play-services-ads:12.0.1') {
    force = true
}
implementation ('com.google.android.gms:play-services-gcm:12.0.1') {
    force = true
}
implementation ('com.google.android.gms:play-services-analytics:12.0.1') {
    force = true
}
implementation ('com.google.android.gms:play-services-location:12.0.1') {
    force = true
}
implementation ('com.google.android.gms:play-services-maps:12.0.1') {
    force = true
}

So, I just forced the version of com.google.android.gms:play-services-x to 12.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants