Android -- selecting API from SDK Manager - android

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.

Related

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 SDK takes a huge amount of disk space

I did many searches on the web, and only partially I understood what I have to do.
When my IDE (Android Studio) reminded me that are available recent update for android SDK, I provided to install them. Now I notice that the Android-SDK directory occupies 87Gb of HDD memory.
This because are installed all the Android API from older version to the latest new.
Today I decided to delete all the SDK directory and perform a clean installaton of the SDK tool.
What I ask is which are the minimum things that I've to install from the SDK manager to be up and running for Android Development.
Consider that my apps must run from Android API 14 (4.0 IceCream) to the least available API version (currently on October 2017 is API 25).
In addiction I use an Android Emulator with Lollipop 5.1 (API 22).
The last thing I ask is when there is a new available and I would to install it, should I unistall all the older API version to prevent SDK grow up?
This is the screenshot of my Android Studio SKD manager.
As you can see the only checked API is 7.1.1 Nougat API 25.
This is a series of screenshot of package details of SDK Manager
The others are all unchecked.
I have to say that for Android 5.1 Lollipop API 22, check marks appear after I create the Android Emulator with Lollipop Installed.
NB: I need only things for mobile programming, not TV or Wearable.
should I unistall all the older API version to prevent SDK grow up?
Yes you can do this to reduce the space size taken by the SDK
Cons : you will not be able to use instant run if you are running your app on particular device on lollipop and above.
Note : you can drop old version under API 14 as support library has also dropped the support for older version
From docs, Revision 26.0.0 Release (July 2017)
The minimum SDK version has been increased to 14. As a result, many
APIs that existed only for compatibility with pre-14 API levels have
been deprecated. Clients of these APIs should migrate to their
framework equivalents as noted in the reference page for each
deprecated API.

What value to set for: "Minimum Required SDK" , "Target SDK" & "Compile with"

I know that there are many question on this, and I also read this page. However, I am still confused about the exact choices.
If I have a mobile phone that runs Android 2.3.6
I know that the Minimum Required SDK should be the lowest version of Android that my app supports.
So for example I will choose Android 2.2 or less than that value, say Android 1.5
The confusing parts Target SDK and Compile with
I have installed these below: (there is no Android 2.3.6 available in the SDK manager)
Android 4.2.2 (API 17)
Android 3.0 (API 11)
Android 2.3.3 (API 10)
Android 2.2 (API 8)
Is the Target SDK should be set to the maximum which is Android 4.2.2, irrespective to what my mobile phone uses; which is Android 2.3.6 ?
choosing Android 4.2.2 will cover all phones below it? is that right?
Or
Is it should be set to the exact/nearest value as my phone. Here the available one is Android 2.3.3? But not exceed my mobile phone Android 2.3.6
Is Compile with must be set to the maximum Android 4.2.2 or what?
Is the Target SDK should be set to the maximum which is Android 4.2.2,
irrespective to what my mobile phone uses; which is Android 2.3.6 ?
That is up to you, but its always recommended to use the latest sdk as a target.
It just says that the application will work between min and target sdk, but tested for the target sdk alone, so if there are any compatible settings system must take care of it.
choosing Android 4.2.2 will cover all phones below it? is that right?
Your app always covers from Min-SDK to Max-SDK. If the Min-SDK is 1 and Max-SDk is not set, then your app supports all the APIs.
Is it should be set to the exact/nearest value as my phone. Here the
available one is Android 2.3.3? But not exceed my mobile phone Android
2.3.6
Must be the latest SDK
Is Compile with must be set to the maximum Android 4.2.2 or what?
Its just your choice of which SDK to compile your app with. But better go with the Target-SDK which in turn is the Latest.
I've always set my Compile with to the be same as Target SDK.
Target should be what you have tested and architected your app to handle. As Android evolves API behaviors can change, like the Serial/Parallel/Serial nature of default AsyncTask (see: Running multiple AsyncTasks at the same time -- not possible? and http://commonsware.com/blog/2012/04/20/asynctask-threading-regression-confirmed.html) which depended on your app's Target API and on the device API. Fun times for us discovering it then.
In addition various APIs get depreciated as well so going with the most recent API forces you to only use what being currently maintained.

Which API version for the Android tablet?

I'm making a program for an Android tablet, and have been using the SDK with API level 12 (Android 3.1), without much thought or knowledge of it, just because it's the newest one. But, which one would you recommend I use? Which ones are for tablets (as opposed to phones)? And, do I have to reinstall all of the SDK if I want to use a different API (as http://android.konreu.com/developer-how-to/install-android-sdk-eclipse-and-emulator-avds/ seems to suggest) or can I just create a new virtual device?
You should use API level 11 that is the one that Google targeted for tablets. Previous version will work with tablets too, but the API 11 itself includes features that are tablet-specific.
And no, you don't have to reinstall the SDK. Just install that additional API level, and create a new virtual machine.
I would probably go for 3.0 since there are tablets that run that.
You only need to download the platform for 3.0 if you don't already have it. No need to reinstall the complete sdk. Just download the appropriate files.
minimum API level is GALAXY_Tab Addon - API Level 8 for the tablet and Android HoneyComb-API Level Honeycomb for the Honeycomb devlopment.

Targeting Android 1.5 and 1.6 from the 2.0 SDK

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."

Categories

Resources