Does Android APIs have compatibilty for its old versions? - android

I'm downloading Android SDK , and want to know if Android's APIs has compatibility with its
Previous versions ? i.e. if i installed Android API 16 can I use the application on
Android 4.0 (API 14) ?

You can run older API versions on newer systems, but not vice-versa. For example Android 4.0 can run programs made for Android 2.3.3, but Android 2.3.3 can't run Android 4.0 programs.

You have to define a minimum sdk level in your android manifest. Every version from this upwards supports the app. You can only use classes and language elements that are supported by this specified version.

This is controlled by the following in your manifest file:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
This means:
1) your app won't run on any Android whose version < 8.
Android OS whose version < 8 will not let your app be installed.
2) Your app is using Android API as of Android version 15.
In your code you can, however, check the Android version (using Build.VERSION.SDK_INT) and if it is < 15 then do not run certain code.
This is often done so the app can use newer features if run on newer Android versions yet it can run on older versions as well.

Not all components are backwards compatible, but for backwards stuff, look at the following
I found the most useful library out there for making an android app backwards compatible.
Its called Actionbarsherlock, it gives you all android 4.1+ functionality all the way back to 2.1 (what i am developing as a min version)
Its fairly simple to use, very well explained on their website:
http://actionbarsherlock.com/
Enjoy

Related

Is it possible to support newer android sdk versions in react-native?

I was following setup guide for android in react-native documentation
and have it up and running correctly using suggested SDK v23
However there are much newer SDK versions available, I would like to set v23 as a minimum SDK version, but use latest one as my main one.
Being new to android I'm not sure on how to achieve this, what steps should I take? I can see option to edit sdk versions in some xml files and can download latest one using Android Studio.
As a side note, what are my limitations of using SDK v23? Will it not work on newer devices, do I loose out on performance etc... ?
According to some sources React Native does support up to API level 25, but there seems to be some disagreement on the issue. So according to official sources, React Native only supports Android API level 16 to level 23.
I haven't used React Native myself, but assuming versioning works the same as native development, an application with a compileSdkVersion lower than the version it is running against will run fine. The only limitations on the application would be that it would be unable to access the new features and APIs introduced by those higher SDK versions.
For example, Android 8.0 (API level 26) introduced a new Picture-in-Picture API, but the method used to enter picture-in-picture mode would not be available in code compiled against API level 23. Some new features may effect performance (usually positively), but an application compiled against API level 23 won't perform any worse on on a device running on API 26 than one running on API 23.

Which Android API to use for all device compatibility?

I have downloaded SDK for Android 4.4(API Level 19) and developed one android app.
But on some old devices it is crashed as they are using OS (Android 4.0 and lesser)
I have already specified below then also it is crashed on old OS devices
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19"/>
Is there any other setting I need to do to run my app on old devices?
Setting the minSdkVersion and TargetSDKVersion isn't enough. In every new Android release new API's and classes are introduced in the SDK. However older versions of Android don't have these new changes. This is the reason the Android team have introduced the Android Support Library, this enables backward compatibiliteit of new features on the older Android versions. My guess is that you're using API's and/or classes only available in the newer SDKs.
Please reffer to: Support Library | Android Developers

What factors are important in choosing target android OS for development

