Reputation: 113
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:design:22.2.1'
to
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:design:23.1.0'
Time to time, android studio will automatically change the values to the latest version which is extremely annoying and breaks my application. Is there a way to prevent this from happening?
Did a google search and stackoverflow searched but nothing came up.
Upvotes: 4
Views: 5903
Reputation: 210
I just ran into this with another developer who had checked out my project, and then started getting build errors shortly thereafter. When I looked, my support library versions had appeared to have been updated as well.
Turns out this was happening after they had added a new Activity via the Android Studio add an activity wizard. This was automatically updating the build.gradle file to use the latest support library versions, and also adding the 'com.android.support:design:23.2.0' library as well which I wasn't even using.
I'm wondering if something similar is happening to you, as you are indicating it seems to be periodically happening.
Upvotes: 0
Reputation: 364988
Android Studio doesn't update the dependencies if you specify the version
Example:
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:design:22.2.1'
In this case AS will tell you when there is a newer version without updating them.
If you the +
in your dependencies gradle updates with the latest version according to the build.gradle
.
For example:
compile 'com.android.support:support-v4:22.2.+'
compile 'com.android.support:support-v4:22.+'
compile 'com.android.support:support-v4:+'
It is a good practice to avoid it.
Upvotes: 1
Reputation: 1386
Instead of:
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:design:22.2.1'
try:
playVersion = '8.3.0'
supportVersion = 'support-v4:22.2.1'
designVersion = '22.2.1'
compile "com.google.android.gms:play-services:$playVersion"
compile "com.android.support:$supportVersion"
compile "com.android.support:design:$designVersion"
Remember to replace the '
s with "
s.
Upvotes: 2