Error: Failed to find target with hash string 'android-28'
Asked Answered
C

3

6

When I sync my project in build.gradle(Project: Allo) I see this error

Failed to find target with hash string 'android-28'in: C:\Users\hacker\AppData\Local\Android\Sdk

Config:

apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.example.android.allo"
    minSdkVersion 19
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0 rc2'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation 'com.android.support:design:28.0.0 rc2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

and this is the image

Cardboard answered 18/5, 2018 at 23:32 Comment(0)
E
9

Read Set Up the Android P SDK.

android {
compileSdkVersion 'android-P'

defaultConfig {
    targetSdkVersion 'P'
}

For the best development experience with the Android P Preview SDK, we recommend that you install the latest Android Studio 3.2 canary.

You should install the Android P Preview SDK as follows:

  • Click Tools > SDK Manager.

  • In the SDK Platforms tab, select Android P Preview.

  • In the SDK Tools tab, select Android SDK Build-Tools 28-rc2 (or higher).

  • Click OK to begin install.

Ennis answered 19/5, 2018 at 3:17 Comment(3)
@SamuelRobert Indeed.Ennis
Thanks, but how I can install android Studio 3.2 canary?Cardboard
I had to set compileSdkVersion to 'android-P' and targetSdkVersion to 28.Wrest
P
4

I got the error "Failed to find target with hash string 'android-28'", None of the solutions above solved my issue.

Here's what caused my problem:

in the project gradle.build I added a user defined extension key value as such:

ext {
    ANDROID_COMPILE_SDK_VERSION=28
}

Then in the module gradle.build I then referenced this value as such:

android {
   compileSdkVersion rootProject.ext.ANDROID_COMPILE_SDK_VERSION
   ...

That's what causes the error!! What I did to correct the issue was to code it this way:

android {
  compileSdkVersion Integer.valueOf(rootProject.ext.ANDROID_COMPILE_SDK_VERSION)

In other words, compileSdkVerion wants an interger, not a string. The same it true with minSdkVerion, targetSdkVersion and versionCode in your gradle script.

I don't know if that's the problem that the above posters were experiencing, but that at least one way in which that error message can occur. And by the way, I could use support libraries 28.0.0

Pfennig answered 5/12, 2018 at 0:2 Comment(0)
B
0

Replace these two dependencies

implementation 'com.android.support:appcompat-v7:28.0.0 rc2'

implementation 'com.android.support:design:28.0.0 rc2'

with these

implementation 'com.android.support:design:28.0.0-rc01'

implementation 'com.android.support:appcompat-v7:28.0.0-rc01'

Burnham answered 4/9, 2018 at 6:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.