How to prevent Android app from running on specific Android API version? - android

We know that uses-sdk attributes in the manifest file can be set for filtering on Google Play:
<uses-sdk android:minSdkVersion="integer"
android:targetSdkVersion="integer"
android:maxSdkVersion="integer" />
and android:minSdkVersion can prevent app from installing on Android OS.
However android:maxSdkVersion is deprecated from Android 2.1 (API7), so it won't be recognized by Android OS anymore.
Then, what is the best way to set an upper limit of Android API version for running an app?

Related

How to work on latest sdk and support older ones

I need to suppoert api level 10, and working with latest sdk to provide new device features (only if sdk of device is new).
on manifest I choose min version 10.
The problem is that the application is not installed succesfully on the old sdk devices.
Whne I debug on those devices it works, The installation of signed aok fails.
Any suggestions?
Use this in your manifest file
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
If your application uses any API's that are not available on older Android versions, then you should try to use Support Libraries or just give up on those devices. If the application does run on older emulators in debug mode, then you can just change the minSdkVersion in the manifest to a lower one. Hope this helps.

Sell Apps with sdk target 13?

I would like to know if phones with Android 2.3 or lower could download Apps with:
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15"/>
and Build Target 15?
Becuase I have to do so to use the AdMob jar.
Thanks
Yes they can, this is the goal of the android:minSdkVersion attribute. It prevents users with an older android version to download and install the app.
Yes, any device running SDK version 7 and above will be able to install your application. The targetSdkVersion attribute doesn't restrict devices from installing your application. Instead, it specifies the maximum API level on which your application should be able to run on.
Just be careful that you protect earlier versions of Android from making use of the new methods provided in SDK 15, as this will cause your application to crash.

Using Apache Cordova/PhoneGap with Android 2.x

It seems that it isn't possible to create a PhoneGap app for Android 2.x. Is that right?
For running android applications using phonegap build your application as Android 4.0.3 and set the minimum version to the lower version whatever you want. Basically Android 4.0.3 build does not affect the functionalities of the older android version. And this app perfectly works with android lower versions.
I usually do like this in manifest.xml
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15"/>
Okay - so answering my own question. You need Android API mark 15 installed for PhoneGap to work.
But . . . you can change the AndroidManifest.xml file in the application to make it backwards compatible.
For example
<uses-sdk android:minSdkVersion="10" />
will be compatible with 2.3.3

How to stop ICS users from downloading my app

The app that I have in the store right now does not work quite right in ICS. While I fix it I would like to block users who have ICS from downloading and buying it. I emailed Google and they say that this is possible but they are vague about how to do it. I know how to put a Minimum SDK so that only people who have version x or above can download the app, but I cannot seem to locate how to do that in reverse. Is this possible?
Define android:maxSdkVersion in your manifest to restrict the upper limit.
For example:
<uses-sdk android:minSdkVersion="8" android:maxSdkVersion="10"/>
Now the app will only be available for devices running Froyo and Gingerbread versions of Android.
http://developer.android.com/guide/appendix/market-filters.html
You can set filters in the market. i.e. ICS user wont see your app ^^
Use android:maxSdkVersion="13" in your manifest
Check this page on the Android Developers documentation.
Just as you can set a minimum SDK version, you can set a maximum SDK version:
<uses-sdk android:minSdkVersion="integer"
android:targetSdkVersion="integer"
android:maxSdkVersion="integer" />
You can define a maxSdkVersion with the uses-sdk tag in the AndroidManifest.xml file. It is documented in the developers guide.
<uses-sdk android:minSdkVersion="integer"
android:targetSdkVersion="integer"
android:maxSdkVersion="integer" />

android app to be runned only in 2.2 and 2.1 versions

in my app i have two set of designs. One design is for the android devices version of 2.1 and 2.2, the other design is for devices of 2.3 and above.
Now the problem is i take a build setting as follows in my manifest file
<uses-sdk android:minSdkVersion="7" />
<uses-sdk android:maxSdkVersion="8" />
My android project properties in been set to 2.2. When i run this build in 2.3.4 devices it gets run properly. How does it happens?
I am planning to submit the app with multiple apk files in market. How to block my apps
one build to be run in 2.1 and 2.2 and
the other build to get run in 2.3 and above
I just tried setting only <uses-sdk android:minSdkVersion="7" /> or <uses-sdk android:maxSdkVersion="7" /> or <uses-sdk android:maxSdkVersion="8" /> or
<uses-sdk android:targetSdkVersion="8" /> then also it gets run in all devices of 2.3.4 devices
Please help me friends....
Hey as per the android documentation :
Introduced in: API Level 4
Future versions of Android (beyond Android 2.0.1) will no longer check or enforce the maxSdkVersion attribute during installation or re-validation. Google Play will continue to use the attribute as a filter, however, when presenting users with applications available for download.
You might want to have a look at last few lines of this link
EDIT1:
Also have a look at the Warning
Warning: Declaring this attribute is not recommended. First, there is no need to set the attribute as means of blocking deployment of your application onto new versions of the Android platform as they are released. By design, new versions of the platform are fully backward-compatible. Your application should work properly on new versions, provided it uses only standard APIs and follows development best practices. Second, note that in some cases, declaring the attribute can result in your application being removed from users' devices after a system update to a higher API Level. Most devices on which your application is likely to be installed will receive periodic system updates over the air, so you should consider their effect on your application before setting this attribute.
According to documentation:
Future versions of Android (beyond Android 2.0.1) will no longer check or enforce the maxSdkVersion attribute during installation or re-validation
http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#max
Alternatively, you can check API version at runtime and block the use of your app.
http://developer.android.com/reference/android/os/Build.VERSION.html
You can install it using the adb or directly downloading the apk through a website.
The minSdk and maxSdkVersion is checked only when its installed from Android market. Devices with versions out of this range will not see your app in the market.
You need to use PackageManager Class for Version Specific Application. There is a method called getPackageInfo() which returns an object of PackageInfo. From this PackageInfo, you can fetch values of Version Name & Code.
Now you have values, so use logic and implement it

Categories

Resources