What do I need to consider before choosing the target android OS for app development?
This is my understanding of how to do it and any clarification would be appreciated:
Determine which OS version is currently in use the most. Look at distribution graphs etc.
Target that version.
that is what I read all the time, but I have some questions.
Suppose 4.0 is the version that is the most used among android phone consumers so I should target 4.0. Now, suppose that I don't use features that are unique to 4.0. will my app work with any version below 4.0 including 1.5, 2.3 etc.? Consider the reverse situation. If I target version 2.3 and if my app uses only features that are available to 2.3 will my app work on phones that are running version 4.0 even though I will not be using features that are unique to version 4.0?
thanks.
have a look at your AndroidManifest.xml
There is a targetSdkVersion and minSdkVersion if you want to support all devices running 2.2 and up then set minSdkVersion to api level 8 (android 2.2)
but in general, its a good practice to develop against the latest api as target (currently API 19, Android 4.4), so you can ensure it will work from your chosen min up to the newest OS api
so if you want to support at least Gingerbread up to KitKat do this in your manifest:
<uses-sdk android:minSdkVersion="9"
android:targetSdkVersion="19" />
and develop against api 19 :)
Suppose 4.0 is the version that is the most used among android phone consumers so I should target 4.0. Now, suppose that I don't use features that are new to 4.0. will my app work with any version below 4.0 including 1.5, 2.3 etc.?
Only if you don't use APIs that were introduced after the earliest version you want the app to run on.
If I target version 2.3 and if my app uses only features that are available to 2.3 will my app work on phones that are running version 4.0 even though I will not be using features that are unique to version 4.0?
Yes. Some functions get deprecated in newer OS versions, but most of them still work in newer releases for keeping compatibility.
I feel the thing to stress here is that Android is backwards compatible, so newer versions will almost be able to run apps developed for older OS versions.
The target version is the highest version you have tested it on. You should always target the absolute latest if you can. The min version is the lowest version that will be able to install the app.
So in the manifest, you would typically have something like this:
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="19" ...
Pick the minSdkVersion based on the features that are absolutely required for your app to function.
So you might wonder what the purpose of targetSdkVersion is. One reason is if your app has some optional features that are in later versions of the SDK. targetSdkVersion will allow you to use those later features, but you will need to protect those method calls with a check against the device's SDK with a call like
if (Build.VERSION.SDK_INT >= 11)
myMethodThatUsesFeaturesOnlyInHoneycombAndLater();
Another reason is that sometimes the Android team makes changes to some of the defaults in various settings on your classes, but to maintain compatibility for future versions on which you have not tested your app, they keep the old default if your app doesn't claim to target this later version.
For example, after Honeycomb, the menu is supposed to be integrated with the action bar. But old apps that were compiled with earlier SDKs have not been tested with Honeycomb or later, as proved by them having a targetSdkVersion of less than 11, so the OS knows to display the old style menu. Once this developer decides to test their app on a more recent targetSdkVersion, they update the value and the OS can trust that they have tested it on Honeycomb, so it can safely show the new style menu.

if i use android 4.1.2 (API 16) Android SDK will my apps work on Android 2.3

if i use android 4.1.2 (API 16) Android SDK will my apps work on Android 2.3 phones. i have downloaded android 4.1.2 sdk tools and other packages.
You will need to set the minimum SDK attribute in your manifest to 2.3 to ensure you app will work on earlier versions of the OS.
Your app will work fine, assuming you are not using any API calls from a later version.
The Android Dev team suggests you always compile against the newest version you can support. So, you are on the right track.
So bottom line, you are on the right track, just make sure to test your app against a 2.3.3 version of the emulator to ensure you are not using any un-supported API calls.
No, if your minimum sdk version is 16 it wont work on that android version.
if you want it to work on that specific version then set the minimum sdk version to 9. You can change this in the apps manifest file.
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="21"
/>
If you are getting errors probably saying "This code uses the minimum sdk to be api 16 or higher"
find alternate ways to modify the code for older android phones. If that does not work then dont support old version of android maybe.

Is it possible to run android 3.1 application to run in android 2.1 device?

Is it possible to run android 3.1 application to run in android 2.1 device? I heard that there is a compatibility in android. And I used API level 3.1 in my application.
There are two things: the compatibility mode: http://developer.android.com/guide/practices/screen-compat-mode.html and the compatibility libraries: http://developer.android.com/sdk/compatibility-library.html
The compatibility mode takes care of adjusting the screen to fit the device on post-3.0 devices even if the app has not been tailored for the specific screen. The compatibility library ports some of the Honeycomb features back all the way till Android 1.6.
Besides these, standard backward compatibility concepts apply.
yes you can do this . Use the min sdk version in your manifest file to API level 2.1.
Add the following line in your AndroidManifest.xml file
<uses-sdk android:minSdkVersion="7" />
this will allow your app to run in any device with api level 2.1 or higher.

Categories

Resources