简体   繁体   中英

Could not get unknown property 'VERSION_NAME' for project ':library' of type org.gradle.api.Project

When I import the RippleBackground library for my project as a module, following exception was thrown

Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'VERSION_NAME' for project ':library' of type org.gradle.api.Project.

But the versionName is already defined in the build.gradle file.

apply plugin: 'com.android.library'

android {
    compileSdkVersion 29
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.skyfishjy.library"
        minSdkVersion 11
        targetSdkVersion 29
        versionName "1.0.1"
        versionCode 2

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

dependencies {
}

apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'

Anyone can explain where the error is?

The publishing script imported on the last line requires some project properties, including VERSION_NAME , GROUP and others.

If you're not going to publish this library remove the line

apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'

Otherwise you'll need to put all the relevant properties in your gradle.properties file or provide them in the command line. You can open the URL in your browser and understand the properties from it.

Here, VERSION_NAME and versionName are not related.

Note: Android libraries don't have applicationId , versionCode or versionName . These properties are only used in Android apps. You can remove these lines.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM