Eclipse: How to support older Android Versions? - android

Is it possible to Support all Android Versions, that exists? How does that work in Eclipse?

You could do that, but you will probably eventually choose not to. Because in the older versions, you don't have all possibilities you now have in the latest version of Android. The API in older versions is very limited.
If you want to do that, you could just use the minSdkVersion in your manifest, that will set the minimal Android version you need to have to run the app.
I suggest you have a look at the following site http://developer.android.com/guide/practices/compatibility.html
Edit: You only need to download the Android version you are locally building against. For example if you say your minSdkVersion is 11, but you're locally building with version 15, that's perfectly okay. You don't need to do anything else for supporting the previous versions. Of course you will need the support libraries too.

Related

What SDK to install, seriously?

I know there are plenty of documents over the internet but I have still some doubts about what SDK to install on my computer to create an android application for nearly %100 devices to working with. Google Play says that if I use API 8 (which is Android 2.2) then my application work nearly all Android devices.
So I downloaded API 8 and API 22 (Android 5.1, was default installed by Android Studio itself) and I don't know if it works or not if I select Minimum SDK to API 8 while creating a new project.
So seriously guys, what the heck is going on?
What SDK Platform(s) you install has little to no impact on what versions of Android you can support.
If you create a new Android Studio project via the new-project wizard, you will find an app/build.gradle file. In there, you will find a setting named compileSdkVersion. This controls what version of the Android SDK you are compiling against (i.e., what JAR is used to satisfy compile-time references to Java classes like Activity and TextView). Whatever value you specify for compileSdkVersion must be an "SDK Platform" that you have installed from the SDK Manager.
In a newly-created project given your setup description from your question, you will see that compileSdkVersion is 22, lining up with pre-established API Level 22 edition of the SDK Platform.
However, this does not mean that your app will only run on API Level 22+ devices. Much of what is in the API Level 22 edition of the Android SDK has existed in previous versions of the SDK.
The minSdkVersion property in the same app/build.gradle file says how old you are willing to go -- what is the lowest API level you are willing to support. Right now, I think a new project will be set up with minSdkVersion of 15, though that varies over time. More importantly, you can change it to be whatever you want, and you do not need the SDK Platform installed for whatever level you choose.
If, in your code, you reference stuff in the Android SDK that is valid for your compileSdkVersion but is newer than the minSdkVersion, the build tools will point out the discrepancy, so you can make sure that you know what you are doing. This is how Android handles progressive enhancement -- you see what version of Android you are running on (Build.VERSION.SDK_INT) and use newer APIs where you can, falling back to older APIs as needed.
TL;DR: So long as your compileSdkVersion has a value for which you have an installed SDK Platform, you're set.
It depends on the application you are developing. And the resources that it will need. It's true that if you use the oldest version (API 8) and your application is simple enough, then it will work on any device.
But there are limitations to it. on older APIs you will not be able to use new features as Navigation drawer for example
I would recommend API 11 or 14, that covers most of the devices and features nowadays.
You should consider the design you want to create on your app
You can see the market share of the different api versions here: https://developer.android.com/about/dashboards/index.html
Then you have a trade-off of how advanced APIs you want to use vs. how many devices you want to support.

Which Android versions are recommended for PhoneGap development?

The PhoneGap installation requires that I install Eclipse, and then use the Android SDK Manager to install the versions of the Android SDK/API. Each of these is a large download, and there is access to versions API 3 through API 21. However, I do not want to install them all and I would like advice on which is a good mix to use when I am not targeting a particular Android version but would like to cover as many devices as possible.
I checked the previous questions and I could not find this specific question from a search. I have noted an important question concerning the Android SDK Build Tools versions, but not the APIs to select.
Do I need to download more than one? Or is the latest (API 21) sufficient for my development work?
If you are aware of previous discussions on this that I have missed in my search I would greatly appreciate being pointed to these.
Phonegap is currently supporting Cordova 3.6.3 which requires API version 19. That is really the only version you need.

Android benefits and drawbacks of build target upgrade?

