将android studio更新为4.2 beta1后,gradle构建失败

ddhy6vgd  于 2021-07-05  发布在  Java
关注(0)|答案(3)|浏览(544)

我刚刚更新了android studio,无法构建我以前的项目。我遇到了以下错误:

class jdk.internal.loader.ClassLoaders$PlatformClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$PlatformClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
class jdk.internal.loader.ClassLoaders$PlatformClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$PlatformClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')

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.

我对android工作室有点陌生我的java版本是:

java version "15.0.1" 2020-10-20

和build.gradle文件:

plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.example.appName"
        minSdkVersion 19
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
//        vectorDrawables{
//            useSupportLibrary true
//        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.github.bumptech.glide:glide:4.9.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

很抱歉问了这么长时间。任何帮助都将不胜感激。

yzxexxkh

yzxexxkh1#

尝试删除 build/ 方法并再次运行守护进程

nhhxz33t

nhhxz33t2#

该错误已经解释了原因并修复了可能出现的问题。如果@gtxtreme的上述答案不起作用,请尝试关闭android studio并重新启动系统。
不过,建议您使用稳定版本的androidstudio,即4.1版,并将beta4.2的测试留给Maven

wb1gzix0

wb1gzix03#

我有一段时间出现了相同的错误,我建议卸载以前的版本。如果需要,请导出您的设置。通过链接中的exe文件安装as,因为zip将产生相同的错误。我没有尝试过在没有卸载的情况下进行新的安装,但是如果这种方法有效的话,任何反馈都是非常感谢的。链接:https://developer.android.com/studio/archive

相关问题