Targeting Android 1.5 and 1.6 from the 2.0 SDK - android

I'm interested in learning Android development.... but if I install the latest 2.0 SDK, will I still be able to target 1.5 and 1.6 devices? (since there is only one 2.0 device right now)
Basically I'm wondering if it will tell me if I'm doing something that won't work on older versions of the OS

Yes you will be able to pick level that you need using combination of Manifest setting and (when in Eclipse) picking Android API version that you need. With 2.0 install you may not get 1.0 or 1.1 but legacy distros available from Google and you can always set your environment to use that
And if you accidentally set your environment to something that device that not support you should always test on the device and watch for exceptions such as ClassNotFoundException and NoSuchMethodException which would indicate that you are attempting to use classes/methods that are not present in the API loaded by your device

You should always target the minimum API that you require as noted on the Android Development site Hello World tutorial
"If an application requires an API
Level that is higher than the level
supported by the device, then the
application will not be installed."
"Android applications are
forward-compatible, so an application
built against the 1.1 platform library
will run normally on the 1.5 platform.
The reverse is not true."

Related

What new packages should I download using SDK Manager

The new version of SDK for Qt 5.12 doesn't include SDK Manager in the Tool folder, hence I needed Android Studio to Add/Remove the packages.
I know that APIs must be chosen based on the target and purposes. But since the APIs are new (28) and there are different options to download, it's rather puzzling what to download.
I don't have a real Android device nor want I use the Emulator. I merely wish to Build the program using Android kits and create APK files from them. Afterwards I will test those APK files on real Android devices which include new or middle aged smartphones and tablets.
For these purposes what packages should I install, for instance, what check boxes are needed to be checked here in the screenshot below. I will repeat the pattern for a number of lower APIs then.
If you don't want an emulator, then you don't want the "system images".
As for the API level, it really depends on what is the minimum API you want to target. If you download only the latest API, you significantly limit your targets, as the app will only run on the latest and greatest version of Android.
The safe lower limit seems to be API level 19, which is android 4.4. So you can use that to build your apps, and they will run on any version onward.
Additionally, if you want to publish to the market, you will have to set your target API to some of the latest versions, because google won't accept any older. Note that the "target SDK" is different from the "minimum required SDK", which you can still have at version 19.
There isn't much point in installing the latest SDK versions, as Qt isn't really using their features, I mean unless you are doing some Java native android app development.
The documentation for Qt 5.12 says "API 21", but 19 seems to work just fine, and it allows to target older devices that are stuck without OS updates - currently around 7-8% of active devices. Still, if you don't care about that, you should go with the recommended API version 21.

Android minSdkVersion uses always minimum sdk even higher api devices

I use minimum sdk version 1.6 and run app on android device 4.0 but the app layout look likes devices with android 1.6. Is not it possible to use proper sdk based on device android version?
For clear my mean, suppose:
I use min sdk version 1.6 and target 8.0. I want when it runs on device version 4 it uses sdk 4, on device version 5 it uses sdk 5 and so on.
You can support different API levels creating multiple APKs taking advantage of this Google Play feature.
It’s essential to adopt some good practices from the get-go and prevent unnecessary headaches further into the development process.
Creating Multiple APKs for Different API Levels explains these steps in detail.

Android -- selecting API from SDK Manager

