Search code examples
androidgradledependenciesandroid-gradle-pluginbuild.gradle

Why does gradle say that it cannot resolve "com.android.support:support-annotations:23.1.1"?


I am building an app called Shaking. Today I added some button libraries to the project, namely:

Bootstrap Buttons: https://android-arsenal.com/details/1/65

Flat Buttons: https://android-arsenal.com/details/1/68

I added the following in the dependencies block of build.gradle file:

compile 'com.beardedhen:androidbootstrap:2.0.1' //This is the bootstrap library
compile 'info.hoang8f:fbutton:1.0.5' //This is the flat buttons library

just like the webpages above have said.

Then an error pops up that says:

Error:Failed to resolve: com.android.support:support-annotations:23.1.1

After some time, I figured out that the bootstrap buttons library is causing the problem because if I comment the line out, no errors!

I tried closing Android Studio and opening it again and cleaning the project, rebuilding... It all did not work.

Then I found this question
I thought the problems that I am having is quite similar to that so I followed the steps suggested by the second answer. This time, another error occurred:

Error:failed to find target android-23 : C:\Users\User\AppData\Local\Android\sdk

I think I do not have SDK 23 installed.

I really want to know why this happens and how can I fix it!


Solution

  • Below is build.gradle of com.beardedhen:androidbootstrap:2.0.1:

    apply plugin: 'com.android.library'
    apply from: 'push.gradle'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.1"
    
        defaultConfig {
            minSdkVersion 11
            targetSdkVersion 23
            versionCode = Integer.parseInt(VERSION_CODE)
            versionName = VERSION_NAME
        }
    }
    
    dependencies {
        compile 'com.android.support:support-annotations:23.1.1'
    }
    

    You can see that compile 'com.android.support:support-annotations:23.1.1'.

    Make sure that you have install android support library 23.1.1:

    enter image description here