I deleted anything related to gradle 1.1 from ~/.gradle and yet I have an error:
Error:Gradle version 1.10 is required. Current version is 2.0. If using the gradle wrapper, try editing the distributionUrl in /home/alex/Documents/projects/android/MyApp/gradle/wrapper/gradle-wrapper.properties to gradle-1.10-all.zip.
My settings were (before I had deleted /gradle from the project):
distributionUrl=http\://services.gradle.org/distributions/gradle-2.0-all.zip
Now in File->Settings->Gradle I have this:
Use local gradle distribution -> /usr/local/gradle/gradle-2.0
which is installed in that folder and has the version of 2.0.
So what's wrong with that?
Here is build.gradle
apply plugin: 'scala'
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url "http://saturday06.github.io/gradle-android-scala-plugin/repository/snapshot"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
classpath "jp.leafytree.gradle:gradle-android-scala-plugin:1.0-SNAPSHOT"
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
The Android Gradle plugin is currently not compatible with Gradle 2.0. The latest AOSP branch supports 2.0, so it is likely that the next release of the Gradle plugin will support 2.0 as well (source).
I recommend switching back to the wrapper and setting distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-bin.zip in your gradle-wrapper.properties.
Alternatively, switch your local Gradle version to 1.10-1.12.
Related
I just turned on an old computer and am trying to access some code. After updating all of my Android Studio, JDK, and Downloading the latest Gradle I am having trouble building the project. I get this error ;
ERROR: Could not find com.android.tools.build:gradle:5.4.1.
Searched in the following locations:
- https://jcenter.bintray.com/com/android/tools/build/gradle/5.4.1/gradle-5.4.1.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/5.4.1/gradle-5.4.1.jar
Required by:
project :
Add Google Maven repository and sync project
Open File
I have dont this and this
Below is the content of build.gradle file
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:5.4.1'
}
}
Below is the content of wrapper file
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
in my settings I have toggled between default and setting my path manually. I have also attemted to add google() and MavenCentral() to the repositories
I just ant to build and run my app but it is saying no! haha help
Don't confuse gradle with the Android Gradle plugin.
classpath 'com.android.tools.build:gradle:5.4.1'
It is the Android Gradle plugin and 5.4.1 doesn't exist.
Use the latest stable release:
classpath 'com.android.tools.build:gradle:3.4.1'
Check the release notes for other versions.
If you open URL https://jcenter.bintray.com/com/android/tools/build/gradle, there is no 5.4.1.
For gradle version meanings, please check What is real Android Studio Gradle Version?.
For your case, you need to add google() repo in your buildscript closure and modify the android-gradle-plugin version to be 3.4.1
buildscript {
repositories {
google()// <-- add this.
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
}
And, also, probably, you need to update your allprojects closure as below:
allprojects {
repositories {
google()// <-- add this.
jcenter()
}
}
Edit #1
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
This is the wrapper configuration telling which gradle version to use for your android gradle plugin. It is NOT the plugin version.
Android sonarqube worked until I updating android studio. Now it gives an error
FAILURE: Build failed with an exception.
* What went wrong:
com.android.build.gradle.api.ApkVariant.getCompileLibraries()Ljava/util/Collection;
I think this happens because gradle dependency syntax changed from 'compile' to 'implementation' like below in newest android version.
from
dependencies {
compile ........
compile ........
}
to
dependencies {
implementation ........
implementation ........
}
Can anyone please help me to configure sonarqube for new android version
Read the last part of the answer to get the latest updates
Original answer
I've performed some researches:
here you can
find the issue tracked internally by SonarQube
here you
can find the issue opened by a SonarQube developer asking Google
about the API change. As stated by Google engineers this change is intended and an alternative API already exists. SonarQube stated they won't support android plugin 3.0.0 until the final release or at least RC version
Result:
To continue to work you are forced to build your project with the current stable Android Studio and Android plugin v2.X.X
UPDATE - 6th November 2017
SonarQube released the new version 2.6 which is fully compatible with the AGP (Android Gradle Plugin) 3.0.0.
buildscript {
repositories {
google()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.1"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
apply plugin: "org.sonarqube"
More info in the release page HERE
You can use my solution https://github.com/SonarSource/sonar-scanner-gradle/pull/33
buildscript {
repositories {
jcenter()
google()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.android.tools.build:gradle:3.0.0"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6-rc1"
}
}
apply plugin: 'org.sonarqube'
After sonarqube 2.6 was released just updating the plugin was enough for me
plugins {
id "org.sonarqube" version "2.6"
}
Updating Benoit answer, the official sonar scanner gradle plugin (v2.6-rc1) already supports the new gradle syntax. So, update your root gradle script to:
buildscript {
repositories {
jcenter()
google()
maven {
url "https://jitpack.io"
}
}
dependencies {
classpath "com.android.tools.build:gradle:3.0.0"
classpath "com.github.SonarSource:sonar-scanner-gradle:2.6-rc1"
}
}
apply plugin: 'org.sonarqube'
Try to use lower version of gradle
I've upgraded to Android Studio 3.1 in Canary channel and I cannot build my project anymore, this error is printed:
Unable to load class 'com.android.builder.Version'. Possible causes
for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync
project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build
processes (requires restart)
Your project may be using a third-party plugin which is not compatible
with the other plugins in the project or the version of Gradle
requested by the project. In the case of corrupt Gradle processes, you
can also try closing the IDE and then killing all Java processes.
I already tried both of those solutions and also tried deleting all the ~/.gradle/caches directory but the error persists.
Looking for similar error I've found the old version of Android Studio having this issues with the suggested solution to upgrade the android tools version.
I think I already have the last one:
classpath 'com.android.tools.build:gradle:3.1.0-alpha01'
EDIT (30 Oct 2017):
Answers show that someone is having the issue while someone isn't.
As pointed out in the comments to this question this can be caused by a non compatible plugin, so I list the plugins used in my project here:
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
jcenter()
google()
// maven {
// url 'https://maven.google.com'
// }
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.gradle:build-scan-plugin:1.10"
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.1'
classpath 'com.android.tools.build:gradle:3.1.0-alpha01'
classpath 'com.google.gms:google-services:3.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
The dexcount one is currently not used tough because of some incompatibilities with newer versions of Android plugin.
I had the same issue and what we have in common is the dexcount plugin. Disabling this issue until the two plugins are compatible. See dexcount bug report.
"updating to dexcount 0.8.2 fixes the issue"
Apparently going back to a previous version of the Android Tools plugin works:
classpath 'com.android.tools.build:gradle:3.0.0'
But the IDE ask me if I want to update to 3.1.0-alpha1 so I wander if this is a bug or if the issue lay somewhere else.
I just leave this solution here until someone else come up with another explanation.
No idea why your build is not working, but after a clean install of Android Studio 3.1 and using this setting everything works fine compiling a large project which contains several libraries (and mixed with java, kotlin).
buildscript {
ext {
gradle_version = "3.1.0-alpha01"
kotlin_version = "1.1.51"
}
repositories {
maven {
url 'https://maven.google.com'
}
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
jcenter()
google()
}
dependencies {
classpath "com.android.tools.build:gradle:$gradle_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
jcenter()
google()
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "500"
}
}
}
and my app-based gradle.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
android {
...
}
i changed my class path line in gradle (project : project name) and issue is gone.
classpath 'com.android.tools.build:gradle:3.1.2'
Android sonarqube worked until I updating android studio. Now it gives an error
FAILURE: Build failed with an exception.
* What went wrong:
com.android.build.gradle.api.ApkVariant.getCompileLibraries()Ljava/util/Collection;
I think this happens because gradle dependency syntax changed from 'compile' to 'implementation' like below in newest android version.
from
dependencies {
compile ........
compile ........
}
to
dependencies {
implementation ........
implementation ........
}
Can anyone please help me to configure sonarqube for new android version
Read the last part of the answer to get the latest updates
Original answer
I've performed some researches:
here you can
find the issue tracked internally by SonarQube
here you
can find the issue opened by a SonarQube developer asking Google
about the API change. As stated by Google engineers this change is intended and an alternative API already exists. SonarQube stated they won't support android plugin 3.0.0 until the final release or at least RC version
Result:
To continue to work you are forced to build your project with the current stable Android Studio and Android plugin v2.X.X
UPDATE - 6th November 2017
SonarQube released the new version 2.6 which is fully compatible with the AGP (Android Gradle Plugin) 3.0.0.
buildscript {
repositories {
google()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.1"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
apply plugin: "org.sonarqube"
More info in the release page HERE
You can use my solution https://github.com/SonarSource/sonar-scanner-gradle/pull/33
buildscript {
repositories {
jcenter()
google()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.android.tools.build:gradle:3.0.0"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6-rc1"
}
}
apply plugin: 'org.sonarqube'
After sonarqube 2.6 was released just updating the plugin was enough for me
plugins {
id "org.sonarqube" version "2.6"
}
Updating Benoit answer, the official sonar scanner gradle plugin (v2.6-rc1) already supports the new gradle syntax. So, update your root gradle script to:
buildscript {
repositories {
jcenter()
google()
maven {
url "https://jitpack.io"
}
}
dependencies {
classpath "com.android.tools.build:gradle:3.0.0"
classpath "com.github.SonarSource:sonar-scanner-gradle:2.6-rc1"
}
}
apply plugin: 'org.sonarqube'
Try to use lower version of gradle
What could be the reason I can't downgrade Android Gradle plugin version?
I have updated to Gradle plugin 2.0 and now I want to use 1.5 but my installed Android Studio says :
> Error:The project is using an incompatible version of the Android
> Gradle plugin. Please update your project to use version 2.1.0
classpath 'com.google.gms:google-services:2.0.0-alpha6'
ad requested in Google Analytics latest version , but the Gradle not working as i want so i want to return to 1.5 .
this is my Gradle file :
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:2.0.0-alpha6'
}
}
repositories {
mavenCentral()
}
allprojects {
repositories {
jcenter()
}
}
Changing to
classpath 'com.google.gms:google-services:1.5.0'
instead
classpath 'com.google.gms:google-services:2.0.0-alpha6'
and in the inner Gradle file :
compile 'com.google.android.gms:play-services:8.4.0'
instead
compile 'com.google.android.gms:play-services:8.3.0'
Solved the problem .
all i need to check now is the affect on the Google Analyticts but the code compiled and run so at least we know for sure what is the incompatible part .