Home » Android » How to change target build on Android project?

How to change target build on Android project?

Posted by: admin November 30, 2017 Leave a comment

Questions:

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?

Answers:

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)

Questions:
Answers:
  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.

  2. 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

  3. Rebuild your project.

    Click the Project on the menu bar, select Clean…

  4. 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.

Questions:
Answers:

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.

Questions:
Answers:

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" />

Questions:
Answers:

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" />

Questions:
Answers:

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.

Questions:
Answers:

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

Questions:
Answers:

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" />

Questions:
Answers:

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.

Questions:
Answers:

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

Questions:
Answers:

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