What SDK to install, seriously? - android

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.

Related

Is there any way that I can make android app with version less than 4.0 on new android studio

I am trying to make an android app and I have installed the latest version of android studio. When I create new project, the API levels are above 4.0 which wont work on many android devices so is there anyway that I can choose another API level?
After the project was created, just edit the build.gradle to contain
defaultConfig {
...
//noinspection MinSdkTooLow
minSdkVersion 9
...
}
But you should be aware that many current libraries will not support this SDK level.
Also you shouldn't be worried about the devices not being supported with a minimum SDK level of 14. Not too many users actually use these nowadays. Also these are long outdated and insecure.

Firemonkey: can we update targetSdkVersion in AndroidManifest.template.xml?

I read that berlin is compatible with marshmallow, but i see that by default in the AndroidManifest.template.xml we have :
<uses-sdk android:minSdkVersion="%minSdkVersion%" android:targetSdkVersion="%targetSdkVersion%" />
i don't know where delphi took the variable to update %targetSdkVersion% but it's seam to be all the time 14 and i don't see any way to configure it
i would like to replace %targetSdkVersion% by 23 (marshmallow api level, to support the app permissions), but is it safe to do so or it's will introduce many other bug ?
FireMonkey was developed to work against a certain range of Android functionality. As you can see from the RAD Studio Platform Status page FireMonkey apps built with Delphi 10.1 Berlin have a lowest supported Android version of 4.0.3, which corresponds to Android API Level 15.
The minSdkVersion field is supposed to be set to the earliest Android version your apps will work with so in truth this should probably be set to 15 but actually is set to 14 (Android 4.0-4.0.2).
If you look back at an Android manifest file generated by Delphi XE7, which supported Android 2.3.3 (API Level 10) it specifies a min SDK version of 9 (Android 2.3-2.3.2), which is the version of Android that introduced the NativeActivity type underlying every Delphi FireMonkey Android app. Again, this seems a little bit out of kilter with what is documented as lowest supported version.
Anyway, minSdkVersion can be used by Google Play store to filter your app out of the listings for someone running a lower version of Android. It is also checked when you install an app on a device; Android won't let you install on a lower version of Android.
targetSdkVersion, on the other hand, indicates what version of Android your app has been tested with and works sensibly with. It can often be higher than minSdkVersion if your your app needs to use features introduced in Android versions later than minSdkVersion.
If you want to use a feature from API Level 23 then sure, you'll need to update that manifest part. Just remove the %targetSdkVersion% template from the Android manifest template file and replace it with the required version.
Problems that you might run into:
You'll either need to check the Android version and, if lower than your targetSdkVersion, not use those features that aren't available or set minSdkVersion to a suitably higher version to ensure the app can only run on devices that have the features you wish to use.
FireMonkey code not aware of differing behaviour in API Levels may
function adversely. In your case you may get issues because of the
different runtime permissions behaviour enabled in API Level 23.
Actually I can't currently think of any more issues, though a good amount of testing is recommended. You might have more to think about in a regular Android app using visual activities and so on, when different API levels may affect the theming or other UI elements. You can see the various things that change when you target target SDK versions on this Android documentation page.
By the way, the use of the SDK Manager in the Tools. Options... dialog is entirely irrelevant to the question of how to update the value in the generated manifest file. The only evident way to change it is to manually edit the Android manifest template file as per the documentation, and mentioned in a comment.
The only relevance of the SDK Manager is that the default Android SDK installation for Delphi 10.1 Berlin installs the Platform libraries for API Level 22. If you want to use a feature from API Level 23 you might think that updating those platform libraries might be necessary, but of course if you're doing the coding in Delphi then you're (presumably) actually just compiling against import definitions of the features in that higher API level, and so whether or not those features are contained in the android.jar file is of no consequence.**
** I'm happy to be proved wrong on this count, but I have never observed a connection between the manifest and what the SDK Manager is set up against.

Choosing SDK version to reach maximum number of people

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

Can I only install the newest Android API to target lower API Version?

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.

Android Target SDK vs Build SDK

In what scenarios would the Target SDK version and Build SDK version ("Compile with" in screen below) differ?
I'm trying to figure out why Target SDK wouldn't be used for both providing the API level the application is designed to run on, as well as compiling against the same SDK.
In what scenarios would the Target SDK version and Build SDK version ("Compile with" in screen below) differ?
When the developer sets them to be different values.
I'm trying to figure out why Target SDK wouldn't be used for both providing the API level the application is designed to run on, as well as compiling against the same SDK.
At the point in time when you create a new project, setting the build SDK and the target SDK to be the same is reasonably common, which is why that's the default in the new-project wizards.
However, developers may well want to raise the build SDK to a newer API level, while leaving the target SDK alone. The target SDK version controls some elements of forwards compatibility and therefore may change things that the developer is not ready to address just yet.
For example, suppose a developer created an app in mid-2013, and at that time set both the build SDK and the target SDK to be 18. Then, early this year, the developer started poking around with Android 4.4 (API Level 19). The developer wanted to add printing capability to her app. The simplest way to support API Level 19 printing is to set the build SDK to 19, so she could reference the relevant classes directly. However, KitKat also changed the behavior of classic AlarmManager methods like set() and setRepeating(), and she decides that she's not ready to deal with that just yet. Since those changes are tied to the target SDK version, she leaves her target SDK version on 18 for the time being, making a note to work on supporting the new inexact nature of AlarmManager alarms in the future. Hence, at this point, her build SDK is 19 and her target SDK is 18.
Target SDK: Highest API level that the application have been tested. The application should be compatible with all the devices with this API level or more recent API.
Compile with: API level with the application have been compiled. For default it's the highest possible level (now it should be Android 4.4.4 kit kat)

Categories

Resources