could not get unknown property for 'applicationVariants' for BuildType_Decorated

后端 未结 1 461
庸人自扰
庸人自扰 2020-12-18 18:42

I have imported the module in my project and its correctly imported. But i am getting this error. i have imported the Scanner control app module (By zebra). I have searched

相关标签:
1条回答
  • 2020-12-18 19:09

    You have an error at applicationVariants.all.

    buildTypes {
        release {
            applicationVariants.all { variant ->
                appendVersionName(variant, defaultConfig)
            }
        }
    }
    

    Fix 1:

    This will not work since you are applying apply plugin: 'com.android.library'.

    You have to change it to apply plugin: 'com.android.application' to use applicationVariants.all.

    Fix 2:

    If you want to keep using apply plugin: 'com.android.library'.

    Change applicationVariants.all to libraryVariants.all or testVariants.all.

    Explanation:

    applicationVariants (only for the app plugin)

    libraryVariants (only for the library plugin)

    testVariants (for both plugins)

    All three return a DomainObjectCollection of ApplicationVariant, LibraryVariant, and TestVariant objects respectively.

    Hope this helps.

    Edit:

    apply plugin: 'com.android.library'
    
    android {
        compileSdkVersion 25
        buildToolsVersion '25.0.3'
    
        defaultConfig {
            minSdkVersion 19
            targetSdkVersion 22
            versionCode 71
            versionName "2.0.8.0"
            if (project.hasProperty('ADD_BUILD_TO_VERSION')) {
                versionName = versionName.substring(0,versionName.lastIndexOf(".") + 1) + (System.getenv("BUILD_NUMBER") ?: "0")
            }
        }
    
        signingConfigs {
            release {
                storeFile file("../../../keys/AndroidScannerSDK.keystore")
                if (project.hasProperty('RELEASE_STORE_PASSWORD')) {
                    storePassword RELEASE_STORE_PASSWORD
                    keyAlias RELEASE_KEY_ALIAS
                    keyPassword RELEASE_KEY_PASSWORD
                }
            }
        }
    
        buildTypes {
            release {
                minifyEnabled false
                if (project.hasProperty('RELEASE_STORE_PASSWORD')) {
                    signingConfig signingConfigs.release
                }
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    
        lintOptions {
            abortOnError false
        }
    }
    
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        compile 'com.android.support:appcompat-v7:25.3.1'
        compile 'com.android.support:design:25.3.1'
        compile project(':BarcodeScannerLibrary')
    }
    
    0 讨论(0)
提交回复
热议问题