Instant App, What's the actual minimum sdk - android

As per the android developers site, minimum sdk for Instant app is 21, ie 5.0.
link
The site clearly states : Android Instant Apps are available on the majority of devices running Android 5.0 (API level 21) and higher.
But when we create a new project as per the guideline given in this link
which states that we need to have minimum sdk of 23, to get instant app support.
And does not allow me to create a support for 5.0.
as shown in below image which I tried :

That requirement exists only in the setup wizard, and it is a bug. If you change the value to something lower after creating the project, you'll see that it builds fine and can run on API 21 and 22 devices.
The documentation is correct about supported Android versions, but note that even that doesn't dictate any particular minSdkVersion. You can build an instant app with a minSdkVersion lower than 21. It just won't run on anything before 21, since the Instant Apps Runtime itself is restricted to 21+.
For that reason, this check was always a bug, even when we didn't support devices before 23. I was told it was fixed in 3.0, though I didn't verify. I checked tonight and confirmed that the check is still present in 3.0. Could be fixed in a more recent version. But if not, we need to fix that. I'll follow up.

That requirement might be due to android run-time permission support Requesting Permissions at Run Time as official document mention
Note: Beginning with Android 6.0 (API level 23), users can revoke permissions from any app at any time, even if the app targets a lower API level. You should test your app to verify that it behaves properly when it's missing a needed permission, regardless of what API level your app targets.
Currently it has been fixed with android studio 3.1 Canary 5

For instance app minimum API 23: Android 6.0 (Marshmallow).
Please follow this link https://developer.android.com/topic/instant-apps/getting-started/first-instant-app.html

Related

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.

Is it mandatory to give targetversion in build gradle or manifest?

If I was not given any targetversion in gradle then, is it will take latest version, or which version it will choose, I build the apk without giving any targetversion, so when I will get problem of this targetversion is mandatory?
Its Not mandatory but is strongly recommended.
targetSdkVersion has nothing to do with adding the latest version or your compiling, it will just allow you to use the features available in the SDK you are targeting.
For example.
If you are targeting SDK 23, Then IDE will mark you errors whenever you are using critical permissions in your code. it will tell you to put a permission check.
If you target SDK 22, then you are free to use critical permissions without putting a permission check.
for the above situation, your app is tested and works fine in Lollipop or below, but it might crash in Marshmallow.
as per Documentation, it says here
Specifies the API Level on which the application is designed to run.
In some cases, this allows the application to use manifest elements or
behaviors defined in the target API Level, rather than being
restricted to using only those defined for the minimum API Level.

Will my application be visible to devices higher than my targetSdkVersion in Google Play Store?

I have gone through the following links but they don't provide a clear and definitive answer to my question. This is what I could derive from the answers:
targetSdkVersion indicates that the app is tested against the target version and will run on all android versions from minSdkVersion to targetSdkVersion
with no compatibility issues.
Android Min SDK Version vs. Target SDK Version
what is the difference between "min sdk , target sdk and compile with " ? in android
My app's minSdkVersion=11 and targetSdkVersion=19, Now I am not sure whether devices with higher SDK versions will see my app on Google Play Store or not.
UPDATE: For those who may encounter this question here is a great article I found:
http://www.thedroidsonroids.com/blog/android/compile-min-max-and-target-sdk-versions/
As Android evolves with each new version, some behaviors and even appearances might change. However, if the API level of the platform is higher than the version declared by your app's targetSdkVersion, the system may enable compatibility behaviors to ensure that your app continues to work the way you expect. You can disable such compatibility behaviors by specifying targetSdkVersion to match the API level of the platform on which it's running. For example, setting this value to "11" or higher allows the system to apply a new default theme (Holo) to your app when running on Android 3.0 or higher and also disables screen compatibility mode when running on larger screens (because support for API level 11 implicitly supports larger screens).
Android Developer, So the answer is yes, but you might want to consider testing and updating to current SDK version.
Yes, devices with higher SDK versions will see your app. Features of newer SDKs like granular permissions in Android 6.0 will not be available if they are not supported in your code.
The documentation for android:maxSdkVersion makes the situation clearer:
Warning: Declaring this attribute is not recommended. First, there is no need to set the attribute as means of blocking deployment of your application onto new versions of the Android platform as they are released. By design, new versions of the platform are fully backward-compatible. Your application should work properly on new versions, provided it uses only standard APIs and follows development best practices. Second, note that in some cases, declaring the attribute can result in your application being removed from users' devices after a system update to a higher API Level. Most devices on which your application is likely to be installed will receive periodic system updates over the air, so you should consider their effect on your application before setting this attribute.
It works on SDK 11 and upwards, as in your first Link stated.
Yes. Your app will be visible to the devices with higher sdk versions than your targetSdkVersion.
By specifying targetSdkVersion you can restrict google by applying default compatibility behaviours.So that you will get along with the api level of the device in which your app is running.
Yes, newer devices will see it. Let's do a thought experiment. Let's go back in time one year. We build an app, setting the minSDKVersion and targetSdkVersion to X, the highest available number in the toolset. Six months ago, X+1 got released. And today I just bought a new phone that runs X+1, and I'm very excited! Wait, what? That brand new app isn't in the store? But it worked on my old phone!
That would be crazy. :)
As a more concrete example, here's an app that has minSdkVersion 15
targetSdkVersion 17: https://play.google.com/store/apps/details?id=com.nasarallysport.rallyracetimer I just verified that I can see it in google play with my Nexus 6 on api 23.

