Some java specific libraries asks for android min API 26. For example Base64.getUrlEncoder() asks for android min API 26. How can I use these java properties in previous api levels? I tried to increase compile java options to latest java version but still I'm not able to use in previous api levels. So is there any way to do this?
No you can't use those APIs below the stated minSDK.
Some APIs are cloned in the Support Library. Base64.getUrlEncoder() is not.
However you could use the Android Base64 version which is available since API 8.
Related
TimeZone.observesDaylightTime() requires API level 24. How do I get it for older APIs? Even though this is included in JAVA 1.7 Android is still complaining.
The short answer is that you can't do things like that in the general case. If a call requires a minimum API level you can't use it if you're targeting older API levels.
Also as one more general remark, keep in mind that Android is not running the "standard" version of Java - it even has its own Virtual Machine that differs in some significant ways from the standard JVM - so the fact that something's allowed in "standard" Java doesn't automatically mean it's possible in Android. For example, it was only very recently that Android had support for Java 8 features, and even now it doesn't support all of the features.
I have developed android application keeping minimum api level 8 and maximum 17. Used Api 14 compilation unit.When I run it on android phone the application crashes.I wan to create application for Android 2.0 -3.0 version i.e the application should be compatible on 2.0 version also. Kindly suggest how can i achieve this?
Because you compile against level 14 API, you might use methods or classes that are not available on API level 8, which will cause runtime errors on level 8 devices.
I suggest you compile your app against the API Level 8 SDK.
Android Lint tool in Eclipse can also find usages of methods that are not available on your app's minimum API level, but I'm not sure how much reliable its results are (It might not find all of the unavailable classes/methods).
Do Android Developers Tools support JAVA 8 API up to this date? I'm trying to build an Android app using JAVA 8 and I was wondering about this thing.
Java 8 APIs started becoming available in Android API 26 (which is Android 8, or Nougat). A mechanism called API desugaring is available to use certain Java 8 APIs on earlier Android versions, regardless of the Android API level.
However, there is no 1:1 connection between Android and Java API versions. In the past, it has taken Google some 2–3 years following the release of a new Java version to gradually start implementing its APIs. So, the question “is a certain Java API available on a certain Android version” can only be answered on a per-class/member base. You will have to look up every class, method, constant etc. on the Android API reference and see if it it supported, and what the minimum API version on Android is – or see if API desugaring provides it, which is not tied to a particular Android API level.
I am learning the Android SDK and I am getting to the point of getting a bit more comfortable to start doing actual app development. I have done some reading here and there online, and based on my limited understanding, I as a developer, should include the Android API levels that I intend to make the app available to. My question is related to this...
Based on some charts online, it seems to make the most sense to support devices from 2.3 (Gingerbread) all the way to the current KitKat API. So that would mean API level 10 - current.
Question 1 Do I have to download all the API levels in between (i.e. 3.0, 4.0, 4.1, etc...)or is the lowest and highest be enough?
Question 2 If I do not end up downloading those API levels in between? What would a user running, say 4.0), experience? Would they be totally unable to run the app? Or would it simply mean that I, as a developer, would not be able to use any of the APIs states in those levels?
I understand that there might be some compatibility issues, from changes in the API which I would need to work out myself.
Thanks you for your clarification.
Answer to Question 1
You can develop your application using any API version. In Android Manifest.XML file, you specify the Minimum SDK version that your application supports. Based on that value, your application works in all API ranging from the min value to the current Value.
Please note that you can specify the MAX SDK value supported but this is not recommended.
Answer to Question 2
Once you develop an application, it is good if you test it on various API versions. If you download different platform versions, then you will be able to create different emulators and test your application. But your application will work successfully even if you install only latest version.
Also, as a developer, from the application code, you can make your application utilize certain libraries supported in higher version and do not use those SDK if the application is running in low API devices. You can do this through code.
Similarly, compatibility issues can also be addressed in code.
You just have to download the latest API. You can define in your app what the minimum Android version can run it (you should start low but as you add more and more features you're going to learn that you might have to increase it) and anything between the version you define and what the current highest version is (19, at the moment) can run it. They all might have slightly different experiences, but it'll all be similar in general (like, I have an ActionBar in my app and it looks pretty different between JellyBean and Gingerbread, but it's there nonetheless).
The main thing is that for backwards compatibility there are support libraries that you'll have to download and include in your app which aren't there by default (android-support-v4.jar for example).
A big tool you can use if you want to include certain features on higher API devices is check to see the current API of the device) and then implement accordingly. The most important thing is testing on different level APIs to make sure your app works on all of them.
You can configured minimum and Maximum API level in Manifest file.So that you can covered maximum device.Please put following code in your manifest file,
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="17" />
Thus your application can run on device having API level between 15 to 17.
I was writing an Android app for Android SDK 2.3.3 but then I was asked to test it on a device running Android 2.2.1. So I set my target to 8 instead of 10. But then java.util.concurrent.TimeUnit only had the Java 1.5 feature set instead of the Java 1.6/1.7 feature set of java.util.concurrent.TimeUnit. So I put the openjdk 6 implementation of TimeUnit into my package for my Android app and everything works fine.
Does anyone know where I can get some documentation that gives me a chart that tells me, for example, that when using the official SDK, Android 2.2 has to be coded using Java 1.5 keywords/syntax/APIs, Android 2.3.3 can be coded using Java 1.6 keywords/syntax/APIs, etc...?
You are trying to look at Android as a subset of Java which it is not. They are completely separated. Even though Android comes from Java, it as departed from it quite a bit and there is no correlation 'version-wise' anymore between the two.
What you can look at is the Android documentation. For every instruction/command/method/properties, at the top right you'll find the api level at which you are able to access said property.
Clicking on the api level will take you to a page which contains a table that translates api level to Android versions.
The easy way to find out if you are allowed to use a property is using eclipse and doing what you just did : Change the target api level. Then any call to methods or properties that are not available to you will produce fatal errors.