I have downloaded the Android SDK(which i think has no version, it is standard). After installing Android SDK, Android SDK Manager comes which by default selects 3 things to be downloaded (1)Android SDK tools(2)Android 4.0.3 (API 15) and the things under it like documentation, samples etc (3)Google USB driver But at present i am having book on Android 3, so should i deselect the second option i.e. Android 4.0.3 (API 15) and select all things under Android 3.0 (API 11) or keeping Android 4.0.3 will be OK for Android 3.I know there are tutorials for Android 4.0.3 on Web so why should i go for Android 3 because i find it easy through books and i got Android 3 here in my place and still no Android 4. So what should i do?
You can install everything. I would recommend to install the API level you want to develop for. But it doesn't hurt (but wastes disk space) to install everything.
Sidenote: Android 3.0 is for tablets, 2.x for older and 4.x for the latest Android Smartphone devices.
You should select the API level that you will target. For example, I am writing an application for API level 7 (Android 2.1.x), so I've got that version installed on my machine. Of course, you can have more than one API level installed, so it is safe to install any combination (for example 3.0.x and 4.0.4 simultaneously - see last paragraph for the reason).
Once you've got a few API levels installed, Eclipse will allow you to change the target API for your project to any of the versions you have installed. The same applies for the command-line project creation.
There is actually one good use-case for installing a version newer than the one you are targeting in addition to the one you use: testing. You can create an emulation environment for a newer version of the API to ensure that your application does not crash and burn when the API levels do not match. If we were to extend my above example, a sensible set of levels to install is 3.0.x, 3.2, and 4.0.4. You can target the initial release of Honeycomb (unless you need anything from the later versions), and test with both the latest Honeycomb and Ice Cream Sandwitch.

Which Android platform SDK do I need?

I would like to test and distribute my phonegap app. It already runs for iPhone.
At first I installed the newest SDK (4.0.3) but this one does not run on my phone. So... i guess I have to install more.
What do I need to install in the Android SDK Manager?
All SDKs? Do I need the Sample/Arm/GoogleAPI/Sources too?
Generally I install all the SDK versions as it is good to be able to test on the various emulators to make sure you app works in all versions of Android. You should always build your application with the latest SDK but in your AndroidManifest.xml file you should have a android:minSdkVersion set to the lowest Android level you want your app to run on. For now I recommend 7 (Android 2.1) as 97% of the phones are running 2.1 or above.
As you can see in the platform versions chart here it is recommended to use Android 2.1 or 2.2 SDK to cover almost all the Android devices on the market.
I think you don't need Sample/ARM/Sources, though if you need to use Google proprietary API (for example Google Maps API) you need to use Google API versions of 2.1 or 2.2.
You only need the SDK that matches the API level you intend to build for.
This page: http://developer.android.com/resources/dashboard/platform-versions.html
has a breakdown of what devices are most active in currrent use (accessed market within 2 weeks)
Judging by that, if you target 2.1 you'd be able to install your app on 98.3% of all such devices.
It is generally best to pick the oldest platform that supports all of the features you need. Just stay at or above 1.6, that is when support for multiple screen sizes was introduced.
As I think, the best solution is SDK 2.2. Many devices work with this android version.
On your Android phone go to settings->About Phone and view the Android version. This should be the sdk you will need. Afterwords, you can just change the target android sdk version in your app and it should run on your phone. As for the folders you speak of - they contain some examples, the source code of the sdk and some additional apis to use google services. It is up to you whether you will need them. You will definitely need the platform-tools from the Android SDK manager - they provide you with the adb tool that enables you to upload applications to your device.

Should I compile my Android apps against the latest SDK?

My app requires that devices are running at least Android 2.0 OS. Would it make more sense for me to compile my project with the 2.0 SDK or does it make more sense to always compile my project using the latest SDK, even if it's well beyond 2.0...?
The problem with compiling against 2.1 for example would be that I don't know if an Android 2.0 device would even run an app compiled with 2.1...?
You can target a later SDK version using android:targetSdkVersion while still permitting your app to be run on earlier versions (since apps are filtered out based on the android:minSdkVersion). If you use API's that aren't supported, your app will force close. So, you'll have to pay attention to the API level annotations in the documentation for all functions, and test your app on an emulator set to use the minimum SDK version.
However, the Android Developer's Blog has some good advice on how to write applications that support earlier SDK versions - at a cost of some added work, of course. Whether it's worth it depends on whom you want to reach, obviously.

Categories

Resources