I am trying to make an android app. I am struggle at finding the suitable API level for my first app. I also not sure what min ark version is and what should I type in while creating a new project.
Can someone please answer me how to determine the correct API level and also what exactly is min sdk version??
Thank you
Minimum SDK version specifies that you application will work on minimum that android version and above. It also helps application to be showed on market. So when you put minimum sdk version like 8, your application will work on minimum android version 8 and above.
It's recommended to choose the lower that you use in your application to your "minSdkVersion".
Generally I used the minSdkVersion 7 (= Android 2.1 Eclair) to reach a maximum of people. You can find a pie chart here.
When you develop, do not hesitate to increase your minSdkVersion if you used a new API, you can find the API levels for any methods in the Android reference.
Related
I am a complete beginner in Android Development and just downloaded Android SDK to integrate it with Eclipse.
However, I don't know which Android version I should select in SDK Manager to allow a maximum number of people to download and use my app.
Here's a screenshot of the manager that is showing up on my screen.
Any kind of help would be really appreciated.
Thanks.
In fact, you don't need to download an OLD SDK just to allow OLD Devices to use your app.
This is done in your project settings via target SDK version and min API level(AndroidManifest.xml or build.gradle).
Define Audience
First, define the audience to your app.
HERE you can find the market share for every Android Version (this can change for each country but it may help).
If you check that table, you can see that only few devices are still using API 15 or older.
So, if you support API<15, you will only reach ~3% more people. If you can support them without lose any feature, good (not all android features are supported/ported to all versions). But if you may need to disable a feature (like that special Floating Action Button that you created) just to reach those devices, I think it does not worth.
So, based on that table, you define the audience
In my case for example, I like to build apps for devices with API from API_16 to API_24.
Usually, we always want to use maximum API available. Today, 24.
This way, I could reach ~97% of the people using Android.
But this is optional... I could select min API as 13... or 14.. or 4.. This is up to you..
After defining the audience
Target SDK
I usually set the target API according to the MAX API I want to support. So, for example, if the MAX API I want to support is API_24, this will be my target API and will download the SDK v24 (7.0).
Usually, you always will have the latest SDK installed since you always want to reach latest android version and enjoy all the new features.
MIN API
Now, you also have defined the min API version that you want to support. So, lets use API 16 for example (first JB version).
You will set this in your project file (AndroidManifest.xml). You don't need to download SDK 16 just because of that.
Setting Eclipse
As I said, min SDK will be set in your project. That would be done in your Android Manifest
Here, you can see that targetSdk is 24. It means that I just need to download SDK v24 to build this project. Even then, I'll be able to install this App in devices with API 16 or later.
Eclipse (AndroidManifest.xml)
<manifest>
....
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="24" />
...
</manifest>
Android Studio (build.gradle)
compileSdkVersion 24
buildToolsVersion "24.0.0"
minSdkVersion "16"
targetSdkVersion "24"
minSdkVersion Does Not Guarantee that your app will work
Note that settings above only allow your app to run in devices with API>=16 or API<=24. However, your app may crash or does not work in all devices within that range. This usually happens because some View Components or Methods were added or removed according to API version.
For example, Fragment was added only on API11. So, if you try to install your app in a phone with APIv11, it will work. However, if you install it in a device with API4, it will crash.
Another example is method Fragment.onAttach(Context context) which was added only in API 23.
That's why we use Support Library
Support Design Library it is a library created by Google which enables the developer to use features from new Android Versions in old Android versions.
So, for example, to add a Fragment which is compatible with devices with API<11, you should import and use Fragment class from package android.support.v4.app.Fragment instead of default version included in SDK (android.app.Fragment).
This way, your app wont crash.
Of course this is very basic example. It is just to illustrate...
Anyway, I hope I could help you
Regards
I recently started with android development. I don't understand what is the point of specifying minSDK, when I use appcompat?
In my project I've set minSDK to api 19, targetSDK to 19, compileSDK to 19, buildTools to 23.0. And Bam, Android studio automatically linked the appcompat v7-23.0.1. What is the point of setting minSDK to 19 if I can run the app even on api 7 because of the appcompat?
There are still a lot of features in Android introduced on higher versions. For example, API 14 introduced a lot of new features that weren't available before (you can see this page for a list of what's new in API 14), but this is just an example. You can read further about development considerations when deciding minimum and maximum SDK versions here.
Using a higher minSDK also means you are reducing your audience (i.e. how many people can buy that app). You can see a chart showing distribution for versions of Android here.
To answer your question, unless there are specific features from API 19 onwards that aren't in any support libraries, there is no point in keeping it at that - I would lower it to API 14, which means that you have access to most features in Android, as well as any support libraries for any other features you want to add in your app.
What is the point of setting minSDK to 19 if I can run the app even on
api 7 because of the appcompat?
you can not all the time.
where appcomapt fills gap for only a lot of APIs, there are still a lot of APIs which are not supported on lower versions even by appcompat or any other support library.
check documentation for more details.
Say I wanna make an app with :
android:minSdkVersion="8"
android:targetSdkVersion="22"
My questions :
Do I need to install both "min SDK Version" as well as the target SDK version?
How if I only have SDK Version of 23 only? Can I make such setting? Or do I need to have both 22 as well as 8?
Can I debug such app with API / SDK Ver 21 phone?
Is it enough to only have the latest SDK version to develop any kind of app?
It is okay if there's any source (link) to comprehensive rule about such ruling, since I didn't found it even after extensive searching.
P.S. I don't know if this info is needed, but the app I wanna make is a libgdx game app.
Thanks
No. (the other answer is wrong)
You only need to have the version that you building with (compileSdkVersion in build.gradle). If you only have 23, then build with 23.
Usually, you should target the same version you build with. However, libgdx is not always fully tested with the latest Android. Check here under Android build version to see what it has been tested for. This is the SDK level you should should target if you want to be sure not to have any problems. Right now, it is version 20 of Android.
I have been targeting Android 22 without issue (that I know of), though. I haven't yet released something higher than 20 yet so no guarantees that it's perfectly safe.
Yes.
Yes. Generally, the target SDK version and the build SDK version should match, but it works if you target a lower version than you're building with.
Targeting a later API basically changes some default behavior of apps. Theoretically, you should be testing on devices spanning the full range of API levels that you support, but in practice this is unnecessary for a libgdx game. But if you target a version that's too old, you might miss out on some newer features. For example, if you target <19, immersive mode (which is desirable for most games) cannot be supported.
Yes you need to install
If you have SDK Version of 23 only but you want to build it in version 22 then also you need to install vesrsion 22 SDK.
Yes you can easily debug such app with API / SDK Ver 21 phone.
I think its enough.
I'm not too familiar with which features belonging to which android version. Is there an easy way to discover the lowest version of android that my app can run in?
You can do it with lint tool.
Try to set minSdkVersion to 1 and run lint.
It'll show all methods and objects which later API is required for.
The minimum SDK version is the one you declare in your manifest for example the following line will set the minimum SDK version of your app to 7.
you can't discover like this. If you want to test your app in all versions of avds
set your app minSdkVersion to 8 and targetSdkVersion to 15
create all all versions of Android Virtual machines(avd) which you want to test
run your app in all versions of avds which you have created by selecting android target
No way to do it programmatically.
android:minSdkVersion — Specifies the minimum API Level on which the application is able to run. The default value is "1".
Before setting the minimum sdk version please check the scenario here. You can detect it programmatically .
http://developer.android.com/about/dashboards/index.html
what do you mean by detecting.. its up to you that which minimum api level you want your app to be supported. select any android:minSdkVersion e.g 8,10 etc. If any of the feature you are using which is not supported on this api level Eclipse will automatically tell, else use Android Lint
My question popped up a very similar question, this one. But the accepted answer (the single one) points to another question, this one, which doesn't really answer the original question.
The Android documentation states:
The Build Target specifies which Android platform you'd like your
application built against.
But what does it mean really?
The way I see it, I can have the minSdkVersion=4 and targetSdkVersion=10 but set the build target to API Level 4. What will happen? Eclipse assumes I'm developing for API Level 4 and any method, constant or whatever defined on API Levels above 4 will not be available to me. If I try to use them, the application will not compile. I'm aware of this.
But let me put it differently...
Let's say I have only set minSdkVersion=4, targetSdkVersion is not defined. I am also not using any method or constant only available on API Levels above 4. In this situation, does it really matter the build target I pick? Will it have any impact in the final APK?
Build target
Build target is the API level Eclipse/IntelliJ/whatever IDE you’re using is building against. This
is simply used by the IDE/build system to know which APIs to offer
you. If you build against API level 14, the application will still be
able to run on API level 7, providing you don’t call any APIs that are
not available on API level 7.
I mostly set the build target to the same as android:targetSdkVersion,
though this is not required.
Source: http://simonvt.net/2012/02/07/what-api-level-should-i-target/
If you use a higher build target then you can write code that will work on earlier versions by using reflection, for example. If you want to be restricted to just API 4 then don't worry about the build target.
For an example of targeting earlier api levels when compiling for a higher one you can look at this question:
Android: how to code depending on the version of the API?
The way I see it, I can have the minSdkVersion=4 and targetSdkVersion=10 but set the build target to API Level 4. What will happen? Eclipse assumes I'm developing for API Level 4 and any method, constant or whatever defined on API Levels above 4 will not be available to me. If I try to use them, the application will not compile.
When you set the build target to API level 4, Eclipse will not let you compile any methods you use higher than that, because it strictly uses API level 4. However, when you put the build target to a higher API level, in your case API level 10, your APK is available for use for phones from API level 4 to 10.
The 2nd question's answer answers your question, that is the Android build target, both minSdkVersion and targetSdkVersion affects the range of users that are able to use your application.
EDIT:
Since you're not going to define targetSdkVersion and you're not using any features which is above API level 4, the targetSdkVersion will be the same as minSdkVersion. Whatever build target your chose will automatically be specified. It doesn't really matter which build target you pick unless it is below API level 4
From Android documentation of targetSdkVersion:
An integer designating the API Level that the application targets. If not set, the default value equals that given to minSdkVersion.
This attribute informs the system that you have tested against the target version and the system should not enable any compatibility behaviors to maintain your app's forward-compatibility with the target version. The application is still able to run on older versions (down to minSdkVersion).