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
}
In your existing gradle project simply run ./gradlew build --scan or gradle build --scan if you're not using the gradle wrapper. You'll be prompted to accept the Gradle Cloud Services license agreement.
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()
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With