更新Android Studio 3.0碰到的问题小结

更新Android Studio 3.0碰到的问题小结,第1张

概述更新完后试下运行正在维护的旧项目,出现各种错误,因为后来发现问题不在这,所以没记完整,大概如下:

更新完后试下运行正在维护的旧项目,出现各种错误,因为后来发现问题不在这,所以没记完整,大概如下:

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

百度找到以下文章,修改后就可以正常编译运行了

https://www.oudahe.com/p/41224/

看了几个文章也搞不清楚这个是什么来的,照着改项目的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碰到的问题小结,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对编程小技巧网站的支持!

总结

以上是内存溢出为你收集整理的更新Android Studio 3.0碰到的问题小结全部内容,希望文章能够帮你解决更新Android Studio 3.0碰到的问题小结所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1143863.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-31
下一篇 2022-05-31

发表评论

登录后才能评论

评论列表(0条)

保存