国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 系統(tǒng) > Android > 正文

更新Android Studio 3.0碰到的問(wèn)題小結(jié)

2019-10-22 18:24:09
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

更新完后試下運(yùn)行正在維護(hù)的舊項(xiàng)目,出現(xiàn)各種錯(cuò)誤,因?yàn)楹髞?lái)發(fā)現(xiàn)問(wèn)題不在這,所以沒(méi)記完整,大概如下:

A larger heap for the Gradle daemon is recommended for running jack.

It currently has 512 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to at least 1536 MB.
To do this set org.gradle.jvmargs=-Xmx1536M in the project gradle.properties.

然后查看gradle.properties我的org.gradle.jvmargs已經(jīng)是2048了,另外還有個(gè)Error:UNEXPECTED TOP-LEVEL ERROR:錯(cuò)誤

搜索了一下并沒(méi)找到要點(diǎn),于是Build一下項(xiàng)目,提示

Error:Failed to complete Gradle execution.

Cause:

The version of Gradle you are using (3.3) does not support the forTasks() method on BuildActionExecuter. Support for this is available in Gradle 3.5 and all later versions.

于是更新使用Gradle最新版,新建一個(gè)項(xiàng)目看看默認(rèn)用的什么版本,修改以下文件

gradle-wrapper.properties里

distributionUrl=https/://services.gradle.org/distributions/gradle-4.1-all.zip

APP的build.gradle里

dependencies {  classpath 'com.android/272227.html">android.tools.build:gradle:3.0.0'}

編譯后又有錯(cuò)

Cannot set the value of read-only property 'outputFile'....

因?yàn)槭褂昧司幾g輸出文件名的代碼

applicationVariants.all { variant -> variant.outputs.each { output -> def outputFile = output.outputFile def fileName if (outputFile != null && outputFile.name.endsWith('.apk')) {  if (variant.buildType.name.equals('release')) {  // 輸出apk名稱為Test_v_1.0_15-09-15 11:12:32_official_release.apk  fileName = "Test_v_${defaultConfig.versionName}_${releaseTime()}_${variant.productFlavors[0].name}_release.apk"  } else if (variant.buildType.name.equals('debug')) {  // 輸出apk名稱為Test_v_1.0_15-09-15 11:12:32_official_debug.apk  fileName = "Test_v_${defaultConfig.versionName}_${releaseTime()}_${variant.productFlavors[0].name}_debug.apk"  }  output.outputFile = new File(outputFile.parent, fileName) } }}

出錯(cuò)在最后一行,應(yīng)該是新版Gradle的問(wèn)題,最后在Stackover Flow找到解決辦法,參考

https://stackoverflow.com/questions/44239235/android-gradle-3-0-0-alpha2-plugin-cannot-set-the-value-of-read-only-property

variant.outputs.each 改成

     variant.outputs.all

最后一行改成

outputFileName = fileName

繼續(xù)編譯繼續(xù)出錯(cuò)

Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html

看了幾個(gè)文章也搞不清楚這個(gè)是什么來(lái)的,照著改項(xiàng)目的build.gradle

defaultConfig { targetSdkVersion:*** minSdkVersion :*** versionCode:*** versionName :*** //版本名后面添加一句話,意思就是flavor dimension 它的維度就是該版本號(hào),這樣維度就是都是統(tǒng)一的了 flavorDimensions "versionCode"}

項(xiàng)目的其它代碼不用改,文章開(kāi)頭的錯(cuò)誤全沒(méi)了,還好沒(méi)浪費(fèi)太多時(shí)間

PS:下面看下更新AndroidStudio到3.0后遇到的一個(gè)編譯問(wèn)題

今天晚上更新了AndroidStudio,可是再用這個(gè)就發(fā)現(xiàn)一個(gè)編譯問(wèn)題:

Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details 
Error:Execution failed for task ':app:mergeDebugResources'. 
> Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details 

通過(guò)google,發(fā)現(xiàn)了解決辦法:

在項(xiàng)目的gradle.properties中添加

android.enableAapt2=false 

目前還沒(méi)搞懂為什么,先留在這里吧

總結(jié)

以上所述是小編給大家介紹的更新Android Studio 3.0碰到的問(wèn)題小結(jié),希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)VEVB武林網(wǎng)網(wǎng)站的支持!


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到Android開(kāi)發(fā)頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 内丘县| 泌阳县| 辽源市| 海宁市| 汉川市| 遂溪县| 安新县| 元朗区| 桑日县| 舞阳县| 寻甸| 岐山县| 全南县| 巴中市| 剑川县| 精河县| 北京市| 岚皋县| 青海省| 西乡县| 苏尼特右旗| 饶阳县| 德格县| 清流县| 缙云县| 深水埗区| 鹤山市| 龙胜| 永顺县| 岢岚县| 荥阳市| 儋州市| 合川市| 仲巴县| 大关县| 称多县| 拜泉县| 察隅县| 姚安县| 左贡县| 南岸区|