50

I am using Android 4.2.2. After installing the latest SDK, when I open the eclipse I could see all the projects having the problem during the build. Following is the error i get. Please let me know how to resolve this?

Unable to resolve target 'android-16'
user1822729
  • 825
  • 1
  • 13
  • 27

13 Answers13

73

I have had the same problem, after an update I got a similar error.

It can be fixed to manually edit the project.properties file and update the android-16 part to the latest one you have installed. In your current case that is android-17.

I guess it can be configured using Android ADT as well, but I could not figure it out and this was quicker

Furthermore, you have to update your manifest as well, make sure you have android:targetSdkVersion set to 17.

Veger
  • 37,240
  • 11
  • 105
  • 116
  • 1
    Thanks Veger. This solved the actual issue. but now my project is not able to handle R file. setContentView(R.layout.about); How to resolve this ? – user1822729 Mar 07 '13 at 09:05
  • Clean and rebuild your project? If this does not help you should open a new question with details about your new problem... – Veger Mar 07 '13 at 09:09
  • You shouldn't modify project.properties. `# This file is automatically generated by Android Tools. # Do not modify this file -- YOUR CHANGES WILL BE ERASED!` – Will Vanderhoef Aug 29 '13 at 20:54
  • You are right, but at the moment of writing it was the only answer/way to fix this problem. The modification does not get reverted, even though the comment in the file indeed suggests so. Since there is another answer now, using the tools instead to provide a solution (which I did not test), it became a matter of preference between using the tools or directly edit the files (which obviously also done by the tools). As does seem to work for other people as well, I'll leave this answer be. – Veger Aug 29 '13 at 22:37
  • I had to change 17 to 18. – Bilbo Baggins Nov 18 '13 at 06:03
  • This answer seems like a hack. Another answer worked for me: http://stackoverflow.com/a/18070674/700204. I'm guessing the initial properties for the compatibility library assume API 16 is installed. The setting is not updated until the user selects a different API version than the one that is checked by default (17 in my case). Once I checked 18 and closed the dialog the library built . Then I checked 17 again and everything was fine. – trukvl Aug 16 '14 at 14:12
  • The best solution may be to install API version 16. I opted to have the compatibility library build against version 17 for now. – trukvl Aug 16 '14 at 14:15
  • One more instance where you can run into this : your $ANDROID_HOME and the actual android tools executables ( aapt, android etc ) on the path are different. Eclipse picks them up from ANDROID_HOME, shell picks them up from path .. quick sanity check : ls -la `which android` $ANDROID_HOME/tools/android – kert Nov 29 '14 at 21:16
  • thank you for this it really saves me a lot of time :) – Kairi San Jan 20 '16 at 00:40
35

If you're using Eclipse, try changing the target build to something higher than API 17 (Right click -> Properties -> Android -> Project Build Target).

If that removes the error, just change the target build back to API 17 afterwards.

I had this issue when importing android-support-v7-appcompat, and changing the target builds back and forth fixed my problem.

user2651262
  • 351
  • 3
  • 3
  • 3
    Unlike the accepted answer this solved my problem. Cleaning the project **won't** solve the issue but strangely the back-and-forth toggling of build targets worked. – Will Vanderhoef Aug 29 '13 at 20:57
  • thanks :) I meet this problem when add android-support-v7-appcompat too :D – hqt Oct 25 '13 at 13:31
7

Worth noting:

My target in project.properties appeared to be set to target=Google Inc.:Google APIs:18. However, it seems that it was set somewhere else to 16. I had to change to target=Google Inc.:Google APIs:16, save, then save it back to 18, and then it worked.

GLee
  • 5,003
  • 5
  • 35
  • 39
6

From the Android SDK Manager, install Android SDK Tools for API version 16.

W.K.S
  • 9,787
  • 15
  • 75
  • 122
4

Sometimes this happens even if the Project Properties and android:targetSdkVersion (in AndroidManifest.xml) are both of the same current SDK version.

If everything is current and matches, try restarting Eclipse. (This does actually work sometimes.)

Old McStopher
  • 6,295
  • 10
  • 60
  • 89
2

To resolve the problem of "Unable to resolve target 'android-16'" set the targetSDKversion for library project for example "android-support-v7-appcompat".

  1. Expand the library project
  2. Open manifest file from the library (not the one in your application)
  3. Under the tag specify the "Target SDK version" to version of SDK installed (example to 18)
  4. Rebuild the library and application ( or restart Eclipse)

That should solve it.

enter image description here

jszobody
  • 28,495
  • 6
  • 61
  • 72
developer
  • 101
  • 2
  • 5
1

Also worth noting - Under Ubuntu 12.04, I installed the Android SDK Tools for API version 16, exited and restarted Eclipse and it resolved the issue without changing the target to version 16 and back to 18

user76945
  • 11
  • 1
1

Checked both projects project.properties files and they had version 18 as target, version 16 nowhere to be found. Restarting Eclipse somehow solved the issue.

jaros
  • 46
  • 3
1

Unable to resolve target 'android-16'

Make sure which version your are using and set that version in the mentioned files

To solve this problem we need to change 3 files as follows.

project.properties (target=android-18)

AndroidManifest.xml (android:targetSdkVersion="18")

\bin\AndroidManifest.xml (android:targetSdkVersion="18")

As mentioned above the 3 files has the same version number.

  • Your answers will be much more appreciated with more formatting, esp. separate out the code from the text. Thanks – philant Nov 27 '13 at 07:17
1

In eclipse I did all the above and the error did not go away.

Then I simply RESTARTED eclipse and that solved it ;)

So, do the above and then restart eclipse!

user3154700
  • 101
  • 1
  • 4
0

Go to project.properties in your project folder and change android:targetSdkVersion or target tag.

For example, if project.properties file contains android:targetSdkVersion=16 or target=android-16, change it to one of the targets which you have installed (you could check the installed target from Android SDK manager).

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
0

Set your proxy settings. sdk manager->options. then you can install the API you want. it worked for me.

Ansu
  • 41
  • 8
0

Right click on Project. Go to Properties. Choose Android on the left site. On the right a you can see list of android API versions. Choose the proper version (android API 16). Click apply.

If you do not see the proper version go to windows. go to Android SDK Manager and download the android API 16 (Android 4.1.2). Repeat the steps as above.

In the below picture you can see API 16.If not found there, you can download API 16 using android sdk manager. If you already have click the check box next to android 4.1.2, click apply and then OK.

enter image description here

To download sdk form the sdk manager in eclipse go to windows, Android SDK Manager. You should see the following window and check android 4.1.2 which API 16 and click install.The below image is an example for API-15(you have to do it for API-16) enter image description here

Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300