Error: Failed to find target with hash string android-28

Error: Failed to find target with hash string android-28

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.

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

Heres 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
   ...

Thats 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 dont know if thats 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

Error: Failed to find target with hash string android-28

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

Leave a Reply

Your email address will not be published. Required fields are marked *