I have encountered this issue multiple time whenever I setup a new project or degraded the targetSdkVersion in Android Studio.
Gradle build system start complaining about dependencies "Failed to resolve: com.android.support:recyclerview-v7:21.1.2" or something else.
My question here is:
Is there any relation between version of gradle dependencies and targetSdkVersion/compileSdkVersion/buildToolsVersion? If yes then how it is calculated and how do I configure and figure out correct dependencies without googling every time?
In my current project my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.mukesh.manageinvestment"
minSdkVersion 8
targetSdkVersion 23
versionCode 1
versionName "1.0.0"
}
def siteURL = '"'+WebsiteURL+'"'
def gameURL = '"'+GamesURL+'"'
signingConfigs{
debug{
}
release{
}
}
buildTypes {
debug{
minifyEnabled false
buildConfigField "String", "BaseURL", siteURL
buildConfigField "String", "GameURL", gameURL
signingConfig signingConfigs.release
}
release {
minifyEnabled true
buildConfigField "String", "BaseURL", siteURL
buildConfigField "String", "GameURL", gameURL
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.squareup.picasso:picasso:2.4.0'
}
I have changed targetSdkVersion 23 to 21 and my current build.gradle is looking like this
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.devendraprasad.manageinvestment"
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0.0"
}
def siteURL = '"'+WebsiteURL+'"'
def gameURL = '"'+GamesURL+'"'
signingConfigs{
debug{
}
release{
}
}
buildTypes {
debug{
minifyEnabled false
buildConfigField "String", "BaseURL", siteURL
buildConfigField "String", "GameURL", gameURL
signingConfig signingConfigs.release
}
release {
minifyEnabled true
buildConfigField "String", "BaseURL", siteURL
buildConfigField "String", "GameURL", gameURL
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:21.1.2'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.android.support:recyclerview-v7:21.1.2'
compile 'com.squareup.picasso:picasso:2.4.0'
}
Every thing looks good dependencies version is matching with targetSdkVersion and buildToolsVersion but application is still not compiling. It gives this error
Information:Gradle tasks [:app:assembleDebug]
Error:A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugCompile'. Could not find com.android.support:appcompat-v7:21.1.2. Searched in the following locations: file:/C:/Program Files/Android/Android Studio1/gradle/m2repository/com/android/support/appcompat-v7/21.1.2/appcompat-v7-21.1.2.pom file:/C:/Program Files/Android/Android Studio1/gradle/m2repository/com/android/support/appcompat-v7/21.1.2/appcompat-v7-21.1.2.jar https://jcenter.bintray.com/com/android/support/appcompat-v7/21.1.2/appcompat-v7-21.1.2.pom https://jcenter.bintray.com/com/android/support/appcompat-v7/21.1.2/appcompat-v7-21.1.2.jar file:/F:/Software/android-sdk-windows/extras/android/m2repository/com/android/support/appcompat-v7/21.1.2/appcompat-v7-21.1.2.pom file:/F:/Software/android-sdk-windows/extras/android/m2repository/com/android/support/appcompat-v7/21.1.2/appcompat-v7-21.1.2.jar file:/F:/Software/android-sdk-windows/extras/google/m2repository/com/android/support/appcompat-v7/21.1.2/appcompat-v7-21.1.2.pom file:/F:/Software/android-sdk-windows/extras/google/m2repository/com/android/support/appcompat-v7/21.1.2/appcompat-v7-21.1.2.jar Required by: ManageInvestment:app:unspecified Could not find com.android.support:recyclerview-v7:21.1.2. Searched in the following locations: file:/C:/Program Files/Android/Android Studio1/gradle/m2repository/com/android/support/recyclerview-v7/21.1.2/recyclerview-v7-21.1.2.pom file:/C:/Program Files/Android/Android Studio1/gradle/m2repository/com/android/support/recyclerview-v7/21.1.2/recyclerview-v7-21.1.2.jar https://jcenter.bintray.com/com/android/support/recyclerview-v7/21.1.2/recyclerview-v7-21.1.2.pom https://jcenter.bintray.com/com/android/support/recyclerview-v7/21.1.2/recyclerview-v7-21.1.2.jar file:/F:/Software/android-sdk-windows/extras/android/m2repository/com/android/support/recyclerview-v7/21.1.2/recyclerview-v7-21.1.2.pom file:/F:/Software/android-sdk-windows/extras/android/m2repository/com/android/support/recyclerview-v7/21.1.2/recyclerview-v7-21.1.2.jar file:/F:/Software/android-sdk-windows/extras/google/m2repository/com/android/support/recyclerview-v7/21.1.2/recyclerview-v7-21.1.2.pom file:/F:/Software/android-sdk-windows/extras/google/m2repository/com/android/support/recyclerview-v7/21.1.2/recyclerview-v7-21.1.2.jar Required by: ManageInvestment:app:unspecified Information:BUILD FAILED Information:Total time: 7.733 secs Information:1 error Information:0 warnings Information:See complete output in console
PS: attached is my sdk manager screenshot
