最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2017年11月07日 10:29:33   作者:Sam  
本文是小編給大家分享的更新Android Studio 3.0碰到的問題小結(jié),非常不錯,具有參考借鑒價值,需要的朋友參考下吧

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

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了,另外還有個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最新版,新建一個項目看看默認(rèn)用的什么版本,修改以下文件

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

出錯在最后一行,應(yīng)該是新版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

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

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

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

http://m.fzitv.net/article/127673.htm

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

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

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

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

今天晚上更新了AndroidStudio,可是再用這個就發(fā)現(xià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 

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

在項目的gradle.properties中添加

android.enableAapt2=false 

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

總結(jié)

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

相關(guān)文章

最新評論

德庆县| 博客| 武汉市| 邹平县| 缙云县| 尼玛县| 黎城县| 喀喇沁旗| 连江县| 林口县| 扎鲁特旗| 潢川县| 神农架林区| 合作市| 泗阳县| 新泰市| 铅山县| 临汾市| 行唐县| 越西县| 阳西县| 沂南县| 卢龙县| 泾阳县| 濮阳县| 博白县| 德清县| 宁夏| 广平县| 花莲市| 石阡县| 朝阳县| 和平区| 济阳县| 洪洞县| 南江县| 喀喇沁旗| 历史| 长岛县| 墨玉县| 汨罗市|