How to change target build on Android project?

AndroidBuildTarget

Android Problem Overview


I currently have an Android project in Eclipse.

I created it with a target build of 1.5 (sdk 3).

Now I want to change it so that it has a minSdk of 3 and targetSdk of 8.

To do this I see that I must build against the newest SDK (2.2)

To do this in Eclipse I right click on my project, go to properties, click on Android and change the project build target to Android 2.2 and click apply and then ok.

However this appears to have no affect and when I try it again the target build is set back at Android 1.5.

Am I missing a step or something?

Android Solutions


Solution 1 - Android

Right click the project and click "Properties". Then select "Android" from the tree on the left. You can then select the target version on the right.

(Note as per the popular comment below, make sure your properties, classpath and project files are writable otherwise it won't work)

Solution 2 - Android

  1. You can change your the Build Target for your project at any time:

Right-click the project in the Package Explorer, select Properties, select Android and then check the desired Project Target.

  1. Edit the following elements in the AndroidManifest.xml file (it is in your project root directory)

In this case, that will be:

    <uses-sdk android:minSdkVersion="3" />
    <uses-sdk android:targetSdkVersion="8" />

Save it

  1. Rebuild your project.

Click the Project on the menu bar, select Clean...

  1. Now, run the project again.

Right Click Project name, move on Run as, and select Android Application

By the way, reviewing Managing Projects from Eclipse with ADT will be helpful. Especially the part called Creating an Android Project.

Solution 3 - Android

Another way on the command line if you are using ant is to use the android.bat script (Windows) or android script (Mac). It's in $SDK_DIR/tools.

If you say,

android.bat update project --path .  --target "android-8"

it will regenerate your build.xml, AndroidManifest.xml, etc.

Solution 4 - Android

There are three ways to resolve this issue.

  1. Right click the project and click "Properties". Then select "Android" from left. You can then select the target version from right side.

  2. Right Click on Project and select "run as" , then a drop down list will be open.
    Select "Run Configuration" from Drop Down list.Then a form will be open , Select "Target" tab from "Form" and also select Android Version Api , On which you want to execute your application, it is a fastest way to check your application on different Target Version.

  3. Edit the following elements in the AndroidManifest.xml file

xml:

<uses-sdk android:minSdkVersion="3" />
<uses-sdk android:targetSdkVersion="8" />

Solution 5 - Android

Well I agree with Ryan Conrad on how to do it in eclipse, have you ensured you have changed your manifest.xml?

 <uses-sdk android:minSdkVersion="3" />
 <uses-sdk android:targetSdkVersion="8" />

Solution 6 - Android

The file default.properties is by default read only, changing that worked for me.

Solution 7 - Android

The problem sometimes occurs when there are errors in the project.

For instance, if your project is configured with a target of 3.2 but the 3.2 libraries are not available, you will not be able to change the version to 4.0!

The usual (perhaps brutal) solution I use is to create a new project with the correct target and copy src, res and manifest into the new project.

Update:

This seems to work:

  1. Change the selected through the build properties as normal
  2. Manually edit project.properties AND default.properties to make sure they both reflect the desired target.
  3. Close the project and re-open it

I always run Android Tools | Fix Project Properties after making any changes to the build target.

Solution 8 - Android

You should not have multiple "uses-sdk" tags in your file. ref - docs

Use this syntax:
    <uses-sdk android:minSdkVersion="integer"
          android:targetSdkVersion="integer"
          android:maxSdkVersion="integer" />

Solution 9 - Android

I had this problem too. What worked for me was to first un-check the previously selected SDK version before checking the new desired version. Then click okay.

Solution 10 - Android

As Mike way says. Change target BEFORE doing anything in your project that requires a higher target like android:installLocation="auto".

Solution 11 - Android

as per 2018, the targetSdkVersion can be set up in your app/build.gradle the following way:

android {
    compileSdkVersion 26
    buildToolsVersion '27.0.3'

    defaultConfig {
       ...
       targetSdkVersion 26
    }
    ...
}

if you choose 26 as SDK target, be sure to follow https://developer.android.com/about/versions/oreo/android-8.0-migration

Solution 12 - Android

right click on project->properties->android->select target name --set target-- click ok

Solution 13 - Android

to get sdk 29- android 10:

Click Tools > SDK Manager.

In the SDK Platforms tab, select Android 10 (29).

In the SDK Tools tab, select Android SDK Build-Tools 29 (or higher).

Click OK to begin install.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDonal RaffertyView Question on Stackoverflow
Solution 1 - AndroidRyan ConradView Answer on Stackoverflow
Solution 2 - AndroidAlan WillView Answer on Stackoverflow
Solution 3 - AndroidScott C WilsonView Answer on Stackoverflow
Solution 4 - AndroidRankView Answer on Stackoverflow
Solution 5 - AndroidstealthcopterView Answer on Stackoverflow
Solution 6 - AndroidnotBananaView Answer on Stackoverflow
Solution 7 - AndroidMike WayView Answer on Stackoverflow
Solution 8 - AndroidjavaProgrammerView Answer on Stackoverflow
Solution 9 - AndroidAdukraView Answer on Stackoverflow
Solution 10 - Androiduser1164035View Answer on Stackoverflow
Solution 11 - AndroidPiotr ZView Answer on Stackoverflow
Solution 12 - AndroidShubhamhackzView Answer on Stackoverflow
Solution 13 - AndroidbatshevaView Answer on Stackoverflow