2016-11-12 8 views
2

私は、クラスファイルを除外したり、jarファイルの依存関係のクラスに対してpickfirstを使用することができるかどうかを調べようとしています。我々は常に代わりにGradleの依存関係を使用してのAARファイルにサードパーティ製のlibsパッケージまで、ジャーを問題に実行するように見えるので、重複したファイルのzipの例外を引き起こす:android gradleのpackagingOptionsでクラスを除外できますか?

次のように:

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/commons/codec/StringEncoderComparator.class 

私たちがきた唯一のソリューションこれまでにaarを解凍し、問題のjarファイルを削除し、それを元に戻すことです。それでは、jarやクラスをgradleから除外する方法はありますか?

ソースを見ると、私はパッケージオプションを使用できるはずです。だから私は最初にピックと除外の様々な組み合わせを試みたが、運はない:

packagingOptions { 
    pickFirst '**/StringEncoderComparator.class' 
    pickFirst 'org/apache/commons/codec/StringEncoderComparator.class' 
    pickFirst 'org/apache/commons/codec/*' 

} 
+0

こんにちは、私はまた、この上の任意のニュースを立ち往生していますか? – elect

+0

いいえ、方法を見つけたことはありませんでした。 – CaptRespect

+0

Javaファイルを除外する方法は? –

答えて

0

解像度を使用しています。

https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html

apply plugin: 'java' //so that there are some configurations 

configurations.all { 
    resolutionStrategy { 
    // fail eagerly on version conflict (includes transitive dependencies) 
    // e.g. multiple different versions of the same dependency (group and name are equal) 
    failOnVersionConflict() 

    // prefer modules that are part of this build (multi-project or composite build) over external modules 
    preferProjectModules() 

    // force certain versions of dependencies (including transitive) 
    // *append new forced modules: 
    force 'asm:asm-all:3.3.1', 'commons-io:commons-io:1.4' 
    // *replace existing forced modules with new ones: 
    forcedModules = ['asm:asm-all:3.3.1'] 

    // add dependency substitution rules 
    dependencySubstitution { 
     substitute module('org.gradle:api') with project(':api') 
     substitute project(':util') with module('org.gradle:util:3.0') 
    } 

    // cache dynamic versions for 10 minutes 
    cacheDynamicVersionsFor 10*60, 'seconds' 
    // don't cache changing modules at all 
    cacheChangingModulesFor 0, 'seconds' 
    } 
} 
関連する問題