如何从gradle中的sdk中排除jar

问题描述 投票:2回答:3

嗨伙计们我试图从这个丛林sdk compile 'com.admost.sdk:vungle:5.3.0'排除一个罐子库,在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]))

android gradle
3个回答
1
投票

在左窗格窗口中选择Project而不是android。见下图。

如果不使用,请删除jar。也从gradle中删除引用。它应该工作。

enter image description here


1
投票
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'
    }

1
投票
**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'
}
© www.soinside.com 2019 - 2024. All rights reserved.