简体   繁体   English

将 android 工作室更新到 4.2 Beta1 后 Gradle 构建失败

[英]Gradle build failed after updating android studio to 4.2 Beta1

I've just updated android studio and can't build my previous project.我刚刚更新了 android 工作室,无法构建我之前的项目。 I've encountered these errors:我遇到了这些错误:

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.

I'm kinda new to the android studio my version of java is:我对 android 工作室有点陌生,我的 java 版本是:

java version "15.0.1" 2020-10-20

and build.gradle file:和 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'
}

sorry for the long and messy question.很抱歉这个冗长而混乱的问题。 any help would be appreciated.任何帮助,将不胜感激。

Try deleting the build/ method and running the daemon again尝试删除build/方法并再次运行守护程序

I had the same error for a while and I recommend to uninstall the previous version.我有一段时间遇到同样的错误,我建议卸载以前的版本。 Exprot your settings if needed.如果需要,导出您的设置。 Install AS via the exe file in the links, because the zip will produce the same error.通过链接中的exe文件安装AS,因为zip会产生同样的错误。 I have not tried making a fresh install without uninstalling, but any feedback is appreciated if that method works.我没有尝试在不卸载的情况下进行全新安装,但如果该方法有效,我们将不胜感激。 Links: https://developer.android.com/studio/archive链接: https://developer.android.com/studio/archive

Had the same with Android Studio 4.2.1.与 Android Studio 4.2.1 相同。 Uninstalling it and then installing it again helped me.卸载它然后再次安装它对我有帮助。

The error already explains the reasons and fixes to possible problems.该错误已经解释了原因并修复了可能的问题。 if the above mentioned answer by @gtxtreme does not work, try closing android studio and restart your system.如果@gtxtreme 的上述回答不起作用,请尝试关闭 android 工作室并重新启动系统。

Though it is recommended that you work with stable version of android studio which is 4.1 and leave the testing of beta 4.2 to the experts虽然建议您使用 4.1 的稳定版 android studio 并将 beta 4.2 的测试留给专家

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM