Can anyone explain regarding the Minimum Required SDK, Target SDK , Compile with options while creating an application.
If i set the minimum required SDK as API 8, Target SDK as API 16 and Compile with API 17,
will it work on Froyo devices in adroid?
If i want to use the methods introduced in API 16 or Library uses API 16, and want my app
to work on Froyo or ICS devices, how can i achieve this?
Thanks in advance.
You can use API-Level 16 methods only on devices that are Level 16 and higher. But you can check in your app and only call them when this is the case. Look into my small test-app which uses API-11-methods and runs from API-3 and up.
http://code.google.com/p/android-change-log/source/browse/trunk/src/sheetrock/panda/changelog/ChangeLog.java
Look at lines 40-41, 144-145 and 324-341. You don't need any third party libraries for this, but you need to put your higher API code in a separate class (lines 324-341).
Yes. But be careful not to include API higher than Froyo in your application
From my understanding, you can't, unless you use third party libraries. There are useful libraries out there which help you realise that:ViewPager and ActionBarSherlock.
Yes ofcourse for first question. If you use like this.
android:minSdkVersion="8"
android:targetSdkVersion="16"
For second. you can go for third party library if you import it, surely will work.For eg:
special features introduced in android 4.0 with tabs and swipe.But to overcome that
actionbar sherlock library been introduced which support in all version and in github.
Hope it helps you.
Related
I made my game work on Android TV, it required Leanback library, which wants minSdkVersion to be 17. I must support API 16 too. What can I do?
When building, I get an error this suggestion:
Suggestion: use tools:overrideLibrary="android.support.v17.leanback" to force usage
What exactly does it do? Does it actually make my app still support API 16? What am I losing?
You can find the detailed information here.
Here is what it says:
tools:overrideLibrary marker
A special marker that can only be used with uses-sdk declaration to
override importing a library which minimum SDK version is more recent
than that application's minimum SDK version. Without such a marker,
the manifest merger will fail. The marker will allow users to select
which libraries can be imported ignoring the minimum SDK version.
And you need to do the following: In the main android manifest :
<uses-sdk android:targetSdkVersion="14" android:minSdkVersion="2"
tools:overrideLibrary="android.support.v17.leanback"/>
Hope this helps.
I'm developing a Android library and I want to support as many API versions as possible. I have stumbled upon a problem with AsyncTask and found an answer here on SO. The proposed code to use is:
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
task.execute(params);
} else {
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
}
My question is, how do I include the proposed code AND support lowest possible API level? What API version should I reference? What should I write in the uses-sdk tag inte manifest?
Since the field THREAD_POOL_EXECUTOR in AsyncTask is only available from API level 11. Can this code be compiled to a lower level?
Thanks!
Assume that you line below exists in you manifest
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"/>
This means that you are using features from API-17 but to ensure backwards compatibility your application may start on minimum API-8 (Froyo).
According to your example, using THREAD_POOL_EXECUTOR for API-17 or lower is OK. And running your code with Froyo device is OK too. Because THREAD_POOL_EXECUTOR field will not be used in this case.
In the manifest set android:minSdkVersion="minimumApiYouNeed", this is the lowest api you want to support, and the android:targetSdkVersion="maximumApi". This is the api that will be used to compile the code. This way you will be able to do things like what you wrote there, if you ever write something that is not supported by the minimum api, the editor will notify you, but it will work well if you do the checking it will work well
You will have to use API level 11 or higher unless you can find a library that works on an earlier API level that provides the THREAD_POOL_EXECUTOR implementation. Also, check to see if Google provides any backports or support libraries that would allow this to work before API 11.
This supports Android back to 2.1 (sdk version 7), but compiles the code against sdk version 17 (HoneyComb). You would have to add that tag to your manifest, of course.
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="17" />
Your project.properties should include this line:
# Project target.
target=Google Inc.:Google APIs:17
I want to add android:tragetSdkVersion= "14" in my manifest but I'm consufed as initially I developed my application for 2.3.3 version. So I used TabActivity for that. But TabActivity is deprecated in 4.0 version and according to the documentation, including android:tragetSdkVersion= "14" means system will not impose any forward compatibility to the app. So I wonder if it is good idea to include android:tragetSdkVersion= "14" in my manifest.
If you want to make it working on sdk 14, why are you leaving TabActivity in your code?
Otherwise, don't make sdk14 your target, and better to prevent users with version 4.0 or higher to install your application
You should use the v4 support libraries if you target higher SDK versions and also provide a minSdk:
<uses-sdk android:minSdkVersion="integer"
android:targetSdkVersion="integer"
android:maxSdkVersion="integer" />
here is info about the support libraries
http://developer.android.com/tools/support-library/index.html
I am attempting to set up ActionBarShelock for the first time using Eclipse on Windows 7.
I followed these instructions: http://actionbarsherlock.com/usage.html
ActionBarSherlock project.properties:
android.library=true
# Project target.
target=android-15
ActionBarSherlock AndroidManifest.xml:
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="11"/>
My error in Lint: Call requires API level 11 (current min is 7): android.widget...
Or if I ignore the error on ActionBarSherlock and import it as a library then I cannot compile my project because any references to the library are not recognized and I get no resource errors.
I looked up many people with similar problems and it was always an API build target error. Thank you for your suggestions!
A few things:
Make sure you are compiling your application with Android 4.0 or newer (API 14+). You must do this in addition to just the library.
Ensure you are calling getSupportActionBar rather than getActionBar. This is likely the source of your errors for lint.
While targeting API 11 is valid, many things are gained by targeting 14 or higher. Try to do that if you can.
I found it! The JDK compliance level was set to 1.5. After setting it to 1.6 it worked.
It says this right in the Action Bar Sherlock website in the requirements section but I made the error of assuming Eclipse was using the latest JDK settings.
Definite beginners mistake.
Thank you for your help.
Are you using an old version of ActionBarSherlock perhaps? As the current version, 4.1.0 has the targetSdk set to 15.
I think some older version can have a problem with newer ADT/lint or similar.
As recomended here http://developer.android.com/guide/practices/screens_support.html for compatibility reasons my AndroidManifest.xml contains this:
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4"/>
This generates warning in eclipse:
Attribute minSdkVersion (3) is lower
than the project target API level (4)
Are there any means to suppress this warning or get rid of it any other way? It is really annoying.
In short, there is no built-in way to do this that I know of.
Here's a discussion from last August.
And here is a Xavier Durochet's response.
It looks like you can manually remove it according to Mark Murphy's response in the first thread:
Or, you can modify SetupTask.java, eliminate this test (lines 297-308 in
the code indexed by Google Code Search), and build it into a custom
version of the Android Ant extension
There is a feature request that may deal with this, but who knows when it will be implemented.
The answer from 2011 is no longer accurate. It was fixed in ADT 17 according to this bug.
This warning is an usual one. I am using minSdkVersion to support Android 1.5 and I am building for Android 1.6 to support small screens. You can build your application with the latest Android 2.3 library, but still support a lower version.