2017-06-27 78 views
0

我,只要我进入elasticsearch依赖性得到这个错误,摇篮构建失败 - 复制文件在APK META-INF复制

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

,不建议直接使用ElasticSearch到Android应用程序添加下面的代码。这样做的缺点是:

  1. 任何人都可以反编译你的应用程序,让你的ElasticSearch实例REST API链接,并与您的indexes玩他们喜欢的方式,甚至修改或删除它们。 API链接必须公开可供用户访问。
  2. 将会有像这个问题一样的依赖冲突,在Android SDK dependenciesElasticSearch之间存在依赖关系。
  3. 如果要定制构建请求的方式,则必须为应用程序发布更新。

更好的解决方法是让自己的API来处理您的ElasticSearch实例的请求。在应用程序中,对该实例发出请求,然后该实例会对您的ElasticSearch实例发出请求。当有人点击您的API时,您可以获取搜索变量并构建您自己的查询。这种方法的优点是:

  1. 您的ElasticSearch链接可以是私人的,没有人可以删除您的索引。
  2. 当您想要修改查询的构建方式时,无需更新应用程序的代码。
  3. 您不会得到相关性冲突。
0

在Android的部分

packagingOptions { 
    pickFirst 'META-INF/*' 
} 
+1

此前我有1个错误,现在我有7个错误。 :d –

+0

尝试这个'机器人{ packagingOptions { PICKFIRST 'META-INF/INDEX.LIST' PICKFIRST 'META-INF/LICENSE' PICKFIRST 'META-INF/io.netty.versions.properties' } } ' –

0

This GitHub的问题票建议使用

packagingOptions { 
     pickFirst 'META-INF/INDEX.LIST' 
     pickFirst 'META-INF/LICENSE' 
     pickFirst 'META-INF/io.netty.versions.properties' 
    } 
+0

'错误:将字节码转换为dex时出错: 原因:Dex无法解析版本52字节码。 这是由使用Java 8或更高版本编译的库依赖项引起的。 如果您正在使用的库子模块中的Java“gradle这个插件添加 targetCompatibility =“1.7” sourceCompatibility =“1.7” 该子模块的的build.gradle file.' –

+0

你的一个依赖使用Java 8不受支持由android。如果你想保持这种依赖性,你必须升级到Android Studio 3.0以获得内置的Java 8支持。 –

+0

Android Studio 3.0中出现同样的错误 –