Android & Eclipse: Changing application API level - android

I am having some difficulty in figuring out how to change an applications API level - the only available level I can configure is level 15. This is not so good as the device I am attempting to test software is running on level 8. Does anyone know I might go about fixing this problem?
Thanks,
J

Have you installed other platform versions?
You can change the build target by right clicking the project ->Properties->Android:

Your question can have multiple interpretations. Here's some hints:
Application Build Target API Level : when you create your application, eclipse ask you that. You can build it with a certain api level. This option is choosen in eclipse direclty when you create your project. This tells your application that it may only be available to devices with this api level since it is the level that is put in minsdk. The target is in the file project.properties.
Application MinSDK : This is the minimum version of android your application can run ( Note : It may not be the application build target level because you can create an application with target api level 15 and make it runnable with minsdk in level 7 and manage backward compatibility or avoid level 8 to 15 new features). This can be modified in your android manifest xml file.

Adding a new site replacing https by http will not work to download
platform (it's not meant for this, we're making the UI clearer).
If you really cannot download over https using r5 (there was a bug in
r4 and before but we fixed it), go to the settings page (in the
standalone version of the SDK Updater), and check "Force https sources
to be fetch using http"

Change the value of the "target" attribute in the project.properties(or default.properties) file.
OR
if you use eclipse; right clic on your project ->Properties->Android->Project Build Target

Check whether the required level 8 software is installed on your machine.
In eclipse goto Window > Android SDK Manager.
In the show column make sure that Update/New and Installed check buttons are checked.
If not installed then install the required API level. Then on the project, goto Properties and select Android on the left pane. Select your API level and click OK.

Related

Android Error: This template requires a build target API version of at least 14, and the current version is 7

I installed the SDK and I like work with API 7 but when I want to create a new Activity Main I have this problem and I can't create a new Activity, thanks.
This template requires a build target API version of at least 14, and the current version is 7
In the log, I can read this:
Not targeting the latest versions of Android; compatibility modes apply. Consider testing
and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details.
I recently faced the same problem when creating the activity or while setting the new android application project and able to solve this problem in this manner.
I checked the system image folder which is in sdk/system-images,build tools folder-sdk/build-tools and found that these folder does not have the API's that i am using at Minimum required sdk,target sdk,compile with. In each of these you need to provide the API no. or Android version.
So check that the API's that you are using for(Minimum required sdk,target sdk,compile with) are installed and also check the system-images and build-tools folder should have these API's
if you have done this your problem must be solved.
You probably set Build SDK to API 7. Normally, you should set Build SDK to the highest possible API level and set the other SDK, it's called Run SDK or don't rememeber how to the minimum API version you want your application to run on.
I ran into this same issue even though I had set in my AndroidManifest.xml minSdkVerion to 13 and targetSdkVersion to 19. What fixed it for me was in Eclipse going to Project > Properties > Android then checking the highest API level in Project Build Target box (API 19 for me).

How can I know which API level I am using with Eclipse ADT

I am wondering how can I know which API level I am using with my ADT. I posted a question about an error that occurred when I was trying to run a sample app source codes which use a View (http://developer.android.com/shareables/training/Animations.zip). Someone asked me which API level I am using? So how do I know this?
When you make an Android app, you have to choose the minimum API level. You can check this in the first lines of your manifest.
You can check the API level of an android device under Settings->about phone. This will give you the Android version number (which is not the same as the API level).
You can look for the API level here when you have the version number.
If you want to get it programatically you will have to do something like this:
Integer.valueOf(android.os.Build.VERSION.SDK);
The Android SDK library is included in the project when you create a project. From there you can find out which OS version you are using and from that the api level.
If you are in eclipse and ADT is installed then right click on the project and go to properties. There select Android in resources. You can find the API level corresponding to the target OS version.

How to change "Compile with" option for Android app

I have application created with "Compile with" option set to API 19. Now when I try to run the app for API level set to 15 or below, I am getting errors. Errors say it is not able to find few attributes, which I guess due to downgrade of API, it is not able to identify few attributes.
So, is there any way through which I can run my app with lower versions of APIs?
How can I change "compile with" option already set while creating the app?
The "compile with" SDK definitions depends on your build tools. For Eclipse/ADT it's defined in project.properties.
However, you can really keep it at SDK 19. Instead, set the minSdkVersion in your manifest to the minimum SDK version you want to support. Run Android Lint on your project - it will report errors where you're using an API feature not available in your min SDK version.

Compiling with Android 4.X but supporting API Level 9

I'm working on an application which uses ActionBarSherlock. As it's documentation points out:
[...] the library requires that both it and your project are
compiled with Android 4.0 or newer. The project also requires that
you are compiling with JDK 1.6 in both your editor and any build
systems that you may be using.
So, that means I'll compile my application (and the library) against Android 4.X but in my Manifest, I declare that I'm targeting (e.g.) API Level 9.
This all works fine and well but there is something that disturbs me. From the FAQ:
What API level should I target in my manifest when using the library?
Targetting API level 11 or newer is required as it will cause Android
to automatically add the native action bar when run on newer devices.
Since you will be compiling against new APIs but your app will likely
be run on devices with older versions of Android extra care must be
taken to either avoid using or properly check and call any methods
that were introduced after your minimum SDK version.
That means, that I'll have to manually check every method call, so I don't use any that are not available in my targeted API Level (9 in my case)? This sounds wrong to me.
Is there a way to tell my IDE (IntelliJ), that I'm only using the API Level 9 (so I don't get any auto-completion for non-existing methods/classes and don't use them by accident) and then choose to compile it against another Android version?
Or can I use some automated checks (which run at compile time) to check for that?
The ADT's lint feature should take care of this by warning when API calls are being made for the wrong API version.
You should be compiling both ABS and your project with the latest SDK available (at present, 4.1). Your manifest should have a targetSdkVersion as high as possible (ideally matching your compilation SDK) and your minSdkVersion should be set to the lowest version you support.
Lint is partially integrated with IntelliJ IDEA and is also available as a command line tool.
You temporarily set your target SDK to the various lower ones and debug with it. Your final build then is with the latest SDK.
Set a Build target similar to that you have mentioned in your manifest.
as always , you should set the targetSdk to the maximum available on both the manifest and the project.properties file (as recommended by google on one of their videos) , so that the ADT&SDK would be able to optimize the ADK accordingly.
set the minSdk to the one that you wish to support your app from , and let Lint to tell you if there are any problems in case you use too-new-features.

Confused about Min SDK Version

I am referring to the http://developer.android.com/resources/tutorials/testing/activity_test.html regarding activity testing.
My avd is showing platform-2.3.3 api level-10.
In eclipse when i click on create new android project and select create project from existing source and then browse to the samples\android-8\Spinner it prefill the Min Sdk Version with 3 and when i select the target platform 2.3.3 api level 10 it shows following warning:
The API level for the selected SDK target does not match the Min SDK Version.
I have checked the spinner manifest file it contains
<uses-sdk android:minSdkVersion="3"/>
I have tried different combinations like changed the sample folder and changed the target but it shows the same warning.
I want to know how to rectify the warning so that my sample run?
Please help me on this
min sdk version can be lower than target sdk version.
see this link
The app uses level 10 sdk I guess and the minsdklevel specified is 3 that is the reason for the warning. This warning can be ignored.
You can run the app on any version of android with level >= 3 as long you dont use any api calls which where introduced in level 10.

Categories

Resources