-1

I am absolutly new in Android development and I have the following problem trying to build a sample project that I have downloaded from Internet.

When I try to build it I obtain the following error message:

Error:Cause: failed to find target with hash string 'android-18' in: C:\Users\Andrea\AppData\Local\Android\sdk
<a href="install.android.platform">Install missing platform(s) and sync project</a>

So I search online and I found this SO link: Android studio - Failed to find target android-18

Ok so I go into Tools > Android > SDK Manager and infact I have installed Android 6 corrisponding to the API level 23 but not Android 4.3 corrisponding to API level 18.

So what it means? It means that I have installed a different version o the Android framework ?(is it the SDK considerable as a framework or what?)

So, on Android Studio can I install different version of the SDK?

I think that the API level have to be defined in some way into the dowloaded application. How can I specify to this application to don't use the API level 18 but instead it use the installed API level 23 ? I think that it is not a problem because I have installed a newest version that have to support all the stuff of the oldest one, is it?

Community
  • 1
  • 1
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
  • There is probably a reason whatever you downloaded uses API 18, so the solution is to download API 18 and then see if the code can run. You can see about updating the API version later. – OneCricketeer Jun 11 '16 at 10:37

3 Answers3

1
  1. You can either change the compileSdkVersion version in build.gradle to 23 or whatever version you have in your local machine

  2. You can obtain the API Level 18 from the SDK Manager.

CodeWalker
  • 2,281
  • 4
  • 23
  • 50
1

I will explain the problem a bit for you and then provide you with the solution.

You are facing this problem, because your project is targeting API level 18 to compile the project. So you MUST have API 18 SDK installed to compile the project.

This is why the IDE is complaining that,

Install missing platform(s) and sync project

The SDK is not the framework. The Android framework is same all over, but with different API levels new updates are pushed to the SDK, the latest being API 23, Marshmallow.

You should not download an older SDK to compile the project.

Always try to use the latest SDK available to work with. So, just head over to your build.gradle file or AndroidManifest.xml file and change the compileSdkVersion to 23.

Aritra Roy
  • 15,355
  • 10
  • 73
  • 107
0

I go into Tools > Android > SDK Manager and infact I have installed Android 6 corrisponding to the API level 23 but not Android 4.3 corrisponding to API level 18.

So what it means? It means that I have installed a different version of the Android framework ?

Yes, you have a newer version of the SDK.

on Android Studio can I install different version of the SDK?

Yes, that is what the SDK Manager is designed for

I think that the API level have to be defined in some way into the dowloaded application. How can I specify to this application to don't use the API level 18 but instead it use the installed API level 23 ?

It is defined. Check either the AndroidManifest.xml or the build.gradle file in the module for the app (not in the project root). You should see some combination of minSdk, targetSdk, and/or compileSdk with a number after it. Since you are getting an error about missing SDK 18, then that number will be 18.

I think that it is not a problem because I have installed a newest version that have to support all the stuff of the oldest one, is it?

The support libraries are separate from the core SDK. You cannot run SDK 23 specific code on devices that have a version less than 23, therefore, to be safe, it is recommended that you start with downloading SDK 18, then run it, then try updating the compileSdkVersion number.

Community
  • 1
  • 1
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245