2
votes

I'm trying to use an old version of appcompat-v7. My build.gradle has the following lines:

dependencies {
    compile 'com.android.support:appcompat-v7:21.0.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.google.android.gms:play-services:8.4.0'
}

The full build.gradle is below:

import com.android.build.gradle.AppExtension

apply plugin: 'com.android.application'

final def extension = android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.example."
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
extension

dependencies {
    compile 'com.android.support:appcompat-v7:21.0.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.google.android.gms:play-services:8.4.0'
}

However, when running it gives me the error:

Error:A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_debugCompile'. Could not find com.android.support:appcompat-v7:23.0.0. Searched in the following locations: [removed links] file:/C:/Users/j/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom file:/C:/Users/j/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.aar file:/C:/Users/j/AppData/Local/Android/sdk/extras/google/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom file:/C:/Users/j/AppData/Local/Android/sdk/extras/google/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.aar Required by: WaitroseStock:app:unspecified Could not find com.android.support:appcompat-v7:23.0.0. Searched in the following locations: https://jcenter.bintray.com/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom https://jcenter.bintray.com/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.aar file:/C:/Users/j/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom file:/C:/Users/j/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.aar file:/C:/Users/j/AppData/Local/Android/sdk/extras/google/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.pom file:/C:/Users/j/AppData/Local/Android/sdk/extras/google/m2repository/com/android/support/appcompat-v7/23.0.0/appcompat-v7-23.0.0.aar Required by: WaitroseStock:app:unspecified > com.google.android.gms:play-services:8.4.0 > com.google.android.gms:play-services-cast:8.4.0 > com.android.support:mediarouter-v7:23.0.0

This is because I have deleted version 23 so it doesn't confuse itself with that newer version and cause errors. Why is it still looking for v23 when I have requested v21?

1
Did you change buildToolsVersion, in build.gradle ?bastien pinaquy
I believe I have. Edited comment with the full build.gradle.Josh Laird
Right click on your module, Open Module Settings, Properties and Dependencies are set to v21 or v23 ?bastien pinaquy
Dependencies is set to v21. Properties was empty. I have changed Compile Sdk Version to API 21, build tools version to 21.1.2. Same error I have also deleted all build-tools that aren't 21.1.2 from the SDK Manager and double-checked the location on my hard disk.Josh Laird
Clean-Rebuild-Restart-SyncIntelliJ Amiya

1 Answers

0
votes

Try this...

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion '21.1.2'

defaultConfig {
applicationId "your package name"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}

buildTypes {
release {
    minifyEnabled false
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.google.android.gms:play-services:8.4.0'
}

Restart your android studio and rebuild the project. Hope this will help you...