gpt4 book ai didi

android - 为 Android 构建 react-native-firebase 时的依赖冲突(多个 dex 文件定义 Lcom/google/firebase/iid/zzb$1)

转载 作者:行者123 更新时间:2023-11-29 16:59:18 26 4
gpt4 key购买 nike

我正在尝试为 android 构建 react-native firebase,并在构建时不断出错 https://github.com/invertase/react-native-firebase/blob/master/docs/installation.android.md

这里是错误

Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/firebase/iid/zzb$1;

我检查了 gradle app:dependencies 并看到 com.google.firebase:firebase-corecom.google.android.gms:play-services -base 被添加为版本 10.2.110.2.0react-native-push-notificationplay-services 添加版本 10.2.1。我认为这可能是原因,这是依赖项的输出

+--- project :react-native-firebase
| +--- com.android.support:multidex:1.0.1
| +--- com.facebook.react:react-native:+ -> 0.42.0 (*)
| +--- me.leolin:ShortcutBadger:1.1.10
| +--- com.google.android.gms:play-services-base:10.2.0 -> 10.2.1
| | +--- com.google.android.gms:play-services-basement:10.2.1
| | | \--- com.android.support:support-v4:24.0.0 -> 25.0.0 (*)
| | \--- com.google.android.gms:play-services-tasks:10.2.1
| | \--- com.google.android.gms:play-services-basement:10.2.1 (*)
| +--- com.google.firebase:firebase-core:10.2.0
| | \--- com.google.firebase:firebase-analytics:10.2.0
| | +--- com.google.android.gms:play-services-basement:10.2.0 -> 10.2.1 (*)
| | +--- com.google.firebase:firebase-common:10.2.0
| | | +--- com.google.android.gms:play-services-basement:10.2.0 -> 10.2.1 (*)
| | | \--- com.google.android.gms:play-services-tasks:10.2.0 -> 10.2.1 (*)
| | \--- com.google.firebase:firebase-analytics-impl:10.2.0
| | +--- com.google.android.gms:play-services-basement:10.2.0 -> 10.2.1 (*)
| | +--- com.google.firebase:firebase-iid:10.2.0
| | | +--- com.google.android.gms:play-services-basement:10.2.0 -> 10.2.1 (*)
| | | \--- com.google.firebase:firebase-common:10.2.0 (*)
| | +--- com.google.firebase:firebase-common:10.2.0 (*)
| | \--- com.google.android.gms:play-services-tasks:10.2.0 -> 10.2.1 (*)
| +--- com.google.firebase:firebase-config:10.2.0
| | +--- com.google.android.gms:play-services-base:10.2.0 -> 10.2.1 (*)
| | +--- com.google.android.gms:play-services-basement:10.2.0 -> 10.2.1 (*)
| | +--- com.google.firebase:firebase-iid:10.2.0 (*)
| | +--- com.google.firebase:firebase-common:10.2.0 (*)
| | \--- com.google.android.gms:play-services-tasks:10.2.0 -> 10.2.1 (*)
| +--- com.google.firebase:firebase-auth:10.2.0
| | +--- com.google.android.gms:play-services-base:10.2.0 -> 10.2.1 (*)
| | +--- com.google.android.gms:play-services-basement:10.2.0 -> 10.2.1 (*)
| | +--- com.google.firebase:firebase-common:10.2.0 (*)
| | \--- com.google.android.gms:play-services-tasks:10.2.0 -> 10.2.1 (*)
| +--- com.google.firebase:firebase-analytics:10.2.0 (*)
| +--- com.google.firebase:firebase-database:10.2.0
| | +--- com.google.android.gms:play-services-basement:10.2.0 -> 10.2.1 (*)
| | +--- com.google.firebase:firebase-database-connection:10.2.0
| | | +--- com.google.android.gms:play-services-basement:10.2.0 -> 10.2.1 (*)
| | | \--- com.google.firebase:firebase-common:10.2.0 (*)
| | +--- com.google.firebase:firebase-common:10.2.0 (*)
| | \--- com.google.android.gms:play-services-tasks:10.2.0 -> 10.2.1 (*)
| +--- com.google.firebase:firebase-storage:10.2.0
| | +--- com.google.android.gms:play-services-basement:10.2.0 -> 10.2.1 (*)
| | +--- com.google.firebase:firebase-storage-common:10.2.0
| | | \--- com.google.android.gms:play-services-basement:10.2.0 -> 10.2.1 (*)
| | +--- com.google.firebase:firebase-common:10.2.0 (*)
| | \--- com.google.android.gms:play-services-tasks:10.2.0 -> 10.2.1 (*)
| +--- com.google.firebase:firebase-messaging:10.2.0
| | +--- com.google.android.gms:play-services-basement:10.2.0 -> 10.2.1 (*)
| | +--- com.google.firebase:firebase-iid:10.2.0 (*)
| | \--- com.google.firebase:firebase-common:10.2.0 (*)
| \--- com.google.firebase:firebase-crash:10.2.0
| +--- com.google.android.gms:play-services-basement:10.2.0 -> 10.2.1 (*)
| +--- com.google.firebase:firebase-iid:10.2.0 (*)
| +--- com.google.firebase:firebase-common:10.2.0 (*)
| \--- com.google.firebase:firebase-analytics:10.2.0 (*)
+--- com.google.firebase:firebase-core:10.2.0 (*)
+--- com.google.android.gms:play-services-base:10.2.0 -> 10.2.1 (*)
+--- project :bugsnag-react-native
| +--- com.bugsnag:bugsnag-android:3.7.2
| | \--- com.android.support:support-annotations:23.1.1 -> 25.0.0
| \--- com.facebook.react:react-native:+ -> 0.42.0 (*)
+--- project :react-native-push-notification
| +--- com.android.support:appcompat-v7:23.1.1 -> 25.0.0 (*)
| +--- com.facebook.react:react-native:+ -> 0.42.0 (*)
| +--- com.google.android.gms:play-services-gcm:+ -> 10.2.1
| | +--- com.google.android.gms:play-services-base:10.2.1 (*)
| | +--- com.google.android.gms:play-services-basement:10.2.1 (*)
| | \--- com.google.android.gms:play-services-iid:10.2.1
| | +--- com.google.android.gms:play-services-base:10.2.1 (*)
| | \--- com.google.android.gms:play-services-basement:10.2.1 (*)
| \--- me.leolin:ShortcutBadger:1.1.8 -> 1.1.10
+--- project :react-native-vector-icons
| \--- com.facebook.react:react-native:+ -> 0.42.0 (*)
+--- com.android.support:appcompat-v7:23.0.1 -> 25.0.0 (*)
\--- com.facebook.react:react-native:+ -> 0.42.0 (*)

