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

huangapple go评论84阅读模式
英文:

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

问题

在将RippleBackground库作为模块导入项目时,出现了以下异常:

> Caused by: groovy.lang.MissingPropertyException: 无法获取类型为org.gradle.api.Project的项目“:library”的未知属性'VERSION_NAME'。

但是在build.gradle文件中已经定义了versionName。

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'

有人能解释一下错误出在哪里吗?

英文:

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?

答案1

得分: 2

最后一行导入的发布脚本需要一些项目属性,包括 VERSION_NAMEGROUP 和其他属性。

如果你不打算发布这个库,可以移除这行代码:

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

否则,你需要将所有相关的属性放入你的 gradle.properties 文件中,或者通过命令行提供这些属性。你可以在浏览器中打开这个URL并从中了解这些属性。

在这里,VERSION_NAMEversionName 没有关联。

注意: Android库不需要 applicationIdversionCodeversionName。这些属性仅在Android应用程序中使用。你可以移除这些行。

英文:

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.

huangapple
  • 本文由 发表于 2020年8月16日 17:45:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/63435392.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定