Luk*_*ang 7 android android-gradle-plugin
我正在关注https://guides.gradle.org/building-android-apps/上的Gradle教程。因此,本部分的最后一个是“运行构建扫描”。我做的和要求我做的完全一样。但是Android Studio一直说“错误:(14,0)无法获得类型为org.gradle.api.Project的根项目'HelloWorldGradle'的未知属性'com'。”
这是我的顶级构建文件(build.gradle(Project:HelloWorldGradle)):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'https://plugins.gradle.org/m2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.4.0-alpha7'
classpath 'com.gradle:build-scan-plugin:1.7.1'
}
}
apply plugin: com.gradle.build-scan
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
2020 年 5 月编辑:
现在在 2020 年 5 月,这样做的方法是,将以下内容添加到应用程序 gradle 文件中:
plugins {
id "com.gradle.build-scan" version "3.3"
}
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
publishAlways()
}
Run Code Online (Sandbox Code Playgroud)
您应该将这些放在 之外buildscript { .. },例如,在它之后,而不是在里面。
然后构建扫描,例如,使用./gradlew build --scan,应该可以工作。
2019 年 10 月编辑:
当前(2019 年 10 月)使构建扫描正常工作的方法是将以下内容添加到应用程序 gradle 文件中
plugins {
id 'com.gradle.build-scan' version '2.4.2'
}
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
publishAlways()
}
Run Code Online (Sandbox Code Playgroud)
并且最好在将来再次更改时直接从gradle build scan 用户手册中获取它。
在build.gradle项目的顶级文件中编写以下内容后,我的问题得到解决
plugins {
id 'com.gradle.build-scan' version '1.16'
}
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
publishAlways()
}
Run Code Online (Sandbox Code Playgroud)
问题在于您的以下行build.gradle:
应用插件:com.gradle.build-scan
您需要更新为
apply plugin: 'com.gradle.build-scan'
Run Code Online (Sandbox Code Playgroud)
您需要注意的另一件事是始终将com.gradle.build-scan插件放在第一个,如下所示:
apply plugin: 'com.gradle.build-scan'
apply plugin: 'java'
Run Code Online (Sandbox Code Playgroud)
否则,你会看到这样的:
警告:构建扫描插件是在其他插件之后应用的。当首先应用构建扫描插件时,捕获的数据更全面。
请参阅https://gradle.com/scans/help/plugin-late-apply了解如何解决此问题。
让我知道这个是否奏效。
| 归档时间: |
|
| 查看次数: |
5308 次 |
| 最近记录: |