61

I installed ALL Extra and SDK API 21-22 including changed

compileSdkVersion 22 to 21 and buildToolsVersion '22.0.1' to 21.1.2.

I'm having Rendering Problems for API 22. I have tried changing the version to <= 21 but I'm still getting an error.

stuckoverflow
  • 625
  • 2
  • 7
  • 23
  • Choose from here as per your `compileSdkVersion`: https://developer.android.com/studio/releases/build-tools.html – Uniruddh Jul 05 '16 at 08:26

17 Answers17

126

These are the correct version that you can add in your build.gradle according to the API needs.

API 24:

implementation 'com.android.support:appcompat-v7:24.2.1'
implementation 'com.android.support:recyclerview-v7:24.2.1'

API 25:

implementation 'com.android.support:appcompat-v7:25.4.0'
implementation 'com.android.support:recyclerview-v7:25.4.0'

API 26:

implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'

API 27:

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
priyank
  • 2,651
  • 4
  • 24
  • 36
25

In order to make that working I had to set:

compile ("com.android.support:support-v4:22.2.0")
compile ("com.android.support:appcompat-v7:22.2.0")
compile ("com.android.support:support-annotations:22.2.0")
compile ("com.android.support:recyclerview-v7:22.2.0")
compile ("com.android.support:design:22.2.0")

compile ("com.android.support:design:22.2.0")

Documentation states something different (docs):

com.android.support:support-design:22.0.0

fabiozo
  • 249
  • 3
  • 5
24

Real path for Support Repository Libraries:

enter image description here

  1. You should download Support Repository Libraries.

If the problem still exists:

  1. Go to the real path of your Support Repository Libraries and check that the following folder exists:

    "ANDROID_SDK_DIRECTORY\extras\android\m2repository\com\android\support" 
    

    In that folder there are support libraries that can't be found. for example:

    "ANDROID_SDK_DIRECTORY\extras\android\m2repository\com\android\support\appcompat-v7"
    
  2. Open folder appcompat-v7 and you see folders with all available version. You should use only one of these versions in the build.gradle file dependencies or use +, for ex. 18.0.+

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:18.0.+'
        compile 'com.android.support:gridlayout-v7:23.1.1'
        compile 'com.android.support:support-v4:23.1.1'
    }
    

That is the path taken from grade.build dependencies file:

com.android.support:appcompat-v7:18.0.0

Refer to the real path on your HDD -->

ANDROID_SDK_DIRECTORY\extras\android\m2repository\com\android\support\appcompat-v7\18.0.0

If there is no such folder, you will receive the error:

"failed to resolve com.android.support:appcompat-v7:18.0.0"  

p.s. If you have Windows x64, when installing sdk and jdk, make sure that the installation path does not have Program Files(86). Brackets that add Windows may cause additional problems with resolving paths for your project. Use simple paths for your installation folder.

For example:

c:\androidSDK\
Martin Evans
  • 45,791
  • 17
  • 81
  • 97
Sergey Orlov
  • 349
  • 2
  • 5
  • I do not have any such folder and hence get the error you mentioned: "failed to resolve...". From here onwards, how can I solve this issue?Any idea? – Srujan Barai Apr 02 '19 at 06:39
17

Failed to find: com.android.support:appcompat-v7:22.0.0

The "I literally tried everything else" answer:

This problem will also occur if you don't have an upto date Android Support Library and Android Support Repository. Just install using the SDK manager.

Paul Totzke
  • 1,470
  • 17
  • 33
  • Not that the other answers are incorrect, but the problem for me was our build machine didn't have the updated Support Library. – fawaad Apr 13 '16 at 22:15
  • 2
    Of course not. But when you google this error and you try every variation of compile and nothing works, this is the usually the culprit and its not entirely obvious to figure out on your own. Glad it helped! – Paul Totzke Apr 14 '16 at 16:16
9

Along with other provided solutions, make sure to have the following within project/build.gradle

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
Ashraf Alshahawy
  • 1,139
  • 1
  • 14
  • 38
2

in support libraries you always need to add three numbers as version number

Suppose for 22 -> you need to write it as 22.0.0, not just 22

for 22.1 -> 22.1.0

So your dependencies should look like this

compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:support-v4:22.0.0'
compile 'com.android.support:cardview-v7:22.0.0'
compile 'com.android.support:recyclerview-v7:22.0.0'

I Programmers language you need to pad extra zeros.

Hope this solves your problem

Ashok Varma
  • 3,489
  • 3
  • 28
  • 43
  • 1
    "and you got error when you used "21.1.2" because you already updated the support library to 22.0.0. so 21.1.2 does not exist anymore." That is so untrue. When you update libraries that doesn't mean you can't use the older versions – priyank Mar 29 '15 at 19:45
