Android Question Which API should I be using?

cooperlegend

Active Member
Licensed User
Longtime User
With APIs now up to 19... which one should I be using.

I currently use 13 as my default (I assume this supports the most devices)

Or should be using the latest?

Does API 19 still support older devices?
 

nwhitfield

Active Member
Licensed User
Longtime User
Use whichever one allows you to do all the things you need, but ideally the lowest you can get away with.

API 19 'supports' older devices in as much as if you use functions that are available on older devices, then the app will work. APIs are (broadly) cumulative, ie a higher number includes all the things that were in lower ones. I say broadly because sometimes, things are removed or deprecated.

So, an Android function that was there in API 8 is probably still there in API 19; in that regard, API 19 can be said to support older devices. But use a function that was only introduced in 19, and of course it won't work on older devices.

If you set the minimum API for your app to 19, but are only using functions that were available in, say, API 15 (Ice Cream Sandwich), then you're needlessly restricting your app to only 13.6% of devices, instead of 84.3% of them.

To see current usage, you can visit http://developer.android.com/about/dashboards/index.html

As you can see, if you were to use functions from API15 and above, then you'd get 84.3%, which is a pretty reasonable base. Include API 10 (Gingerbread, Android 2.3), and you get another 15%, which may include people who have devices only a couple of years old.

Some libraries in B4A will explicitly tell you which version they require, and that may actually be the limiting factor for your app, more than anything else.

Personally, I have my B4A config set up to API 15 for now, as I feel that's a reasonable compromise.
 
Upvote 0

cooperlegend

Active Member
Licensed User
Longtime User
Interesting contrasting views, I guess there is no right answer

With some of my projects I need Admob which requires 13 or above, but others I would rather support as many devices as I can.

So two more questions.

1) Can I configure different project differently using the manifest?, I currently set these to <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>. In the Path setup I point to android.jar API 13.

2) Do the API function remain the same in later APIs? i.e. an API call to a drop down list, will this look the same or have they improved core functions over time? If it just a case of more functions added then I can use the early API without problem.

BTW, Really appreciate the prompt answers here, it is why I love B4A and hope I can use this forever :)
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
The answer is very simple, you should use only the latest API level (at the time of this post SDK 19), as mentioned by @thedesolatesoul Android is backwards compatible, so, it doesn't matter what SDK level the device has the app will work without a problem, the only time you should exclude older SDK levels is when your app uses features found ONLY on higher levels, adding something like:
B4X:
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
To your manifest means that ANY version of Android will be supported, but, if you are using something only available on higher SDKs then you could just do something like:
B4X:
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="14"/>
In that case your app will be only visible to devices running Ice Cream and above.

I hope that helps.
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
I dont understand your problem. You should just set the API to the latest possible.
If you are using features not supported on older APIs, then they wouldnt work on them anyway?
What is the reason not to use the latest API?

And by API I assume you mean the android.jar you reference to in 'Configure Paths'.

EDIT: This message is deprecated after @NJDude answer above.
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
The target is just to use the features on the device for that API level, for example, the Holo theme, you can leave it at 14 or like on the line below, it will work anyway.
B4X:
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="19"/>
 
Upvote 0
Top