Palak
Palak

Reputation: 1296

Android Gradle project sync failed due to target version

Since a new API of Android 6.0 is available in SDK Manager a hint was appeared in application level build.gradle file to update

FROM

androidTestCompile 'com.android.support:support-annotations:22.0.1'
compile 'com.android.support:appcompat-v7:22.0.1'

TO

androidTestCompile 'com.android.support:support-annotations:23.0.0'
    compile 'com.android.support:appcompat-v7:23.0.0'

I haven't downloaded new update from sdk manager for Android 6(API 23) yet but still changed the following details as shown below,

BEFORE

compileSdkVersion 22
buildToolsVersion "22.0.1"
targetSdkVersion 22
androidTestCompile 'com.android.support:support-annotations:22.0.1'
compile 'com.android.support:appcompat-v7:22.0.1'

AFTER

    compileSdkVersion 23
    buildToolsVersion "23.0.0"
    targetSdkVersion 23
    androidTestCompile 'com.android.support:support-annotations:23.0.0'
    compile 'com.android.support:appcompat-v7:23.0.0'

As I haven't downloaded new API 6.0 yet, following error occurred

Error:Cause: failed to find target with hash string 'android-23' in: C:\Users\DRONE\AppData\Local\Android\sdk

So now again I changed the setting in application level build.gradle file as what it was before, but the error is not being resolved. Same error is occurring.

How do I solve this now?

Upvotes: 31

Views: 51847

Answers (4)

Fred
Fred

Reputation: 352

Yes as others have mentioned you need to install API-23 through the SDK Manager but it's a long list of downloads and if you don't want to install all of them right away, you can just install the one named "SDK Platform" under API-23

Upvotes: 1

Wernon
Wernon

Reputation: 228

Normally it is caused by not having API 23. After updating the SDK to the newer version, it often rewrites build.gradle to the highest API version SDK provided even if you didn't upload it. The easiest way - download API 23.

Upvotes: 21

Frédéric
Frédéric

Reputation: 77

Try to add a "+" for example: compile 'com.android.support:appcompat-v7:23.+'

You have also to update your Android Studio APIs (as Kun said).

Upvotes: 2

Kun
Kun

Reputation: 580

I think it may caused by you don't have 23 API, Go to Tools > Android > SDK Manager and check to see if API-23 is installed.

Upvotes: 15

Related Questions