由 groovy.lang.MissingPropertyException 引起无法获取未知属性'android'对于项目 ':lib1'类型为 org.gradle.api.Project

发布于 01-18 22:50 字数 790 浏览 6 评论 0原文

要解决我的问题此处:应用 JaCoCo对于所有 Android Studio gradle 模块,我应用了解决方案 这里。到目前为止,对于带有以下内容的模块来说效果很好

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

一旦我将所需的 apply from: '../jacoco/modules.gradle' 添加到标记为 Java 库的模块中

plugins {
    id("java-library")
}

,我就会得到一个

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

I would like将 apply from 添加到 java 库,以便也为它们生成 JaCoCo 报告。我在这里想念什么?

To solve my problem here: Applying JaCoCo to all Android Studio gradle modules, I applied the solution here. 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

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. What am I missin here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

街角迷惘 2025-01-25 22:50:24

我假设您还从您已链接的解决方案 ../ jacoco/modules.gradle文件?在这种情况下,您可以用以下内容替换该片段:

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

如果不能解决它,那么我建议使用gradle的- stacktrace选项运行构建。这应该为您提供更多详细信息,以了解丢失的财产的确切位置。

没有有关您确切构建设置的更多信息,很难真正说出更多信息。

I assume you have also applied the snippet from the “Improvements” section of the solution you have linked to your ../jacoco/modules.gradle file? 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. 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.

红玫瑰 2025-01-25 22:50:24

对于 Cordova - 一些过时的软件包导致它 - 请参阅 https ://github.com/google/cordova-plugin-browsertab/issues/43 & https://github.com/apache/cordova-android/issues/821,例如我们的cordova-plugin-browsertab

有多种方法可以解决这个问题,甚至是 来自 Cordova 文档的示例

那个对我有用的 - 在 gradle.properties 中添加 cdvMinSdkVersion=21 。没有尝试过其他的,但根据 cordova-plugin -browsertab#43(评论),它至少应该可以作为环境变量导出。

For Cordova - some outdated packages cause it - see https://github.com/google/cordova-plugin-browsertab/issues/43 & https://github.com/apache/cordova-android/issues/821, such us cordova-plugin-browsertab.

There are multiple ways to solve this, it's even an example from Cordova docs.

That one working for me - add cdvMinSdkVersion=21 inside gradle.properties. Haven't tried the other ones, but as per cordova-plugin-browsertab#43 (comment), it should work at least with exporting as environmental variable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文