Reputation: 12899
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.
Upvotes: 12
Views: 9524
Reputation: 1087
i changed my class path line in gradle (project : project name) and issue is gone.
classpath 'com.android.tools.build:gradle:3.1.2'
Upvotes: 0
Reputation: 642
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"
Upvotes: 29
Reputation: 8106
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 {
...
}
Upvotes: 0
Reputation: 12899
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.
Upvotes: 0