简体   繁体   English

由 groovy.lang.MissingPropertyException 引起 Could not get unknown property 'android' for project ':lib1' of type org.gradle.api.Project

[英]Caused by groovy.lang.MissingPropertyException Could not get unknown property 'android' for project ':lib1' of type org.gradle.api.Project

To solve my problem here : Applying JaCoCo to all Android Studio gradle modules, I applied the solution here .在这里解决我的问题:Applying JaCoCo to all Android Studio gradle modules,我在这里应用了解决方案。 This works fine so far for modules with到目前为止,这对于具有

plugins {
    id("com.android.library")
}

As soon as I add the required apply from: '../jacoco/modules.gradle' into a module labeled as a Java library一旦我将所需的apply from: '../jacoco/modules.gradle'添加到标记为 Java 库的模块中

plugins {
    id("java-library")
}

I get a我得到一个

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

I would like to add the apply from to the java library, so that JaCoCo reports were generated for them as well.我想将apply from添加到 java 库,以便为它们生成 JaCoCo 报告。 What am I missin here?我在这里想念什么?

I assume you have also applied the snippet from the “Improvements” section of the solution you have linked to your ../jacoco/modules.gradle file?我假设您还应用了链接到您的../jacoco/modules.gradle文件的解决方案“改进”部分中的片段? In that case you could replace that snippet with the following:在这种情况下,您可以用以下内容替换该片段:

project.afterEvaluate {
    if (project.pluginManager.hasPlugin('com.android.library')) {
        android.libraryVariants.all { variant ->
            tasks.create(…)
        }
    } else {
        tasks.create(…)
    }
}

If that doesn't solve it, then I'd recommend to run the build with Gradle's --stacktrace option.如果那不能解决问题,那么我建议使用 Gradle 的--stacktrace选项运行构建。 That should give you more details on where exactly the missing property was found.这应该会为您提供有关找到丢失属性的确切位置的更多详细信息。

Without more information on your exact build setup it's hard to really say more.如果没有关于您的确切构建设置的更多信息,就很难说更多。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 groovy.lang.MissingPropertyException:无法为类型为org.gradle.api.Project的项目&#39;:flamingo&#39;设置未知属性&#39;versionKey&#39; - groovy.lang.MissingPropertyException: Could not set unknown property 'versionKey' for project ':flamingo' of type org.gradle.api.Project Android Studio:“无法获得类型为 org.gradle.api.Project 的项目的未知属性‘VERSION_NAME’” - Android Studio : “Could not get unknown property 'VERSION_NAME' for project of type org.gradle.api.Project” gradle 无法为项目'获取未知属性'战争'<project name> ' 类型为 org.gradle.api.Project</project> - gradle Could not get unknown property 'war' for project '<project name>' of type org.gradle.api.Project 无法为 org.gradle.api.Project 类型的根项目“[redacted]”获取未知属性“artifactory_contextUrl” - Could not get unknown property 'artifactory_contextUrl' for root project '[redacted]' of type org.gradle.api.Project 无法为类型为 org.gradle.api.Project 的项目“:app”获取未知属性“localProperties” - Could not get unknown property 'localProperties' for project ':app' of type org.gradle.api.Project 错误:无法获取类型为 org.gradle.api.Project 的项目“:app”的未知属性“appcompat” - ERROR: Could not get unknown property 'appcompat' for project ':app' of type org.gradle.api.Project 无法为org.gradle.api.Project类型的根项目“MyApplication3”获取未知属性“删除” - Could not get unknown property 'Delete' for root project 'MyApplication3' of type org.gradle.api.Project 无法获得类型为org.gradle.api.Project的项目&#39;:app&#39;的未知属性&#39;VERSION_CODE&#39; - Could not get unknown property 'VERSION_CODE' for project ':app' of type org.gradle.api.Project groovy.lang.MissingPropertyException:无法获取未知属性“manifestOutputFile” - groovy.lang.MissingPropertyException: Could not get unknown property 'manifestOutputFile' 无法为类型org.gradle.api.Project的项目&#39;:app&#39;设置未知属性&#39;localProperties&#39; - Could not set unknown property 'localProperties' for project ':app' of type org.gradle.api.Project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM