Android build target - android

I've been writing my first android app and so far have just been building against the highest android SDK available - 4.1. Up until this point I have only been testing on a physical device running 4.03 and everything seems to work fine.
I would like my min SDK level to be level 8 (2.2) and as far as I know I have not used anything from the APIs higher than this.
However if I build against 4.1 and run on a 2.2 emulator it just shows a white screen and no crash (OpenGL based so something going wrong with this). The same build runs fine on a 4.1 emu and my 4.03 device.
If I build against 2.2 with the exact same code it runs on the 2.2 emu fine.
I don't really know what could be causing this so any tips would be great. Do some classes get replaced in the newer APIs? If they were removed entirely I would assume it just wouldn't build at all against the new version.
Should I be setting my build target equal to my minimum? I am not using anything from the APIs higher than 2.2 currently but I was under the impression I should be building against the newest SDK available. Are there any negative effects of building for the lowest version for instance does it affect the look of the menus/dialogs?
Any help is appreciated, thanks.

You should build against the lowest SDK version you intend to be supported by your app (e.g., if you want to support users don't having the newest smart phones or tablets, building against the newest SDK version wouldn't be a good idea).
Generally, newer SDK versions only include additional classes and functions, but I am not 100% sure about any removed classes.

add this to your AndroidManifest.xml
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="15" />

Related

PhoneGap or Cordova lowest SDK version target

Up until now I have been doing my Cordova development on a Nexus 5 and Galaxy S4 which are running Android 4.4.2 and 4.2.2 respectively.
I recently tried development on a device running 4.0.4 and it wouldn't install. I found out this was due to my manifest which had:
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="19" />
I quite easily changed the minSdkVersion to one that suited that of Android 4.0.4 (15) and it compiled.
I was just wondering though, does anyone know if there are any functions used within Cordova or PhoneGap which would require an elevated minSdkVersion?
Is it only dictated by any plugins or native code that is written?
Phonegap requires at least Android 2.2. Taken from the documentation: "Cordova supports Android 2.2, 2.3, and 4.x." As long as you are above version 7 you are fine. If you're using an HTML5 framework like e.g sencha you should check their restrictions, too. It makes sense to support the minSDK 10 as there are still many devices (about 20%) of Android users which are running on Gingerbread as you can see in Googles fragmentation chart.
To answer your second question: of course it would be possible that a plugin features functionality which is only available on newer devices. In that case you have to make the decision if you rather go up with your minSDK by locking out users, or you do it without the functionality. It all depends on how well your plugin is written - normally it should also work on devices which don't feature the higher level APIs and react properly (e.g "sorry, your device is too old for that feature get a new one" ;)
Hope that helps!

How can I use PhoneGap 1.7 for deployment on Android 2.x devices?

I am currently using PhoneGap 1.7, just having created the HelloWorld app, per the instructions at their site. However, I believe it requires Android Revision 15 or higher (4.0.3). I will eventually be wrapping a jQuery Mobile app with PhoneGap and I need it to be runnable on Android 2.x. Android 1.x and 3.x would be nice but are not required. How can I create a deployable app that will work on 2.x and 4.x versions of Android (with 1.x and 3.x being optional)? I hope I don't have to have different versions of PhoneGap and thus different deployment app versions. I'd like to have one deployable app for all versions.
Thank you very much for any help.
I am not familiar at all with phonegap. But with native development the API levels are backward compatible. So you can build the application with API 15, but set the android:minSdkVersion in the manifest to something lower. I imagine this is how phonegap works also, so even though you are using the newest API level it should still be backward compatible.
i.e. in the manifest of a native app
<uses-sdk android:minSdkVersion="7"/>
would indicate that the application is able to run on any devices that are Android 2.1 or newer. Even though you've added the 4.0.3 android jar file to your project the system is smart enough to make sure that it still works on the older devices as long as you set this in the manifest.
It is also worth noting that if your app takes advantage of any newer API's then you'll have to come up with a way to ensure those features get turned off if the app detects that the OS version it is currently on is too old to support the feature.

How do I emulate a HoneyComb-compatible app on older emulators?

I began the process of making one of my apps Honeycomb-friendly.
I started by changing the project's target build to version 11, and edited to AndroidManifest.xml to use:
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="11" />
These are the only changes I made so far. I am able to test it perfectly on my Honeycomb tablet device.
However, I cannot get Eclipse to launch this app in an older emulator (e.g. version 9). Technically speaking, the app should run in older android versions, so what can I do to test this app for older devices?
Or am I doing something else wrong?
I'm by no means an expert on this front but setting the minSdkVersion different from the targetSdkVersion doesn't make the app automatically use a different API level based on the device. See this:
Android Min SDK Version vs. Target SDK Version
and this:
http://android-developers.blogspot.com/2010/07/how-to-have-your-cupcake-and-eat-it-too.html
I suspect that because your application is using level 11 apis it won't run on a device that is of a previous API level.
This seems to be some sort of bug. When my 3.1 device is plugged into my PC, Eclipse/Android won't let me launch a new emulator that's < 3.0.
I worked around this by launching the emulator before I plug in my device, and then it has no problems deploying the app to both of the running devices.

support multiple OS versions incrementally

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.

What happens if we use/install 2.3 build in 2.2 device

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

Categories

Resources