I changed the build target from 7 to 16, with the only reason that I want to compile with the newest SDK. I still want to target versions starting at 7.
My project compiles and ran without problems on 2 devices. But I'm not sure if this is safe. I don't want to realease and that it crashes on some devices, because some things I'm not aware of.
Does it anyways make sense to upgrade the build target, without any specific reason?
Edit: Just to make it clear - I'm not doing it to target newer versions or support new features (I'm already using the compatibility library). It's just, because, maybe with newer build targets the internals have been improved - like performance, etc.?
If you do not use any functionality of the new SDK version(s) it does not make sense to update this requirement 'just for upgrading it'.
When running your application on a device, it will use that version, so it already makes use of the newest internals.
The android library is backwards compatible (meaning it is compatible with older version). The support library provides forward compatibility (meaning it adds functionality to match the newest android library version), the support library is provided with the application (in the APK), so it is available when required. The application first tries to use the android library (so it always uses the newest internals for that device) and if functionality is not present, it tries the support library.
If you require some new functionality then you should upgrade to that SDK version. And (eventually) add code to check the running version and provide an alternative for devices with a lower SDK version.
To find out the SDK version at run-time, for providing alternatives, use android.os.Build.VERSION.

Compiling with Android 4.X but supporting API Level 9

I'm working on an application which uses ActionBarSherlock. As it's documentation points out:
[...] the library requires that both it and your project are
compiled with Android 4.0 or newer. The project also requires that
you are compiling with JDK 1.6 in both your editor and any build
systems that you may be using.
So, that means I'll compile my application (and the library) against Android 4.X but in my Manifest, I declare that I'm targeting (e.g.) API Level 9.
This all works fine and well but there is something that disturbs me. From the FAQ:
What API level should I target in my manifest when using the library?
Targetting API level 11 or newer is required as it will cause Android
to automatically add the native action bar when run on newer devices.
Since you will be compiling against new APIs but your app will likely
be run on devices with older versions of Android extra care must be
taken to either avoid using or properly check and call any methods
that were introduced after your minimum SDK version.
That means, that I'll have to manually check every method call, so I don't use any that are not available in my targeted API Level (9 in my case)? This sounds wrong to me.
Is there a way to tell my IDE (IntelliJ), that I'm only using the API Level 9 (so I don't get any auto-completion for non-existing methods/classes and don't use them by accident) and then choose to compile it against another Android version?
Or can I use some automated checks (which run at compile time) to check for that?
The ADT's lint feature should take care of this by warning when API calls are being made for the wrong API version.
You should be compiling both ABS and your project with the latest SDK available (at present, 4.1). Your manifest should have a targetSdkVersion as high as possible (ideally matching your compilation SDK) and your minSdkVersion should be set to the lowest version you support.
Lint is partially integrated with IntelliJ IDEA and is also available as a command line tool.
You temporarily set your target SDK to the various lower ones and debug with it. Your final build then is with the latest SDK.
Set a Build target similar to that you have mentioned in your manifest.
as always , you should set the targetSdk to the maximum available on both the manifest and the project.properties file (as recommended by google on one of their videos) , so that the ADT&SDK would be able to optimize the ADK accordingly.
set the minSdk to the one that you wish to support your app from , and let Lint to tell you if there are any problems in case you use too-new-features.

Android Developer: change version

Is there a way to change the Android version on my app without redoing everything? I just realized that Nook Color only has version 1.4. Well, I have my app set at 3.2 ... so those who have the Nook Color will not be able to access it. Why on earth did I do this to myself!
I am using Eclipse.
You can certainly create multiple .apk files for different versions. See this article about it. However, you may not need to if you haven't used any 3.2 API calls. You may be able to just change the minimum sdk level in the manifest file, update the version code, and republish your app.
You don't have to redo everything , but you can't use 3.2 API on nook color. You'll have to lower your minSDK version in your AndroidManifest.xml to the nook and test your application. If it doesn't compile you can look at using the compatibility libraries allow your app to run on older versions of Android if you are using API calls that aren't available on whatever the nook runs. 1.4 isn't a real version FYI.
http://developer.android.com/sdk/compatibility-library.html
Now you might run into bugs that exist in earlier versions that have been fixed in 3.2. Those bugs might require you rework your features.

Categories

Resources