Transparent Java library for Android studio

Is it possible to have different build types for simple java libraries in Android Studio with gradle? I intend to run proguard and reduce the size of the jar file.

Java build.gradle

apply plugin: 'java'
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
}

Android build.gradle

android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
    applicationId "test.app"
    minSdkVersion 23
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
packagingOptions {
    exclude 'META-INF/services/javax.annotation.processing.Processor'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/LICENSE.txt'
}
productFlavors {
    buildWithSingleAlarmFlavour {
        applicationId "test.app"
        versionName ".1"
    }

    buildWithMultipleAlarmFlavour {
        applicationId "test.app"
        versionName "0.1"
    }
}

}
+4
source share

Source: https://habr.com/ru/post/1620309/


All Articles