Mehran Mehran - 4 months ago 26
Android Question

Changing compileSdkVersion in Android Studio Is Giving an Error

I'm testing an app in Android Studio for which I need to use

compileSdkVersion
lower than 23, but the current version of
compileSdkVersion
in Android Studio is 23 by default. I downloaded and installed
Android SDK build-tools
revision 22 and changed it in
build.gradle
as follows:

android {
compileSdkVersion 22
buildToolsVersion "23.0.1"


but I'm getting this error:

cause: failed to find target with hash string 'android-22'


I've looked at a few similar questions but none helped me with this.

What should I do?

Answer

I found the answer to the issue... when I set the compileSdkVersion and buildToolsVersion through file => project structure => (module) app, they were set in the build.gradle accordingly as below:

compileSdkVersion 22
buildToolsVersion "22.0.1"

And I thought that the dependencies section should be like this(i.e versions being the same as that of buildToolsVersion):

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.0.1'
compile 'com.android.support:design:22.0.1'

}

but after a lot of research I found out that there is no version as 22.0.1 for the appcompat-v7... The version which I used for appcompat-v7 and design which worked is 22.2.1. So, that was it!

Comments