我的顶级build.gradle

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.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()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}

我的应用 build.gradle

dependencies {
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile project(':react-native-fbsdk')
compile project(':react-native-firebase')
compile 'com.google.firebase:firebase-core:10.2.0'
compile project(':bugsnag-react-native')
compile project(':react-native-push-notification')
compile project(':react-native-vector-icons')
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'
}

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

以下是对我有用的依赖项

dependencies {
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile project(':react-native-fbsdk')
compile project(':react-native-firebase')
compile project(':bugsnag-react-native')
compile project(':react-native-push-notification')
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-config:10.2.1'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.google.firebase:firebase-storage:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.google.firebase:firebase-crash:10.2.1'
}

最佳答案

我相信您通过“firebase-core”和“:react-native-firebase”两次添加它:

dependencies {
// compile 'com.google.firebase:firebase-core:10.2.0' <- try removing this, "firebase-core" is already in ":react-native-firebase"
// compile fileTree(dir: "libs", include: ["*.jar"]) <- try not to add jars
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+"
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile project(':bugsnag-react-native')
compile project(':react-native-fbsdk')
compile project(':react-native-firebase')
compile project(':react-native-push-notification')
compile project(':react-native-vector-icons')
}

关于android - 为 Android 构建 react-native-firebase 时的依赖冲突(多个 dex 文件定义 Lcom/google/firebase/iid/zzb$1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43536529/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com