因新版的Android Studio一直弹出提示要更新,Android Gradle Plugin也一直有更新提示,查看了一下新的开发环境好似有了重大的变化,连版本号都看得出来有着大跃进,都要更新了就直上最新的Release版吧~虽然未知的领域很可怕,但该备份的也都备份好了,就来试试看
将专案的内建函式库合并成新的androidX,这时候不得不说Android Studio很贴心,有个一键转移成androidX的功能
点击後会弹出视窗
接着会在下方的Find出现所有会因为此更新影响的档案,然後点击Do Refactor
出现进度条,稍待更新
更新完成後会发现原本android.support的函式库都被换成了androidX为首的函式库
然後点击”File”>”Project Structure…”
更新一下java版本(从1.7改成1.8),同步完
执行编译,发现有报错
而Android Gradle Plugin Version和Gradle Version的部分
假如要更新到新版,就要升级Android Studio版本
於是将版本从4.1.2更新成Arctic Fox | 2020.3.1
将Android Gradle Plugin Version更新为7.0.2
将Gradle Version更新为7.0.2
然後编译後出现此错误
我将java1.8 改为11後
还是出现
然後出现下面的警告与错误
警告:
* DSL element 'dexOptions' is obsolete and should be removed. It will be removed in version 8.0 of the Android Gradle plugin. Using it has no effect, and the AndroidGradle plugin optimizes dexing automatically.
* Using flatDir should be avoided because it doesn't support any meta-data formats.
错误:
* API 'BaseVariant.getApplicationIdTextResource' is obsolete and has been replaced with 'VariantProperties.applicationId'. It will be removed in version 7.0 of the Android Gradle plugin. For more information, see TBD. To determine what is calling BaseVariant.getApplicationIdTextResource, use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
* Some problems were found with the configuration of task ':app:processCa88asiaDebugGoogleServices' (type 'GoogleServicesTask').
先解决错误
将专案的依赖项的google 服务更新成最新版
dependencies {
classpath 'com.android.tools.build:gradle:7.0.2’
classpath 'com.google.gms:google-services:4.2.0'
}
更新版本为4.3.8
dependencies {
classpath 'com.android.tools.build:gradle:7.0.2'
classpath 'com.google.gms:google-services:4.3.8'
}
接着处理警告一
* DSL element 'dexOptions' is obsolete and should be removed. It will be removed in version 8.0 of the Android Gradle plugin. Using it has no effect, and the AndroidGradle plugin optimizes dexing automatically.
找到下列的项目?内容?
dexOptions {
dexInProcess true
preDexLibraries true
javaMaxHeapSize "4g"
}
删除以上内容即可
继续处理警告二
* Using flatDir should be avoided because it doesn't support any meta-data formats.
於储存库中找到下列指令
flatDir {
dirs 'libs'
}
删除以上指令,於”android”项下调整添加下列指令即可
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
以上更新完成,也清掉警告和错误了~下一篇针对jcenter即将落日後的旧专案调整做解说~
<<: Day 14. slate × Interfaces × Ref
前言 进行观察还是需要用图表表示,这时候叠图就很好用。之前都一张一张画,现在呈现叠图的方式。 本日程...
接着则是加法运算,按下加数後,label变空字串,运算.add,是否值行运算(是),先前的数字为萤幕...
根据GDPR第5条和CCPA§§1798.83(d)(E)(iii) 和 §§1798.91.04(...
前几篇介绍了 Form 的基本操作与概念,也介绍了如何在表单中加入验证,最後要来介绍 Angular...
前言 Pandas 是强大的资料科学分析工具,结合前几天所学的NumPy特性 提供方便读取及使用的资...