如何基于gradle应用传递的配置删除依赖关系?

时间:2020-07-22 22:09:31

标签: android gradle

我有一个依赖关系,需要从相关模块的导入所传递的配置中忽略。

我尝试使用android.applicationVariants解决问题,但是对于未应用插件的项目“ com.android.application”不存在此调用,但是我需要在应用于“ com.android.library”。

MyModule gradle

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'


android {
    compileSdkVersion 30
    buildToolsVersion "30.0.0"

    defaultConfig {
        minSdkVersion 22
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    flavorDimensions "general"
    productFlavors {
        general {
            dimension "general"
        }
        specific {
            dimension "general"
        }
    }

    configurations {
        generalDebug
        generalRelease
        specificDebug
        specificRelease
    }

}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
    implementation 'com.squareup.okhttp3:okhttp:4.0.1'

    // Pax
    implementation files('libs/NeptuneLiteApi_V2.04.00_20180329.jar')
    
// Error if applied: Could not get unknown property 'applicationVariants' for extension 'android' of type com.android.build.gradle.LibraryExtension.
//    project.android.applicationVariants.all { variant ->
//        if (variant.flavorName == "specific") {
//            implementation files('libs/PPCompAndroid-v1.32.aar')
//        }
//    }

    // NewLand
    implementation files('libs/libposdigital-1.5.1-4-release.aar')

    // Zoop
    implementation files('libs/zoop-emv-connect-pax-a920-pos_0.10.jar')
}

MyApp gradle:

dependencies {
...
implementation project(path: ':integration-lib', configuration: 'generalDebug')
...
}

0 个答案:

没有答案