Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load class 'com.android.builder.Version' after upgrade to Android Studio 3.1

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.

like image 947
Daniele Segato Avatar asked Oct 27 '17 09:10

Daniele Segato


Video Answer


1 Answers

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"

like image 51
Gabor Peto Avatar answered Sep 28 '22 01:09

Gabor Peto