2015-12-30 231 views
2

如何从jar文件中删除单个程序包。如何从gradle中的jar文件中删除单个模块Android Studio

the package hierarchy

我从diffent厂商的两台SDK的和两个SDK的有google.gson包含在jar文件包,因为这引起了我的问题,运行在Android Studio中构建它显示的错误下面

enter image description here

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

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

但我不知道如何从我的应用程序中需要的jar文件中排除一些包。任何帮助,将不胜感激。

MY摇篮FILE:

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' 
} 
+0

发表您的'build.gradle' –

+0

@IntelliJAmiya,我已经发布了文件的gradle再次 – warlock

回答

1

我知道你做了类似的东西,但我想补充一点,你可以使用星号,这仅仅是从一个旧的项目一个片段:

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依赖。

exclude module: 'gson'; 
+0

一样,我知道如何从回购排除,但不能从本地jar文件编译的文件(“库/ SDK的.jar“){ 排除模块:‘com.google.gson’ } – warlock

+0

它以同样的方式,只是不包括libs文件夹整个文件夹 –

+0

工作室把这个 编译文件(以后它不是建设gradle这个”库/ sdk.jar') { exclude module:'com.google.gson'} – warlock

相关问题