10

[2011-02-10 00:14:34 - newproject] Unable to resolve target 'android-2'


and the newproject java and xml files does't have an any error but the project is in error from when i import what problem in it


ezhil
  • 2,606
  • 7
  • 26
  • 30
  • Are you using eclipse? Did you right click on eclipse project and check your android sdk. ( I am sure you will see an error there). – uncaught_exceptions Feb 09 '11 at 07:03
  • @doc another project are running good this one only responding like that.. may i want to start new AVD ... – ezhil Feb 09 '11 at 07:08
  • Did you import another project from the same eclipse ide. I might be wrong, but this is what I think is happening. Develop a new android application in eclipse? Set the android version to "android 2" ( a custom name that I provided while setting up the sdk). 3. Now when I export the project, the reference to "android 2" is still there. – uncaught_exceptions Feb 09 '11 at 07:12
  • By the way don't change you avd. It's not a runtime problem, but a compile time library problem. – uncaught_exceptions Feb 09 '11 at 07:13

4 Answers4

23

Problem is not in your Java or XML code. You have to change the target in your default.properties file in your project.

Here you have to change the following line:

target=android-2

Here the digit 2 represents the API level of the Platform you want to run your application.

So use the value of the API you want to run.

Like if I run my application on Android 2.3 then I use target=android-9

Refer : API Levels

Dean Rather
  • 31,756
  • 15
  • 66
  • 72
Vikas Patidar
  • 42,865
  • 22
  • 93
  • 106
  • MITian : This API level is 1.5 am having that.Another 1.5 projects's are running and this is running good to my colleague only to me not responding. Thankyou – ezhil Feb 09 '11 at 07:16
  • Then i would simply recommend that just delete this project and import it again or try cleaning the whole workspace. Also insure that your SDK path is correct? – Vikas Patidar Feb 09 '11 at 07:23
  • 2
    Also your API Level 1.5 means you have to use `android-3` – Vikas Patidar Feb 09 '11 at 07:25
  • 2
    Android-2 means it's android 1.1 (which is no longer available as part of the standard downloads for developers). You better just follow Creative MITian's advice and set it to android-3 for android sdk 1.5 – Stephan Branczyk Feb 09 '11 at 07:34
  • watchout! I was freaking out cause my `default.properties`file looked fine. There might be `project.properties` lingering around as well. Make sure you've also checked this cat! :) – nuala Mar 12 '12 at 11:26
  • @VikasPatidar Your suggestion works, and it is much better than downloading a whole slew of past Android versions, but the file in question (now called "project.properties") starts with "Do not modify this file -- YOUR CHANGES WILL BE ERASED!", which suggests that, well, one should edit the settings that were used to generate this file. – Calaf Feb 08 '13 at 18:36
12

You can change the target version of Android by right-clicking your project, navigating to Properties and then clicking on the "Android" tab as shown here.

enter image description here

Raoul George
  • 2,807
  • 1
  • 21
  • 25
4

I've just had this problem. The fix is simple - restart Eclipse. The reason is a bit more complicated:

  1. I had a fresh install of Eclipse and android SDK v.17 (4.2.2)
  2. I downloaded and imported source code (ActionBarSherlock) which had target=android-14 in it's project.properties file.
  3. Eclipse figured out that I use android-17 and updated project.properties to target=android-17, BUT, eclipse still had target=android-14 cached somewhere in its workspace's .metadata folder and was using the cahced version during the build

Restarting eclipse solved it.

Alon Catz
  • 2,417
  • 1
  • 19
  • 23
0

Also be aware of SDK version if importing an existing project, because project.properties will be also imported as well.

If you're running Android SDK Manager in Windows, you can access SDK Manager.exe program to check which SDK versions are installed. This program is usual

Nikhil
  • 16,194
  • 20
  • 64
  • 81
Oskytar
  • 205
  • 2
  • 8