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

首頁 > 系統 > Android > 正文

更新Android Studio 3.0碰到的問題小結

2019-12-12 01:44:20
字體:
來源:轉載
供稿:網友

更新完后試下運行正在維護的舊項目,出現各種錯誤,因為后來發現問題不在這,所以沒記完整,大概如下:

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已經是2048了,另外還有個Error:UNEXPECTED TOP-LEVEL ERROR:錯誤

搜索了一下并沒找到要點,于是Build一下項目,提示

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最新版,新建一個項目看看默認用的什么版本,修改以下文件

gradle-wrapper.properties里

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

APP的build.gradle里

dependencies {  classpath 'com.android.tools.build:gradle:3.0.0'}

編譯后又有錯

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

因為使用了編譯輸出文件名的代碼

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) } }}

出錯在最后一行,應該是新版Gradle的問題,最后在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

繼續編譯繼續出錯

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

百度找到以下文章,修改后就可以正常編譯運行了

//m.survivalescaperooms.com/article/127673.htm

看了幾個文章也搞不清楚這個是什么來的,照著改項目的build.gradle

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

項目的其它代碼不用改,文章開頭的錯誤全沒了,還好沒浪費太多時間

PS:下面看下更新AndroidStudio到3.0后遇到的一個編譯問題

今天晚上更新了AndroidStudio,可是再用這個就發現一個編譯問題:

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 

通過google,發現了解決辦法:

在項目的gradle.properties中添加

android.enableAapt2=false 

目前還沒搞懂為什么,先留在這里吧

總結

以上所述是小編給大家介紹的更新Android Studio 3.0碰到的問題小結,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 麟游县| 徐水县| 永寿县| 西畴县| 磴口县| 南康市| 集安市| 蒲江县| 华宁县| 南投县| 高密市| 襄樊市| 峡江县| 浙江省| 鄢陵县| 武邑县| 通城县| 杂多县| 建瓯市| 太原市| 平原县| 东莞市| 鞍山市| 开江县| 锡林郭勒盟| 库伦旗| 临邑县| 江口县| 酉阳| 神池县| 磴口县| 旅游| 静海县| 清徐县| 三门峡市| 苍南县| 武隆县| 中阳县| 专栏| 读书| 读书|