I'm writing an application that is compatible with Android 1.6, but I would like to give users running Android 2.2 the option of moving the application installation to their sd card.
How can I compile my application for 1.6, but still allow 2.2 users to install it to their sd?
In your manifest:
In <manifest>, add "android:installLocation="preferExternal"
Keep your current uses-sdk as "<uses-sdk android:minSdkVersion="4">"
Then go to Project > Properties > Android (on the left), change the build target to 2.2, and you're all set.
Your project will build using 2.2 (but still only requires 1.6), but devices running 1.6 will simply ignore your new "installLocation" setting in the manifest. Just be careful not to add any 2.2-introduced material in your actual code, since the compiler will no longer catch it.
This is not quite as seamless as the developer guide suggests.
First, the application does not build when the installLocation is present in the manifest and the build target is set to anything other than 2.2:
error: No resource identifier found for attribute 'installLocation' in
package 'android'
So in order to test backwards-compatibililty by setting the build target to 1.6, the manifest must be edited as well.
Second, once the build target is set to 2.2, I don't get to pick an emulator with a lower API level for testing. I can still manually start an 1.6 emulator and run the app on it, though, but I am curious if my app will appear on Android Market for 1.6 devices if my build target is 2.2 (even though minSdkVersion=4). I don't have an actual device to test. Can someone confirm that this does not affect the availability on the market?
Lastly, this warning remains:
Attribute minSdkVersion (4) is lower than the project target API level (8)
Related
I am building an Android application which I compile against API-17: project.properties contains
target=android-17
I am slightly confused because I can download and execute the application on an Android phone running Gingerbread 3.3.6, API 10. Can perhaps someone clarify?
You are able to run it on API 10 as your android:minSdkVersion would be less than 10. It is
an integer designating the minimum API Level required for the application to run.
See http://developer.android.com/guide/topics/manifest/uses-sdk-element.html
To differ between target in project.properties and android:targetSdkVersion
target=android-sdk version in project.properties file indicates Eclipse will not allow use methods or classes from sdk higher than this one.
android:targetSdkVersion attribute informs the system that you have tested against the target version and the system should not enable any compatibility behaviors to maintain your app's forward-compatibility with the target version. The application is still able to run on older versions
Source: What is the difference between the 'target' settings in the 'project.properties' file and the 'android:targetSdkVersion' tag in the manifest?
Because target=android-17 is compilation target not a MIN-SDK.
Min-sdk version will be Android 2.2 so you are able to download and execute on 3.3.6, API 10
Previous answers are valid.
I'll only add that there's one condition to that: That the code of that application should be written in API-10 compatible code. The application shouldn't call classes or methods that are not defined in API-10 otherwise it will crash when doing so.
Then, Android has many way for developers to work around compatibility, such as the support libraries and detecting device version to write specific compatibility code.
I've built an Android application in eclipse. Before starting the project I selected the 2.3.3 api. The code is very basic.
A friend of mine asked to have a copy, but he's using 2.2, do I have to rebuild the project in 2.2 or will it work just fine if I send him the APK build with the 2.3.3 api?
change
<uses-sdk android:minSdkVersion=.... />
in the android manifest to
<uses-sdk android:minSdkVersion="8" />
Change the Project Build Target to 2.2, in the Properties Menu of your project in the Android drill down.
You should only get errors if you used methods that were introduced with the level 10 API (Android 2.3.3). Since you pointed out that your application is very basic, I highly doubt you'll run into major problems.
From the docs
Selecting a platform version and API Level
When you are developing your application, you will need to choose the platform version against which you will compile the application. In general, you should compile your application against the lowest possible version of the platform that your application can support.
You can determine the lowest possible platform version by compiling the application against successively lower build targets. After you determine the lowest version, you should create an AVD using the corresponding platform version (and API Level) and fully test your application. Make sure to declare a android:minSdkVersion attribute in the application's manifest and set its value to the API Level of the platform version.
So in short, you'll have to recompile it
If you go to the properties for your project and then select the Android dialog, you can change the API which your project is using. Provided you have have it installed.
In the AndroidManifest file set android:minSdkVersion to 7. In this way you force it to run in compatibility mode on devices that have lower version than the target mode(which is 8 in your case).
I'd like to support Android 2.1 devices, but also would like to enable users to move my app to the SD card if they have Android 2.2+
The attribute for that is android:installLocation="auto"
How can I still support 2.1 while enable this attribute for 2.2+?
EDIT: I've set it with build 2.1 and I get a compilation error and I cannot launch my app. The reason I don't want to increase the build target to 2.2 is because if I do that and the app gets installed on 2.1, a bunch of exceptions are thrown and it crashes. I want to make sure that the app works perfectly on 2.1. For an example of what I mean, please see NoSuchMethodError: String.isEmpty
An exact solution for you is in Android Manual.
It can be done, set your minimum API level to 7 and your target API level to 8, more details are in the Dev Guide.
I am working on application which should go into android 2.2(Froyo) and android 2.3(GingerBread) devices.
I have built application with android 2.3 SDK , and Installed the same application in 2.2(Froyo) and 2.3 (Ginger Bread) devices.
In both the devices application installed successfully and it is working properly.
I want to know if we install the higher version build into lower version devices is there any chances to face problems.
Till now I didn't found any issue with this.
I didn't used the MIN:SDK version field in the Manifest file.
If you want only users from version 2.2 and up to download your app, just make sure your minimum SDK version is 2.2 by putting this line in your AndroidManifest.xml:
<uses-sdk android:minSdkVersion="8" />
If you want an upper bound limit as well, you can add:
android:maxSdkVersion="10"
So users with Android SDK version 2.2 up to 2.3.3 will be able to install your app.
Regarding problems: If you're using a specific SDK API then just make sure to add an if clause around it to make sure you're on the right version. The best thing to do is change the target to 2.2 just to see if you have any compilation errors... Then you'd know what to change.
Then just fix the problems, change back to 2.3 and build.
If you don't specify the minimum sdk attribute in the manifest file users with 2.2 won't see your application on the market. It specifies that your application supports 2.2 so that users can see the app on the market.
Make sure any functionality that you use from 2.3 has an alternative functionality so that 2.2 users have the ability to actually use your application.
yes , u can find problem ,
try to install that app on android 1.6
it's about API version , there will be some APIs in your app doesn't supported in a lower API version
I'm building an application, and need to support both 1.5 (Magic and Hero) and 1.6 (Tattoo) devices.
As Android SDK is forward compatible, it seemed logical to build against Android 1.5 SDK, and expect application to work on Tattoo.
While that's true, (I tested app, it works ok), I'm now having problems on Android Market.
On Tattoo, Market search by default filters android apps that doesn't have explicit support for small screens defined in AndroidManifest.
Problem is that attribute exists only on Android 1.6 SDK, so Building against Android 1.5 SDK is no an option anymore.
How safe is to build App agains A1.6 (with minSdkVersion="3") and run it on 1.5 devices?
Is there anything else I should take care of except just change target SDK?
Make sure you don't mix up minimum SDK version and target SDK version as these are different options.
For example, I use the following setting in the application for my manifest:
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4"/>
The documentation says the following about targetSdkVersion:
In some cases, this allows the application to use manifest elements or behaviors defined in the target API Level, rather than being restricted to using only those defined for the minimum API Level.
So by specifying targetSdkVersion of 4 but having a minimumSdkVersion of 3 you'll have an application which should work on 1.5 devices and 1.6 small screen devices.