在接收到 AS
推送的 3.1.4(stable) 的版本升级通知后,根据自己一直持有的升级会带来相应的 Bug
修复、稳定性、新特性等准则,尝鲜进行升级操作。在 Google Developers 官网,我们可以看到相较于 3.1.3
版本,本次升级有以下方面得到改善:
3.1.4 (August 2018)
This update to Android Studio 3.1 includes the following changes and fixes:
- The bundled Kotlin is now version 1.2.50.
- New projects are created with
kotlin-stdlib-jdk* artifacts
, rather than withkotlin-stdlib-jre* artifacts
, which are deprecated. - R8 parsing of ProGuard rules has been improved.
- The following bugs have been fixed:
- Attempting to run the Kotlin Main class failed with an error:
"Error: Could not find or load main class..."
- R8 entered an infinite loop while performing certain optimizations.
- Attempting to run the Kotlin Main class failed with an error:
- Using the Rerun failed tests command in the Run window sometimes incorrectly returned the message “No tests were found”.
- D8 did not correctly handle invoke-virtual instances, causing a crash with a *
VerifyError: invoke-super/virtual can't be used on private method
- The Data Binding compiler was depending on an old version of
com.android.tools:annotations
.The compiler now uses tools annotations from the base project when available. - Android Studio crashed during fragment transitions when using profilers.
The debugger crashed when debugging a layout with a text box. - D8 failed to read some ZIP files with special characters.
- D8 did not correctly handle invoke-virtual instances, causing a crash with a *
意思就是一些包的更新、某些功能的优化、一些 Bug
的修复,这些升级总体来说对于开发者的不会造成很大的影响,但是我确实因为 AS
的升级遇到了我无法解释的问题(还是自己造诣太浅啊),所以在本文只写了问题是什么,以及我是怎么解决的,自己做此记录。如果有幸这篇博文呗大神临幸,又恰好深知内在原因,望大神能指点一二,多谢!!!
问题第一阶段
向 ButterKnife、RxFragment 等一小部分的远端依赖库无法依赖到项目中,于是就爆出了 cannot reslove the symbol ‘ButterKnife’ 等一些类似的错误。
在多次 clean 、rebuild 、Invalidate Cache/Restart 、重启电脑操作后,错误依旧存在,但是最逗的是自己在第二天在没有做任何更改下去编译项目,竟然项目正常编译,完全没有任何错误,懵逼!
问题第二阶段
在问题频发的情况下,自己怀疑是不是真的是 3.1.4
版本的 Bug
,但是通过 Google
关键字 Android Studio 3.1.4 Bug
,并没有发现类似的有用信息。但是既然有这种可能,那么自己也只有试一试了,于是自己重新下载了Android Studio 3.1.3
版本,用他去构建项目,问题以及存在。因为自己同时在电脑中安装了Android Studio Canary
版本,发现也是这样的错误。
但是这样一来二区,有出现了新的错误:Caused by:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
, 关于 AAPT (Android Asset Packing Tool , 资源打包工具 在编译资源文件出了问题,导致很多的 style
、Theme
无法被找到,尝试了 Google
上的几个解决方案,无果。
解决方案
折腾了这么久,怀疑自己是不是把 Gradle
构建工具的相应文件损坏了,毕竟用了好几版的 AS
去构建项目,自己删除了 .gradle
文件夹,让项目重新进行相关构建,时间有点长,在构建成功的那一刻,一切都美好了,感觉世界马上要和平了。
注意:在删除
.gradle
文件时,自己发现这个文件竟然如此的大,有3 G
还要,自己点进wapper/dists
文件下,发现gradle
插件竟然有十几个版本,这也降低项目构建速度。也提醒自己一点:保留几个版本几个,在Android Studio
打开新的项目之前,应该手动修改相应的gradle
版本。
问题猜想
是不是自己重复用不同版本的 AS
,打开同一个项目,破坏了项目构建文件???