一旦我输入 elasticsearch 依赖关系
,我就会收到此错误 compile 'org.elasticsearch.client:transport:5.0.0'
详细错误logcat:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDevDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/io.netty.versions.properties
File1: C:\Users\Dell\.gradle\caches\modules-2\files-2.1\io.netty\netty-buffer\4.1.5.Final\b5fb6bccda4d63d4a74c9faccdf32f77ab66abc1\netty-buffer-4.1.5.Final.jar
File2: C:\Users\Dell\.gradle\caches\modules-2\files-2.1\io.netty\netty-handler\4.1.5.Final\6262900ee9487e62560030a136160df953b1cd6b\netty-handler-4.1.5.Final.jar
File3: C:\Users\Dell\.gradle\caches\modules-2\files-2.1\io.netty\netty-transport\4.1.5.Final\37126b370722ff9631ee13c91139aacec0a71d1d\netty-transport-4.1.5.Final.jar
File4: C:\Users\Dell\.gradle\caches\modules-2\files-2.1\io.netty\netty-codec-http\4.1.5.Final\87bda1b9ec7e3f75ca721fc87735cbedad2aa1a\netty-codec-http-4.1.5.Final.jar
File5: C:\Users\Dell\.gradle\caches\modules-2\files-2.1\io.netty\netty-resolver\4.1.5.Final\5f367bedcdc185a727fda3296b9a18014cdc22c4\netty-resolver-4.1.5.Final.jar
File6: C:\Users\Dell\.gradle\caches\modules-2\files-2.1\io.netty\netty-codec\4.1.5.Final\66bbf9324fa36467d041083f89328e2a24ec4f67\netty-codec-4.1.5.Final.jar
File7: C:\Users\Dell\.gradle\caches\modules-2\files-2.1\io.netty\netty-common\4.1.5.Final\607f8433d8782445e72abe34e43a7e57e86a5e6c\netty-common-4.1.5.Final.jar
Gradle文件:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "..."
minSdkVersion 18
targetSdkVersion 25
versionCode 6
versionName "20170616.06"
multiDexEnabled true
ndk {
abiFilter "armeabi-v7a"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// signingConfig signingConfigs.release
}
}
productFlavors {
dev {
applicationId "..."
minSdkVersion 21
}
prod {
applicationId "..."
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
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'
}
lintOptions {
abortOnError false
}
}
repositories {
jcenter()
maven { url "https://dl.bintray.com/drummer-aidan/maven" }
mavenCentral()
}
configurations {
compile.exclude group: "org.apache.httpcomponents", module: "httpclient"
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// https://mvnrepository.com/artifact/commons-io/commons-io
compile group: 'commons-io', name: 'commons-io', version: '2.4'
compile 'com.android.support:appcompat-v7:' + rootProject.ext.supportLibraryVersion
compile 'com.android.support:cardview-v7:' + rootProject.ext.supportLibraryVersion
compile 'com.android.support:recyclerview-v7:' + rootProject.ext.supportLibraryVersion
compile 'com.android.support:support-v4:' + rootProject.ext.supportLibraryVersion
compile 'com.android.support:design:' + rootProject.ext.supportLibraryVersion
compile 'com.android.support:percent:' + rootProject.ext.supportLibraryVersion
compile 'com.android.support:animated-vector-drawable:' + rootProject.ext.supportLibraryVersion
compile 'com.android.support:support-annotations:' + rootProject.ext.supportLibraryVersion
compile 'com.android.support:support-compat:' + rootProject.ext.supportLibraryVersion
compile 'com.android.support:support-core-ui:' + rootProject.ext.supportLibraryVersion
compile 'com.android.support:support-v13:' + rootProject.ext.supportLibraryVersion
compile 'com.android.support:support-v4:' + rootProject.ext.supportLibraryVersion'
compile 'com.google.firebase:firebase-storage:' + rootProject.ext.firebaseVersion
compile 'com.google.firebase:firebase-common:' + rootProject.ext.firebaseVersion
compile 'com.google.firebase:firebase-auth:' + rootProject.ext.firebaseVersion
compile 'com.google.firebase:firebase-database:' + rootProject.ext.firebaseVersion
compile 'com.google.firebase:firebase-crash:' + rootProject.ext.firebaseVersion
compile 'com.google.firebase:firebase-core:' + rootProject.ext.firebaseVersion
// this line must be included to integrate with Firebase
compile 'com.google.firebase:firebase-messaging:' + rootProject.ext.firebaseVersion
// this line must be included to use FCM
compile 'com.google.firebase:firebase-ads:' + rootProject.ext.firebaseVersion
compile 'com.google.android.gms:play-services-auth:' + rootProject.ext.firebaseVersion
compile 'com.google.android.gms:play-services-plus:' + rootProject.ext.firebaseVersion
compile 'com.google.android.gms:play-services-location:' + rootProject.ext.firebaseVersion
compile 'com.google.android.gms:play-services-places:' + rootProject.ext.firebaseVersion
compile "im.ene.toro2:toro-ext-exoplayer2:${toroVersion}"
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compile 'com.jakewharton:butterknife:' + rootProject.ext.butterknifeVersion
apt 'com.jakewharton:butterknife-compiler:' + rootProject.ext.butterknifeVersion
//RxAndroid
compile 'io.reactivex:rxandroid:' + rootProject.ext.rxandroidVersion
compile 'io.reactivex:rxjava:' + rootProject.ext.rxjavaVersion
compile 'com.squareup.retrofit2:adapter-rxjava:' + rootProject.ext.retroRxAdapterVersion
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.firebaseui:firebase-ui-database:0.4.0'
compile 'com.google.firebase:firebase-invites:10.2.1'
compile 'com.firebase:firebase-client-android:2.5.2+'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:multidex:1.0.1'
compile 'pub.devrel:easypermissions:0.1.5'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
compile 'com.danikula:videocache:2.6.4'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.dinuscxj:circleprogressbar:1.1.1'
compile 'com.afollestad.material-dialogs:core:0.9.4.5'
compile 'com.afollestad:easyvideoplayer:0.3.0'
compile 'com.googlecode.mp4parser:isoparser:1.1.22'
compile 'javax.inject:javax.inject:1'
compile 'com.google.firebase:firebase-storage:10.0.1'
testCompile 'junit:junit:4.12'
compile 'com.google.api-client:google-api-client:1.21.0'
compile 'com.google.apis:google-api-services-people:v1-rev2-1.21.0'
compile 'org.elasticsearch.client:transport:5.0.0'
compile project(':ffmpeg4android_lib')
}
apply plugin: 'com.google.gms.google-services'
PS:SO上已经有很多类似的帖子,但没有一个对我有帮助
有人可以帮我吗?另外,请告诉我解决这些问题的通用方法。
答案 0 :(得分:1)
在android部分添加以下代码
packagingOptions {
pickFirst 'META-INF/*'
}
答案 1 :(得分:0)
This github发行票据建议使用
packagingOptions {
pickFirst 'META-INF/INDEX.LIST'
pickFirst 'META-INF/LICENSE'
pickFirst 'META-INF/io.netty.versions.properties'
}
答案 2 :(得分:0)
不建议直接在android应用程序中使用ElasticSearch
。这样做的缺点是:
ElasticSearch
实例REST API
链接,并以您想要的方式使用indexes
,甚至修改或删除它们。用户可以公开访问API链接。Android SDK dependencies
和ElasticSearch
依赖关系之间会存在此问题之间的依赖冲突。 更好的解决方法是,制作自己的API来处理ElasticSearch
实例的请求。在App上,对该实例发出请求,该实例依次在您的ElasticSearch
实例上发出请求。当有人点击您的API时,您可以获取搜索变量并构建您自己的查询。这种方法的优点是:
ElasticSearch
链接可以是私有的,没有人可以删除您的索引。答案 3 :(得分:0)
别忘了放
packagingOptions {
pickFirst 'META-INF/*'
}
如果使用模块,则所有构建gradle文件。