简体   繁体   中英

How is build.gradle automatically changed in Android Studio?

I find that from time to time, Android Studio automatically updates one of my build.gradle files. I'm new to the gradle flow for Android development, but is it possible to control this automatic updating of build.gradle?

For example, I have a line in my build.gradle:

compile 'com.google.android.gms:play-services:5.0.89'

that recently got changed to

compile 'com.google.android.gms:play-services:5.2.08'

I did not want this change. Is this kind of change just fundamental to gradle? If not, how can I control when/whether it updates my build.gradle?

Thanks.

Similar to what Scott was saying, the build.gradle can't update unless you take some action to modify it. One of the most common triggers is using almost any of the built in templates. For example if you right click on a source folder and go to New -> Fragment -> Fragment (Blank) to insert a new blank fragment AS will also update the Google Play Services line in your build.gradle to the latest version. AFAIK there is no way to disable AS updating your build files when inserting a template.

Off the top of my head, I can't think of any cases where it modifies the build files without you having taken some action to cause it. Any modifications you make to Project Structure will of course modify the underlying build files. Various errors and warnings have quickfixes that can modify the build files on your behalf. In this case, I suspect that's what happened. If you change the dependency statement back to 5.0.89 and look at the build file in the IDE, you'll notice that it's warning that a newer version is available, and if you invoke the quickfix for that warning, it will change it for you. I suspect you may have done something like without realizing it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM