react-native-maps + react-native-firebase Android应用在启动时崩溃

时间:2018-11-14 17:31:19

标签: android firebase react-native maps react-native-android

我在使用react-native-firebase + react-native-maps运行我的应用程序时遇到麻烦。

该应用在Android上启动时崩溃,而在iOS中则完美运行,没有任何问题。

环境:

  

OS:macOS Mojave 10.14.1   React Native:0.57.4   react-native-maps:0.22.1   react-native-firebase:5.1.0

我最喜欢的build.gradle是:

buildscript {
repositories {
    google()
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
    jcenter()
}
dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
    classpath 'com.android.tools.build:gradle:3.2.0'
    classpath 'com.google.gms:google-services:4.0.1'
}
}

allprojects {
buildDir = "$rootDir/build/${rootProject.name}/${project.name}"
repositories {
    google()
    mavenLocal()
    maven { url 'https://maven.google.com' }

    maven {
        url "$rootDir/../node_modules/react-native/android"
    }
    maven { url 'https://maven.fabric.io/public' }
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }     
    jcenter()
}
}

我的应用程序build.gradle是:

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
    applicationId "py.com.kynox.pelotajara"
    minSdkVersion 16
    targetSdkVersion 27
    versionCode 138
    versionName "1.3.8"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
    multiDexEnabled true
}
signingConfigs {
    release {
        if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
            storeFile file(MYAPP_RELEASE_STORE_FILE)
            storePassword MYAPP_RELEASE_STORE_PASSWORD
            keyAlias MYAPP_RELEASE_KEY_ALIAS
            keyPassword MYAPP_RELEASE_KEY_PASSWORD
        }
    }
}
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"
        signingConfig signingConfigs.release
    }

}
// 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
        }
    }
}
dexOptions {
    dexInProcess = false
}
flavorDimensions "devStages"

productFlavors {
    dev {
        applicationIdSuffix ".dev"
        versionNameSuffix "-dev"
        println "Using Dev google-service.json"
        copy {
            from 'src/dev/'
            include '*.json'
            into '.'
        }
        copy {
            from 'src/dev/'
            into 'src/main/'
            include 'res/**'
        }
        dimension "devStages"

    }
    prod {
        applicationIdSuffix ""
        versionNameSuffix ""
        println "Using Production google-service.json"
        copy {
            from 'src/prod/'
            include '*.json'
            into '.'
        }
        copy {
            from 'src/prod/'
            into 'src/main/'
            include 'res/**'
        }
        dimension "devStages"
    }
    staging {
        applicationIdSuffix ".staging"
        versionNameSuffix "-staging"
        println "Using Staging google-service.json"
        copy {
            from 'src/staging/'
            include '*.json'
            into '.'
        }
        copy {
            from 'src/staging/'
            into 'src/main/'
            include 'res/**'
        }
        dimension "devStages"
    }
}
}


dependencies {
/* PLAY SERVICES */
 implementation "com.google.android.gms:play-services-base:16.0.1"

/* FIREBASE */
implementation project(':react-native-firebase')
implementation "com.google.firebase:firebase-core:16.0.4"
implementation "com.google.firebase:firebase-messaging:17.3.4"
implementation "com.google.firebase:firebase-invites:16.0.4"
implementation "com.google.firebase:firebase-config:16.1.0"

/* RN AND OTHER LIBRARIES*/
implementation 'com.facebook.react:react-native:+'
implementation project(':lottie-react-native')
implementation project(':react-native-view-shot')
implementation project(':react-native-share')
implementation project(':react-native-vector-icons')
implementation(project(':react-native-maps')){
    exclude group: 'com.google.android.gms'
}
implementation project(':react-native-linear-gradient')
implementation project(':react-native-fabric')
implementation('com.crashlytics.sdk.android:crashlytics:2.6.3@aar') {
    transitive = true;
}
implementation(project(':react-native-fbsdk')) {
    exclude(group: 'com.facebook.android', module: 'facebook-android-     sdk')
}
implementation 'com.facebook.android:facebook-android-sdk:4.31.0'
implementation ("com.google.android.gms:play-services-maps:+") {
    force = true;
}
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:multidex:1.0.1'
implementation fileTree(include: ['*.jar'], dir: 'libs')


}

task copyDownloadableDepsToLibs(type: Copy) {
 from configurations.compile
 into 'libs'
}

apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

应用在启动时崩溃,logcat引发此错误:

java.lang.NoClassDefFoundError: Failed resolution of:     Lcom/google/android/gms/maps/GoogleMapOptions;

有人能使这两个一起工作吗?

0 个答案:

没有答案