Gradle build fail

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project ‘android’.

Could not resolve all files for configuration ‘:classpath’.
Could not find com.android.tools.build:gradle:8.0.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/8.0.1/gradle-8.0.1.pom
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/8.0.1/gradle-8.0.1.pom
Required by:
project :

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

I always get this exception when I try to run my program.

buildscript {
ext.kotlin_version = ‘1.8.0’
repositories {
google()
mavenCentral()
}

dependencies {
    classpath 'com.android.tools.build:gradle:8.0.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

}

allprojects {
repositories {
google()
mavenCentral()
}
}

This is in my build.gradle file. I tried several different gradle versions but none worked

Don’t confuse Gradle versions with Android Gradle Plugin versions.
The latest Gradle version is 8.0.1.
But the latest Android Gradle Plugin version is 7.4.2.

1 Like

FAILURE: Build failed with an exception.

  • Where:
    Initialization script ‘C:\Users\finni\AppData\Local\Temp\ijmapper.gradle’

  • What went wrong:
    Could not compile initialization script ‘C:\Users\finni\AppData\Local\Temp\ijmapper.gradle’.

startup failed:
General error during conversion: Unsupported class file major version 63

Now this error comes up, after I changes the gradle version back to 7.4.2, with this being the updates build.gradle file:

buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath ‘com.android.tools.build:gradle:7.4.2’
classpath “org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version”
}
}

Again, you did not change the Gradle version, you changed the version of the Android Gradle Plugin.

But what Gradle version are you using? I guess something below 7.6. Because your message now says that you want to use Java 19 stuff with something that is not compatible with Java 19 like Gradle versions below 7.6: Compatibility Matrix

So if my assumption is right, either use an older Java version that is supported, or use a newer Gradle version.

yes, thank you, that worked now! But now I got this mistake. Could you help me there please?

A build operation failed.
Could not resolve all files for configuration ‘:path_provider_android:androidApis’.
Could not resolve all files for configuration ‘:path_provider_android:androidApis’.
Failed to transform android.jar to match attributes {artifactType=android-mockable-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime, returnDefaultValues=true}.
Execution failed for MockableJarTransform: C:\Users\finni\AppData\Local\Android\sdk\platforms\android-31\android.jar.
Cannot create mockable android.jar
C:\Users\finni\AppData\Local\Android\sdk\platforms\android-31\android.jar

No, I have no idea about Android.
You might better ask in some Android community about it.
And you might check whether --info and --stacktrace maybe give more information about the problem.