2

i solve it

change 22.0.0 to 21.0.3

dependencies {

 compile fileTree(dir: 'libs', include: ['*.jar'])

//compile 'com.android.support:appcompat-v7:22.0.0'

compile 'com.android.support:appcompat-v7:21.0.3'  }

maybe i have download the com.android.support:appcompat-v7:21.0.3 but have not got the compile 'com.android.support:appcompat-v7:22.0.0'

when i use SDK Manager update my support library and support repository , the problem dismissed.

Jeffery Ma
  • 3,051
  • 1
  • 23
  • 26
2

NOTE1: All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes).

NOTE2: Support library should not use a different version than the compileSdkVersion

For API 28 you can use:

implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:recyclerview-v7:28.0.0-alpha1'

https://mvnrepository.com/artifact/com.android.support/appcompat-v7/28.0.0-alpha1 https://mvnrepository.com/artifact/com.android.support/recyclerview-v7/28.0.0-alpha1

All support libraries: https://mvnrepository.com/artifact/com.android.support

Aniket Thakur
  • 66,731
  • 38
  • 279
  • 289
1

It is easier to use "+" sign in the version number. For example

compile 'com.android.support:support-v4:22.0.+'
compile "com.android.support:appcompat-v7:22.0.+"

In this case you won't have to change versions for the same API number

Kate
  • 69
  • 6
  • never use + sign, it will lead to unpredictable behavior, unless you are absolutely sure –  Apr 27 '15 at 05:36
  • 4
    I've seen using "+" in build.gradle file in several topics of Android Developers documentation. For example, [link1](https://developer.android.com/training/wearables/notifications/creating.html) or [link2](https://developer.android.com/training/wearables/apps/packaging.html) and others (you need to scroll the page to see it). There was no mentioning about any problems with this and I also have never had any. But if you did it would be helpful to add some links with description of the problem. – Kate Jul 07 '15 at 19:05
  • if you use + your build has dynamic behavior, you wont be sure which version will be resolved. External changes may cause bugs. – LGama Jul 13 '15 at 22:29
1

Go to Messages Gradle Sync, and Click on Install Repository and sync project. This is will install needed file in Android SDK and after syncing you will be able to create gradle or run your project.

Ravi Ranjan
  • 407
  • 1
  • 3
  • 16
1
allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
Makvin
  • 3,475
  • 27
  • 26
  • Duplicated answer. Please see Ashraf Alshahawy's answer above – Mo Zaatar May 19 '19 at 21:55
  • @MoZaatar It's not a duplicate answer I want to show that if you have put google() line below then also this error happened so put top of the all line like my answer. I am not copy anyone answer. – Makvin May 21 '19 at 05:19
  • @MoZaatar If those answer has google() line then i choose edit or comment.Why should i give as a new answer.I solved this issue this way so i put my answer. – Makvin May 22 '19 at 07:54
0

Are you import them? Like this:

compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.3'
oldfeel
  • 420
  • 3
  • 12
0
compile ("com.android.support:support-v4:22.2.0")
compile ("com.android.support:appcompat-v7:22.2.0")
compile ("com.android.support:support-annotations:22.2.0")
compile ("com.android.support:recyclerview-v7:22.2.0")
compile ("com.android.support:design:22.2.0")

paste the above code in your app gradle.

and while setting up the project select empty activity instead of blank activity.

Abhi Soni
  • 445
  • 6
  • 14
0

Fixed my issue by changing these

compile 'com.android.support:cardview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'

to

compile 'com.android.support:cardview-v7:23.0.+'
compile 'com.android.support:recyclerview-v7:23.0.+'

that means your target SDK version should be same as version of cardView and recyclerView and other google libraries.

targetSdkVersion 23
Abhishek
  • 2,295
  • 24
  • 28
0

I had such dependancy in build.gradle -

compile 'com.android.support:recyclerview-v7:+'

But it causes unstable builds. Ensure it works ok for you, and look in your android sdk manager for current version of support lib available, and replace this dependency with

def final RECYCLER_VIEW_VER = '23.1.1'
compile "com.android.support:recyclerview-v7:${RECYCLER_VIEW_VER}"
Aran Mulholland
  • 23,555
  • 29
  • 141
  • 228
Anton Kizema
  • 1,072
  • 3
  • 13
  • 27
0

Tools > Android > SDK Manager

Select all of the packages that are not up to date and update them.

Naskov
  • 4,121
  • 5
  • 38
  • 62
0

I solved the problem updating all packages from Android SDK Manager and also, I had to install Extras -> Android Support Repository.

Tonatio
  • 4,026
  • 35
  • 24