build.gradle dependencies auto updates itself

前端 未结 3 1555
后悔当初
后悔当初 2021-01-19 04:42
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\'
相关标签:
3条回答
  • 2021-01-19 04:47

    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.

    0 讨论(0)
  • 2021-01-19 04:58

    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.

    0 讨论(0)
  • 2021-01-19 05:09

    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.

    0 讨论(0)
提交回复
热议问题