Reputation: 145
I am following the Gradle tutorial on https://guides.gradle.org/building-android-apps/ . So the last step of this part is Run a Build Scan. I am doing the exact same thing as it asked me to do, but Android Studio keeps saying "Error:(14, 0) Could not get unknown property 'com' for root project 'HelloWorldGradle' of type org.gradle.api.Project."
Here is my Top-level build file(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
}
Upvotes: 12
Views: 16118
Reputation: 4331
Edit in May 2020:
Now in May 2020, the way to do it is, add the following to the app gradle file:
plugins {
id "com.gradle.build-scan" version "3.3"
}
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
publishAlways()
}
You should place these outside of the buildscript { .. }
, e.g., right after it, rather than inside it.
Then the build scan, e.g., with ./gradlew build --scan
, should work.
Edit in October 2019:
The current (October 2019) way to get the build scan working is to add the following to the app gradle file
plugins {
id 'com.gradle.build-scan' version '2.4.2'
}
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
publishAlways()
}
and it would probably be best to get it directly from the gradle build scan user manual in the future for when it changes again.
Upvotes: 7
Reputation: 1
Run from Terminal next command ./gradlew build --scan
or gradlew build --scan
Also, agree to the Terms of Service in the command line.
Upvotes: 0
Reputation: 401
According to gradle doc, this should be the latest implementation
plugins {
id 'com.gradle.build-scan' version '2.3'
}
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
publishAlways()
}
Upvotes: 3
Reputation: 1569
My issue was solved after writing the following in build.gradle the top-level file for the project
plugins {
id 'com.gradle.build-scan' version '1.16'
}
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
publishAlways()
}
Upvotes: 8
Reputation: 9866
The issue is with the following line in your build.gradle
:
apply plugin: com.gradle.build-scan
You need to update as
apply plugin: 'com.gradle.build-scan'
Another thing you need to pay attention is ALWAYS put the com.gradle.build-scan
plugin as the very first one, like this:
apply plugin: 'com.gradle.build-scan'
apply plugin: 'java'
Otherwise, you would see this:
WARNING: The build scan plugin was applied after other plugins. The captured data is more comprehensive when the build scan plugin is applied first.
Please see https://gradle.com/scans/help/plugin-late-apply for how to resolve this problem.
Let me know if this works.
Upvotes: 3