如何从gradle Android Studio中的jar文件中删除单个模块 [英] How to remove single module from the jar file in gradle Android Studio

查看:66
本文介绍了如何从gradle Android Studio中的jar文件中删除单个模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从jar文件中删除单个软件包.

How can i remove the single package from the jar file.

我有两个来自不同供应商的SDK,并且两个SDK的jar文件中都包含 google.gson 包,因为这导致我在android studio中运行构建时出现问题,它显示了错误下图

I have two SDK's from diffent vendors and both the SDK's have google.gson package included in the jar files, because this causing me the issue in running a build in android studio it shows the error in image below

我知道如何像这样从存储库中排除模块:

i know how to exclude the modules from the repository like this:

compile('com.android.support:design:23.1.1') {
        exclude module: 'support-v4'
    }

但是我不知道如何从我的应用程序所需的jar文件中排除某些软件包.任何帮助将不胜感激.

but i don't know how to exclude some package from the jar file that i need in my application. Any help would be appreciated.

我的梯度文件:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'libs/SDK/com.google.gson'
    }


    defaultConfig {
        applicationId "**********"
        minSdkVersion 16
        targetSdkVersion 21
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable true
        }

    }
    dexOptions {
        preDexLibraries = false
        javaMaxHeapSize "4g"
    }

}

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    compile('com.facebook.android:facebook-android-sdk:4.1.0') {
        exclude module: 'support-v4'
    }
    compile('org.twitter4j:twitter4j-core:4.0.2') {
        exclude module: 'support-v4'
    }
    compile('com.android.support:design:22.2.0') {
        exclude module: 'support-v4'
    }
    compile files('libs/FlurryAnalytics-5.3.0.jar')
    compile files('libs/gcm.jar')
    compile('com.android.support:design:23.1.1') {
        exclude module: 'support-v4'
    }
    compile files('libs/SDK.jar')

    compile project(':volley')
    compile project(':viewPagerIndicator')
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.squareup.picasso:picasso:2.5.0'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
    compile 'com.android.support:support-v4:23.1.0'
    compile project(':android-country-picker-master')
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'javax.annotation:javax.annotation-api:1.2'
}

推荐答案

我意识到您做了类似的事情,但是我想补充一点,您可以使用星号,这只是一个旧项目的片段:

I realize that you did something similar to this but i would like to add that you can use Asterisks, this is just a snippet from an old project:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:recyclerview-v7:21.0.3'
    compile 'com.android.support:cardview-v7:21.0.3'
    compile 'com.android.support:support-v4:22.2.0'
    compile('com.google.android.gms:play-services:7.3.0') {
        exclude group: "com/google/android/gms/location/**"
        exclude group: "com/google/android/gms/wearable/**"
        exclude group: "com/google/android/gms/maps/**"
        exclude group: "com/google/android/gms/games/**"
        exclude group: "com/google/android/gms/plus/**"
        exclude group: "com/google/android/gms/drive/**"
        exclude group: "com/google/android/gms/panorama/**"
        exclude group: "com/google/android/gms/wallet/**"
        exclude group: "com/google/android/gms/tagmanager/**"
        exclude group: "com/google/android/gms/fitness/**"
        exclude group: "com/google/android/gms/security/**"
        exclude group: "com/google/android/gms/identity/**"
    }
    compile 'com.github.amlcurran.showcaseview:library:5.0.0'
}

还要澄清一下,由于您具有重复的gson依赖项,因此应该将gson从其中一个软件包中排除.

Also just to clarify you should be excluding gson from one of the packages since you have a duplicate gson dependency.

exclude module: 'gson';

这篇关于如何从gradle Android Studio中的jar文件中删除单个模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