After the update, I tried running the old project being maintained. Various errors occurred. Later I found that the problem was not here, so I didn't remember it in full, roughly as follows:
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 =-Xmx1536M in the project .
Then checking mine is already 2048, and there is also an error: UNEXPECTED TOP-LEVEL ERROR: Error
After searching for it, I didn't find the key points, so I built the project and prompted
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.
So I updated the latest version of Gradle, created a new project to see which version is used by default, and modified the following files
inside
distributionUrl=https\:///distributions/gradle-4.
In the APP
dependencies { classpath ':gradle:3.0.0' }
There is another error after compilation
Cannot set the value of read-only property 'outputFile'....
Because the code that compiles the output file name is used
{ variant -> { output -> def outputFile = def fileName if (outputFile != null && ('.apk')) { if (('release')) { // The output apk name is Test_v_1.0_15-09-15 11:12:32_official_release.apk fileName = "Test_v_${}_${releaseTime()}_${[0].name}_release.apk" } else if (('debug')) { // The output apk name is Test_v_1.0_15-09-15 11:12:32_official_debug.apk fileName = "Test_v_${}_${releaseTime()}_${[0].name}_debug.apk" } = new File(, fileName) } } }
The error occurred on the last line, which should be the problem with the new version of Gradle. Finally, I found the solution in Stackover Flow. Reference
/questions/44239235/android-gradle-3-0-0-alpha2-plugin-cannot-set-the-value-of-read-only-property
Bundle
Change to
The last line is changed to
outputFileName = fileName
Continue compilation and error
Error:All flavors must now belong to a named flavor dimension. Learn more at /r/tools/
Baidu found the following article, and after modification, it can be compiled and run normally.
https:///article/
After reading a few articles, I couldn't figure out what this came from, so I changed the project accordingly
defaultConfig { targetSdkVersion:*** minSdkVersion :*** versionCode:*** versionName :*** //A sentence is added after the version name, which means flavor dimension, and its dimensions are the version number, so that the dimensions are all unified flavorDimensions "versionCode" }
The other code of the project is not necessary to be changed, all the errors at the beginning of the article are gone, but fortunately I didn't waste much time
PS: Let's take a look at a compilation problem encountered after updating AndroidStudio to 3.0
I updated AndroidStudio tonight, but using this again will find a compilation problem:
Error:: .aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:mergeDebugResources'.
> Error: : .aapt2.Aapt2Exception: AAPT2 error: check logs for details
Through Google, the solution was discovered:
Add in the project
android.enableAapt2=false
I haven't figured out why yet, so stay here first
Summarize
The above is a summary of the problems encountered in updating Android Studio 3.0 that the editor introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!