Android Studio Failed to find target with hash string 'android-26'


Android Studio Failed to find target with hash string 'android-26'



I've installed latest Android Studio and
- I've created new project for sdk 25
- I have sdk 25 installed



I have this issues:



Error:Failed to find target with hash string 'android-26' in: C:Android
Install missing platform(s) and sync project



Why is it complaining about version 26? I have project with api 25 set up?





I am having the exact same problem with a fresh never-before used Android Studio install; except the I have my project set up for api 16 and it is complaining about not having api 26. I also don't have Tools > Android or Tools > Android > AVD Manager in my tools menu. The whole computer is 100% fresh, nothing else ever installed on it except the JDK and Android Studio, and I am using a sample project I created by taking the "Start Project" menu and click next to all the defaults (just to test if everything was set up correctly).
– HarryFromMarydelDE
Jan 7 at 20:03





The solution can be found at: youtube.com/watch?v=bl6y3rY7_Wc . Apparently it is a bug in the default project build files in the latest version of Android Studio, once I went through the video everything was working, including the Tools > Android menu.
– HarryFromMarydelDE
Jan 7 at 20:18




1 Answer
1



This problem seem to emerge because AndroidStudio tries to target the last version of SDK it aware of. There few ways to solve it and @HarryFromMarydelDE Jan 7 at 20:18 presented nice solution in form of youtube video. I'll make this answer verbose and more detailed:



One way to deal it is to install sdk-26. You really may not have Android->AVD Manager menu items under Tools menu. You can find SDK Manager icon just under the Android Studio main menu, or open File->Settings (Ctrl+Alt+S) and go to Appearance&Behavior->System Settings->Android SDK



Other way is to find gradle.build file in YourAppName/app folder, find lines: compileSdkVersion 26 and targetSdkVersion 26 in it and change number into SDKs you already have.



But, if you'll change target sdk from 26 to 25, you may encounter more errors. Particularly, if you checked Back Compatibility box when you created your app in wizard. In this case you'll need to change 'com.android.support:appcompat-v7:26.1.0' string to use sdk 25 version of appcompat-v7:25.1.0 in the same file.



After this, you may encounter one more error:



Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (25.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.



To resolve it, edit app.iml in YourAppName/app folder: change 27.1.1 numbers to 25.1.0 and hopefully, Gradle will finally build your project.




Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).


Would you like to answer one of these unanswered questions instead?

Popular posts from this blog

How to add background colour in existing image using Swift?

Moria Casán

How to make file upload 'Required' in Contact Form 7?