【发布时间】:2021-03-15 04:05:36
【问题描述】:
我刚刚更新了 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 studio 有点陌生,我的 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'
}
很抱歉这个冗长而混乱的问题。任何帮助将不胜感激。
【问题讨论】:
-
我今天也发生了同样的事情,我现在只是卸载并重新安装了稳定版。
-
Tnx @David Kroukamp 我也做了同样的事情现在工作正常
-
@PersianBuddy 我也升级到了 4.2,并不是所有的单元都失败了。不过它通过了 Jenkins/Github CI。当我回滚到 4.1.3 时,所有单元测试都通过了。 4.2 IDE 出现了问题,但奇怪的是更多的人没有遇到问题。您是否已升级回 4.2?如果是这样,您是否能够解决您提到的这些冲突?
标签: java android android-studio gradle