How to change "Compile with" option for Android app - android

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.

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

Lowering minSdkVersion when using APIs introduced after, fails to cause errors

I created an app compatible with API level 14+. I want to now make it compatible with API level 10+. I know for a fact I am using API calls introduced in 14, so I was planning on lowering the minSdkVersion first, and then fix the errors that it caused.
The only problem is, when I lowered the minSdkVersion in the manifest, no errors are thrown. It used to throw errors when I did this, but now it isn't for some reason.
Is there a way to force Eclipse to check my API calls and make sure they are compatible with the current minSdkVersion?
Thank you.
Right-click over the project in Package Explorer, and choose Android Tools > Run Lint.
If you change the minSdkVersion it won't change what sdk the app in compiled against, only the api levels that the application can be installed on.
If you want to compile against a lower sdk change the targetSdkVersion.
Links: Difference between "Build Target SDK" in Eclipse and android:targetSdkVersion in AndroidManifest.xml?
and http://developer.android.com/guide/topics/manifest/uses-sdk-element.html also Android Min SDK Version vs. Target SDK Version

How to set up an Android project with Eclipse Juno

My professor and I are using different versions of Eclipse apparently and I'm having trouble matching his project requirements up to my Eclipse.
His requirements are: "You are recommended to use the 2.3 SDK and test your app on 4.0 emulators..."
I am using Juno and this is what I see:
Is this set up right?
So that people don't just tell me to email my professor as an answer, what is the difference between target SDK and "compile with" conceptually? I'm unclear on why they are separate options.
How can I compile with 4.0 but have a lower target? That doesn't seem right.
If you set your minimum reqd SDK to API:9 too then you'll be closer to what your teacher says. What you have looks OK.
Usually your "compile with" level should not be higher than the target SDK level. (It's often the same as the minimum required SDK, but there are sometimes reasons to set it higher.) The idea for "compile with" is to allow you to target higher levels and restrict your API calls to a lower level for compatibility.
Otherwise, your choices look consistent with what the prof is recommending. Note that none of these settings have much to do with the emulator version. You set that when you create an AVD and as long as the emulator version is at least the "minimum required sdk", the project should run (barring bugs, of course).

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.

Android & Eclipse: Changing application API level

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.

Categories

Resources