我尝试将我的应用程序连接到firebase数据库,以便从使用recyclerview和cardview显示的firebase接收数据列表,但添加依赖项时有很多错误 运行app时出现此错误。
第一个错误 -
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/firebase/iid/zzc.class
这是我的应用程序构建gradle
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.seu.hh.mm"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.firebase:firebase-client-android:2.4.0'
compile 'com.google.firebase:firebase-crash:10.0.1'
compile 'com.google.firebase:firebase-storage:10.0.1'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:cardview-v7:23.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:support-v4:23.0.0'
compile 'com.firebaseui:firebase-ui-database:2.1.1'
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
apply plugin: 'com.google.gms.google-services'
这是我的构建gradle项目
allprojects {
repositories {
maven {
url "https://maven.google.com"
}
jcenter()
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
请帮帮我:(
如何解决这个问题并让app运行
答案 0 :(得分:0)
您正在将compile 'com.firebaseui:firebase-ui-database:2.1.1'
与compile 'com.google.firebase:firebase-database:10.0.1'
混合在一起,这就是您复制的原因。
首先,您需要删除这行代码:
compile 'com.firebaseui:firebase-ui-database:2.1.1'
更改以下代码行:
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-crash:10.0.1'
compile 'com.google.firebase:firebase-storage:10.0.1'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:cardview-v7:23.0.0'
与
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.firebase:firebase-core:11.0.1'
compile 'com.google.firebase:firebase-database:11.0.1'
compile 'com.google.firebase:firebase-crash:11.0.1'
compile 'com.google.firebase:firebase-storage:11.0.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
通过这种方式,您将拥有lates版本。