Analysis of various pits for Android studio 3.0 upgrade (recommended)
Click Check for updates to update incrementally:
When the download is complete, you will be prompted to update gradle to 4.1:
Here, it is recommended that you click don't remind me on this project for the time being to prevent pit. Of course, I will not go to hell. I will order Update, and the question will come. It has been in the download. But don't worry, I downloaded it, official account chat interface reply to "gradle-4.1-all", download the gradle-4.1-all.zip file, and put it on:
Restart Android studio.
Gradle Directory:
MAC system default: / users / (user name) /. Gradle
Windows system default: C: \ users (user name). Gradle
Modify old project
First, let's create a new project and see what changes have taken place.
1、app/build.gradle
Buildtoolsversion: there is no buildtoolsversion attribute of the build tool. By default, Android studio 3.0 plug-in will automatically use the minimum build tool version for the Android plug-in version you use;
Implementation: changed from the previous compile to implementation. The old version of the build keyword compile has been abandoned, but changed to these two: API: the same function as compile, that is, it is considered that this module will disclose the content of its dependent module;
Implementation: This module will not expose its dependent module contents to the outside through its own interface.
2. Project build.gradle
Google (): Android studio 3.0 now uses Google's Maven repository by default, instead of relying on the Android SDK manager to obtain the updates of Android support library, Google play service, firebase and other dependencies;
Build. Gradle: Specifies the version of the gradle plug-in, which has been changed from 2.3.3 to 3.0.0.
3、gradle-wrapper.properties
The version of gradle is configured in gradle-wrapper.properties.
The above points can be modified for the old project.
butterknife
If you use butterknife in lib, you will encounter the following error:
It is said on the Internet that the problem can be solved by injecting the application plugin: 'com. Jakewharton. Butterknife'. However, if the butterknife used in lib is still reported that R2 cannot be found, I have to let go of the application plugin: 'com. Jakewharton. Butterknife'. Finally, I can only take the second place and change the 3.0.0 in build.gradle to the previous 2.3.3.
Package custom APK file name
When packaging, if you customize the output APK file name, you can do this:
Error reporting when using gradle plugin 3.0.0:
You need to modify each() and outputfile() methods to all() and outputfilename:
supplement
To learn more about the difference between build.gradle and gradle-wrapper.properties: https://developer.android.com/studio/releases/gradle-plugin.html
last
At present, these holes are welcome to make complaints about the pit you encountered in upgrading and development. In addition, if gradle-4.1-all.zip files are required, the official account "Wu Xiaolong student" chat interface will reply to "gradle-4.1-all".
PS: let's give you a supplementary introduction to the various methods of upgrading Android studio to 3.0.
Build.gradle of the project (not module):
Solution:
Just turn off aapt2
Add Android. Enableaapt2 = false in project / gradle.properties
summary
The above is the analysis of Android studio 3.0 upgrade pits (recommended) introduced by Xiaobian. I hope it will help you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!