今天AndroidStudio安装了个2021版本的,gradle用了7.3.3,创建项目后控制台总是有这样一个错误:
Unable to load class 'com.google.common.collect.ImmutableList$SerializedForm'.
This is an unexpected error. Please file a bug containing the idea.log file.
各种百度未找到解决办法,无奈下,看idea.log自己解决吧,查看此日志可以通过这个路径:AndroidStudio菜单栏–>Help–>Show Log in Explorer
我这个日志文件报错是这样的:
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.ImmutableList$SerializedFormat java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)at java.base/java.lang.Class.forName0(Native Method)at java.base/java.lang.Class.forName(Class.java:398)at org.gradle.tooling.internal.provider.serialization.WellKnownClassLoaderRegistry$2.resolveClass(WellKnownClassLoaderRegistry.java:86)at org.gradle.tooling.internal.provider.serialization.PayloadSerializerObjectInputStream.readClass(PayloadSerializerObjectInputStream.java:66)at org.gradle.tooling.internal.provider.serialization.PayloadSerializerObjectInputStream.readClassDescriptor(PayloadSerializerObjectInputStream.java:46)at java.base/java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1984)at java.base/java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1862)at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:451)at java.base/java.util.HashMap.readObject(HashMap.java:1460)at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.base/java.lang.reflect.Method.invoke(Method.java:566)at java.base/java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1175)at org.gradle.tooling.internal.provider.serialization.PayloadSerializer.deserialize(PayloadSerializer.java:76)at org.gradle.tooling.internal.provider.PhasedActionEventConsumer.dispatch(PhasedActionEventConsumer.java:42)at org.gradle.launcher.daemon.client.DaemonClient.monitorBuild(DaemonClient.java:246)at org.gradle.launcher.daemon.client.DaemonClient.executeBuild(DaemonClient.java:204)at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:167)at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:99)at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
初步分析,可能是我用的java sdk版本问题,这个报错信息,我用了1.8jdk,既然1.8没有这个api,就用高版本jdk吧,索性改成了17,这么尝试还真是问题解决了