linczy
linczy

Reputation: 170

Android Error: failed to find target with hash string android-26 and similar

I have an error when I wanted to try it first google firebase android quickstart. The gradle build is failed with the reason "failed to find target with hash string android-26". Despite I installed the required version.

Upvotes: 1

Views: 5161

Answers (3)

hoijui
hoijui

Reputation: 3914

I had the same error message, and it remained even after installing android SDK version 26 through the GUI in Android Studio (File -> Settings... -> Appearance & Behavior -> System Settings -> Android SDK). When checking with the command line tool. sdkmanager --list. It showed that version 26 was actually not installed, so i installed it this way:

cd android-sdk
sdktools/bin/sdkmanager --install "platforms;android-26" "sources;android-26"

after which my Android project compiled fine.

Upvotes: 1

Uwe Post
Uwe Post

Reputation: 515

In the SDK Manager, make sure SDK version 26 is installed.

Make sure that the app/build.gradle file has this line:

android {
compileSdkVersion 26
...
}

You might also want to set the targetSdkVersion to the same number, and check if intalled Build Tools version matches the one denoted in the build.gradle file. If none is there, add it, i.e.:

android {
buildToolsVersion '26.0.3'
}

Then press "Try again" at the top border of the window and wait.

Of course the same works for SDK version 27 and buildToolsVersion 27.0.1 and so forth. Just make sure installed version and referenced version do match.

Upvotes: 3

linczy
linczy

Reputation: 170

Actually I find out that each time you install a new sdk or library from sdk manager you need to run "invalidate caches/restart" from the file menu. Without this one, gradle won't see the new installed libraries. Android studio 2.3.3 from Mac.

Upvotes: 2

Related Questions