记一次Android studio升级之后的坑
像往常一样打开Android studio,但这次它提示我升级!说是什么为了更好的体验,在好奇心的驱使下,我毅然地点击了“update”按钮。升级之后,编译项目,报出了N多个error,我的心都慌完!整个人都是凉的,但想到作为社会主义的接班人,不能被这个给吓到,因为我知道解决了眼前的error,还有日后的error。好了,言归正传,下面说一下什么解决的error。
1、第一个error比较简单,就是升级之后一些旧的配置信息不能再用,需要根据提示更新就好,这里就不详细介绍了。
2、这个error就比较恶心了,直接贴代码:
Caused by: java.lang.ExceptionInInitializerErrorat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.api.internal.classloading.GroovySystemLoaderFactory.forClassLoader(GroovySystemLoaderFactory.java:44) at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory.executeInWorkerClassLoader(IsolatedClassloaderWorkerFactory.java:106) at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory.access$200(IsolatedClassloaderWorkerFactory.java:56) at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1$1.call(IsolatedClassloaderWorkerFactory.java:84) at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1$1.call(IsolatedClassloaderWorkerFactory.java:81) at org.gradle.internal.progress.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:350) at org.gradle.internal.progress.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:340) at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199) at org.gradle.internal.progress.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:120) at org.gradle.workers.internal.IsolatedClassloaderWorkerFactory$1.execute(IsolatedClassloaderWorkerFactory.java:81) at org.gradle.workers.internal.DefaultWorkerExecutor$1.call(DefaultWorkerExecutor.java:105) ... 8 more
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.4.4 and you are trying to load version 2.4.12
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl$DefaultModuleListener.onModule(MetaClassRegistryImpl.java:511) at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanExtensionModuleFromProperties(ExtensionModuleScanner.java:80) at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanExtensionModuleFromMetaInf(ExtensionModuleScanner.java:74) at org.codehaus.groovy.runtime.m12n.ExtensionModuleScanner.scanClasspathModules(ExtensionModuleScanner.java:56) at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:112) at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:73) at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:36) ... 23 more
看着好像很简单,都已经给出错误提示了,把groovy-all换成2.4.12就行了。其实不然!我换了也没用,这个error花了我两天时间!在网上找了很多相关的答案,我来总结一下:
1、在build.gradle中添加groovy-all 2.4.12,或者是把build.gradle中的groovy删除再重新编译。
2、把build.gradle中的groovy-all的版本号后面换成加号,如:groovy-all 2.4.+ 再编译。
以上的方法我都试过,没卵用~差点绝望。
后来我对照了一下上一个版本,发现升级之后,AS自动把我的project的build.gradle中的classpath的配置降到3.1.1~这尼玛啊!坑爹啊!修改回原先的版本后,完美运行!有遇到这问题的朋友可以借鉴一下。