4

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 inbuild.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?

Pradeep Gupta
  • 1,770
  • 1
  • 9
  • 23
Mehran
  • 61
  • 1
  • 1
  • 5

2 Answers2

2

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!

Mehran
  • 61
  • 1
  • 1
  • 5
1

Note:

  • You can set compileSdkVersion 23

  • call buildToolsVersion "22.0.1"

Finally

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

You should update your SDK Manager

  1. Android SDK Tools
  2. Android SDK Build Tools

Then Clean-Rebuild-Sync Your Project .

The Android SDK Manager separates the SDK tools, platforms, and other components into packages for easy access and management. You can also customize which sites the SDK Manager checks for new or updated SDK packages and add-on tools. For example, you can configure the SDK Manager to automatically check for updates and notify you when an installed SDK Tools package is updated. When you receive such a notification, you can then quickly decide whether to download the changes.

Please read official guide line about SDK Manager .

Hope this helps you .

IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198