What should be the Target SDK when publishing an Android app?

I have been working on an Android project from past one year in Eclipse with API level set to 4.2 (target SDK 17).
Now I want to publish it in the Play Store. Should I change the target SDK (manifest file) to the latest (i.e. 4.4) since my app works perfectly on KitKat?
The purpose of targetSdkVersion is explained in the developer documentation for <uses-sdk>:
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).
As Android evolves with each new version, some behaviors and even appearances might change. However, if the API level of the platform is higher than the version declared by your app's targetSdkVersion, the system may enable compatibility behaviors to ensure that your app continues to work the way you expect.
TL;DR: You should set targetSdkVersion to the API level that you've primarily been developing and testing on. Google recommends that you see to it that this is the latest Android version, but that may not always be feasible (for financial and other reasons).
See your app will work fine with kitkat because the newer versions are always made to be compatible with the older android versions,but vice versa is not true....if you develop something in higher API level and then try to run it in older versions of android, than it may happen that your app may not work or some features may not work as expected.So,you too can add KITKAT compatibility in your android manifest file ...cheers
As per this announcement you have to make sure to use a recent target SDK (at most one or two versions older than the most recent), otherwise you cannot publish your app in the Play Store. This is enforced for new apps as of August 2018 and November 2018 for updating existing apps, requiring you to target API level 26 or newer.

Relation between android version of device and version specified in the app

While creating a project using eclipse i have Minimum SDK required as Android 2.2(Froyo) and Target SDK as Android 4.2(Jelly Bean) compile with Android 4.3. I have used sqlitebrowser v2.ob1 for creating database. My app runs without any errors (few lines in red in logcat though) and meets my requirements when i run it in an emulator. I tried 3 different emulators and it works fine. But when i tried this app in a mobile device it shows force close whenever there is something to do with database. I mean to say that it shows force close when it has to retrieve from database or connect to database. By searching i learned that just the .apk file is enough for the app to run even if externally created database is used in it (copying to assets folder and then to the default location). My questions are
Shouldn't my app work fine in any device ranging from Android 2.2 to 4.2 ?
Should i try compiling the app with Android 4.2 instead?
Am not sure about the version of the device i tried it in but am sure its within 2.2 and 4.2 . (Probably gingerbread). Other than plugging the device to PC via USB and seeing logcat (bcoz i dont own an android mobile phone) what can i do to solve this?
How is the app's version, emulator and version of mobile or any other device related?
My app can run on what versions of devices?
This is my first android app so any help is appreciated. Thanks in advace
It's possible that you are using a feature in your application that isn't supported by a lower version of the SDK. It's difficult to tell you exactly what that might be without any source code or stacktrace, but I can clear up your understanding of minSdkVersion and targetSdkVersion.
Consider that with each new version of the Android SDK, additional features and APIs are introduced that did not exist in previous versions. Obviously, the older versions of Android don't support those features.
When you specify a targetSdkVersion you are specifying that you are using features that were introduced in that particular version of Android. You are also implying that you have tested your application at that particular API level, and that it works as it should.
When you specify a minSdkVersion that is lower than your targetSdkVersion, you are implying that your application will work properly on a lower API level because you have manually programmed tests or checks in your code to ensure that the current API level is compatible with a feature before running it.
For example, if I wanted to run a feature introduced in Jelly Bean but I want to retain support for a lower API level (e.g. Gingerbread), I might add the following check before I run the feature (see other version codes here):
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
// run some code specific to API level 16
}
The Android SDK can automatically deal with code introduced in a lower API level, but it can't automatically deal with code specific to a higher API level.
So with that in mind, to answer your questions:
No, it's only guaranteed that your application will work properly on Android 4.2. It's up to you to ensure that it remains backwards compatible for earlier versions that you wish to support.
It shouldn't matter. Instead, you should first determine if your application runs on a device/emulator that is running the same API level as you are targeting (Android 4.2, API level 17), then run it on a device/emulator running a lower version and try to isolate the code that is causing it to crash (logcat will be helpful).
You can check the Android version of a device by going into Settings > About phone > Android version. If it is running Gingerbread, keep in mind that a lot of new features have been introduced since then and your application might be using some of those features. For the emulator, you can specify an API level when you create an emulator (you can download other versions to use from the SDK Manager).
I think my answer so far has made this relationship clear.
To reiterate, your application WILL run on any device running Android 2.2 or later, but it can crash if you are using features from a higher API level than the device is running.
If this is still not clear, you should read more about supporting multiple platform versions in the Android documentation: here.

Categories

Resources