簡體   English   中英

如何從gradle的sdk中排除jar

[英]how to exclude a jar from an sdk in gradle

嗨,大家好,我正在嘗試從此vungle sdk compile 'com.admost.sdk:vungle:5.3.0'刪除一個jar庫,這是sdk中的常見庫,我正在使用這些庫導致dagger-2.7gson-2.7rxjava-1.2.0我嘗試了所有發現都無效的方法。 構建項目時出現的錯誤是

錯誤:任務':app:transformClassesWithMultidexlistForStagingDebug'的執行失敗。 java.io.IOException:無法編寫[D:\\ Geeky \\ Work \\ UFL \\ UFL-Android \\ app \\ build \\ intermediates \\ multi-dex \\ staging \\ debug \\ componentClasses.jar](無法讀取[C: \\ Users \\ bisho.gradle \\ caches \\ transforms-1 \\ files-1.1 \\ vungle-5.3.0.aar \\ b93710fa3315099ee82cab738c995134 \\ jars \\ libs \\ dagger-2.7.jar(;;;;;; **。class)]]重復的zip條目[dagger-2.7.jar:dagger / Reusable.class]))

在左窗格窗口中選擇Project而不是android。 參見下圖。

如果不使用,請刪除罐子。 也從gradle中刪除引用。 它應該工作。

在此處輸入圖片說明

You can build this sdk like below example:


    compile("com.github.vungle:vungle-android-sdk:5.3.0") {
            exclude group: 'com.google.dagger', module: 'dagger'
            exclude group: 'com.google.code.gson', module: 'gson'   
            exclude group: 'io.reactivex.rxjava2', module: 'rxjava'
    }
**To find duplicate dependencies or its required dependencies, you can visualize library dependencies in tree. Execute gradle command as below.**

run gradlew in Windows as below. 
**gradlew -q dependencies yourProject:dependencies --configuration compile**

The command result will show you human-readable tree hierarchy of all dependencies as below.

compile - Classpath for compiling the main sources.
+--- org.androidannotations:androidannotations-api:3.2
+--- com.android.support:support-annotations:22.1.1
+--- com.squareup:otto:1.3.6
+--- in.srain.cube:grid-view-with-header-footer:1.0.10
+--- com.nostra13.universalimageloader:universal-image-loader:1.9.3
+--- com.github.chrisbanes.photoview:library:1.2.3
+--- org.simpleframework:simple-xml:2.7.1
+--- com.google.android.gms:play-services-base:6.5.+ -> 6.5.87
+--- project :yourProject
|    +--- com.loopj.android:android-async-http:1.4.6
|    +--- org.apache.httpcomponents:httpmime:4.2.5
|    |    \--- org.apache.httpcomponents:httpcore:4.2.4
|    \--- com.google.code.gson:gson:2.3.1
+--- project :facebook
|    \--- com.android.support:appcompat-v7:22.1.1
|         \--- com.android.support:support-v4:22.1.1
|              \--- com.android.support:support-annotations:22.1.1 -> 22.2.0

You can see overriden dependencies and decide in mind which ones should be avoided. 
In above example, last line com.android.support:support-annotations presents overriden from 22.1.1 to 22.2.0 internally.
**To avoid duplicates**,you can add exclude clauses in each project build.gradle file.

compile('com.github.chrisbanes.photoview:library:1.2.3') {
exclude group: 'com.android.support'
}
compile('org.simpleframework:simple-xml:2.7.1') {
    exclude module: 'stax'
    exclude module: 'stax-api'
    exclude module: 'xpp3'
}
compile('com.google.android.gms:play-services-base:6.5.+')
{
        exclude module: 'support-v4'
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM