Xamarin Android target version - xamarin

I am receiving the error message below when trying to release a Xamarin Android app on the Play Developer Console
Upload failed
Your app currently targets API level 26 and must target
at least API level 28 to ensure that it is built on the latest APIs
optimised for security and performance. Change your app's target API
level to at least 28. Find out how.
I have the following settings in VS for Mac
Also, all of the Xamarin.Android libraries that I am using are v28.0.0.3.

It must be an issue with your Android support libraries or the version. Can you ensure the below and try to publish it with a new version?
Ensure the latest SDK (API level 28) is installed in your Android SDK Manager
Ensure you have the latest Android Support libraries and Build tools installed.
Set your Android Target version to API level 28 and Minimum Android version to something lesser than that.

Following points you should note:
When Google play talks about target Android version it is talking about the Target Framework in your Android Project Properties.
The error message that you are getting has nothing to do with what version of support libraries that you have. But when you target the latest version you might want to have the support libraries of the same version.
Adding all the SDK's that your Android app is going to support is recommended which means if you Min Android support version is 21 per se and you want to target the latest version then make sure that your Android SDK has all these sdks's so that there are no issues while parsing your APK in the desired version.
I wouldn't recommend that your min Android version is set to version 9 because of the fact 90% of the devices do not have this version of SDK which means none of them will be able to install or use your APP. Which if you ask me should never be the case. Supporting the widest possible audience is always the best call.
After making the above changes your app should work fine. Feel free to get back to me if you have any questions or queries...

Related

TargetFrameworkVersion problem of Xamarin.Form.Android

I am a beginner at Xamarin.Forms.
My project has to support Android 6 and I create a brand new project with Xamarin.Forms 4.8.0.1451, and then set the Compile using Android version to Android 6.
Now visual Studio reports this error:
Severity Code Description Project File Line Suppression State
Error The $(TargetFrameworkVersion) for Sample.Android (v6.0) is less than the minimum required $(TargetFrameworkVersion) for Xamarin.Forms (9.0). You need to increase the $(TargetFrameworkVersion) for Sample.Android. Sample.Android
It seems the current version Xamarin.Forms does not support Android 6, right?
How can I solve this? Whether I can only use a lower version Xamarin.Forms?
Thank you.
First the Target Framework (also known as compileSdkVersion) is the specific Android framework version (API level) that your app is compiled for at build time. This setting specifies what APIs your app expects to use when it runs, but it has no effect on which APIs are actually available to your app when it is installed. As a result, changing the Target Framework setting does not change runtime behavior.
The Target Framework identifies which library versions your application is linked against – this setting determines which APIs you can use in your app. For example, if you want to use the some method that was introduced in Android 6.0, you must set the Target Framework to API Level 23 or later.
We recommend that you always compile with the latest available Target Framework version.
So you don't need to set the Compile using Android version to Android 6,if you want it support Android 6,you just need set the Target Android Version or Minimum Android Version to android 6.
And you could see the Android version(MonoAndroid Version) that Xamarin.Forms depends on when you open the NugetPackage Manager.

Xamarin Form Android API level support?

I use VS 2019 and Xamarin
I try to run the example (new project), but I need level API 19 (Android 4.4.2)
I was set target, minimun sdk. But get error while build
"Severity Code Description Project File Line Suppression State
Error The $(TargetFrameworkVersion) for App4.Android (v4.4) is less than the minimum required $(TargetFrameworkVersion) for Xamarin.Forms (8.1). You need to increase the $(TargetFrameworkVersion) for App4.Android. App4.Android"
I have already tried select different Android version (5,6,7), but apart from 8 only.
I don’t. Search on sites they write, simple changed and use.
But in reality, this is not so. In general, is it really possible to write below Android 8?
you could set your TargetFram Version to the latest version,then set the Minimum version to 19, Target Version to the same as TargetFram Version.
Target Framework – Specifies which framework to use in building your
application. This API level is used at compile time by
Xamarin.Android.
Minimum Android Version – Specifies the oldest Android version that
you want your app to support. This API level is used at run time by
Android.
Target Android Version – Specifies the version of Android that your
app is intended to run on. This API level is used at run time by
Android.
In general, the Target Android Version should be bounded by the Minimum Android Version and the Target Framework. That is:
Minimum Android Version <= Target Android Version <= Target Framework
As described here Expanding target API level requirements in 2019, In order to provide users with the best Android experience possible, the Google Play Console will continue to require that apps target a recent API level:
August 2019: New apps are required to target API level 28 (Android 9) or higher.
November 2019: Updates to existing apps are required to target API level 28 or higher.
and in future as well the target API level requirement will advance annually.
So you need to set target api version as required, however your app will work on all the phones with minimum sdk support. Minimum sdk version you can set based on the features supported by your app.

why Apply Changes ability only works in devices with API 26 and above in android studio 3.5

android studio 3.5 just released and I installed it, but there is an abnormal thing. and that is the ability "Instant Run" is removed and instead introduced a new thing called "Apply Changes".
the negative point about this ability is that it only works in device with API 26 and above.
is there any way to use this ability for devices with API level below 26?
I faced the same problem. Before upgrade to AS 3.5, I used this function on API 23. But it seems that starting from version 3.5 it is no longer available.
There is a page on the official site: https://developer.android.com/studio/run/index.html
Before 3.5 release:
Apply Changes action is available only when you meet the following
conditions:
Build your app using a debug build variant.
Use Android plugin for Gradle version 2.3.0 or higher.
Set minSdkVersion to 15 or higher in your app's module-level build.gradle > file.
Deploy your app to a target device running Android 5.0 (API level 21) and > higher.
After:
Apply Changes actions are only available when you meet the following
conditions:
You build the APK of your app using a debug build variant.
You deploy your app to a target device or emulator that runs Android 8.0 (API
level 26) or higher.
So if you really need this feature for pre-Oreo, it seems that the only option is to use older versions of the AS. Until more knowledgeable people have not found a hack or some workaround :)

Android Mono version or Support package version

Let's say I want to make sure all Android 7.0 devices can run my app.
When installing NuGet packages which version should I pay attention to?
Android Mono Version or the version of the Support package?
Should I choose A or B? By the way, is Android 7.0 the same thing as Android Mono 7.0 or are they not?
First and foremost MonoAndroid V7.0 and Android V7.0 are not the same things.
Mono Android is an open source implementation of Microsoft’s .NET Framework based on the open standards for the C# language and the Common Language Runtime, whereas Android is a mobile operating system developed by Google, based on a modified version of the Linux kernel and other open source software.
To Answer your First Question Support libraries actually work in a different way then you understand to make sure that your app works on all Android 7.0 devices you need to make sure you have the Android SDK and that your compilesdkversion is minimum this or greater than this, Now support libraries, on the other hand, are for compatibility suppose you have an app that targets V 5.1 and there is an API that is available on 5.1 but if you want to be able to use the same in your device below that you need to have support library V21 for more understanding read till the end.
Well trying to keep it as plain and simple as possible when you say the MonoAndroid version it basically shows you the version that you are targeting your android application on. Which basically means your targetted version which has nothing to do with the maximum support.
Target Framework:
Target Framework – Specifies which framework to use in building your application. This API level is used at compile time by Xamarin.Android.
The Framework you want to target for your android application, And this actually is A as per you and this has nothing to do with whether or not it will run on a device higher than that it basically provides you with new features that are available to that Android framework.The Target Framework (also known as compileSdkVersion) is the specific Android framework version (API level) that your app is compiled for at build time. This setting specifies what APIs your app expects to use when it runs, but it has no effect on which APIs are actually available to your app when it is installed. As a result, changing the Target Framework setting does not change runtime behaviour.
For eg: If you target anything below V6.0 you don't need to provide any runtime permissions or if you target v8.0 you can use Adaptive icons and so on and so forth. The Target Framework identifies which library versions your application is linked against – this determines which APIs you can use in your app. For example, if you want to use the NotificationBuilder.SetCategory method that was introduced in Android 5.0 Lollipop, you must set the Target Framework to API Level 21 (Lollipop) or later. If you set your project's Target Framework to an API level such as API Level 19 (KitKat) and try to call the SetCategory method in your code, you will get a compile error.
Also Note:
Beginning in August 2018, the Google Play Console will require that new apps target API level 26 (Android 8.0) or higher. Existing apps will be required to target API level 26 or higher beginning in November 2018. For more information, see Improving app security and performance on Google Play for years to come.
Minimum Android Version
Minimum Android Version – Specifies the oldest Android version that you want your app to support. This API level is used at runtime by Android.
The Minimum Android version (also known as minSdkVersion) is the oldest version of the Android OS (i.e., the lowest API level) that can install and run your application. By default, an app can only be installed on devices matching the Target Framework setting or higher; if the Minimum Android version setting is lower than the Target Framework setting, your app can also run on earlier versions of Android. For example, if you set the Target Framework to Android 7.1 (Nougat) and set the Minimum Android version to Android 4.0.3 (Ice Cream Sandwich), your app can be installed on any platform from API level 15 to API level 25, inclusive.
For eg: Although your app may successfully build and install on this range of platforms, this does not guarantee that it will successfully run on all of these platforms. For example, if your app is installed on Android 5.0 (Lollipop) and your code calls an API that is available only in Android 7.1 (Nougat) and newer, your app will get a runtime error and possibly crash. Therefore, your code must ensure – at runtime – that it calls only those APIs that are supported by the Android device that it is running on. In other words, your code must include explicit runtime checks to ensure that your app uses newer APIs only on devices that are recent enough to support them.
Target Android Version
Target Android Version – Specifies the version of Android that your app is intended to run on. This API level is used at runtime by Android.
The Target Android Version (also known as targetSdkVersion) is the API level of the Android device where the app expects to run. Android uses this setting to determine whether to enable any compatibility behaviours – this ensures that your app continues to work the way you expect. Android uses the Target Android version setting of your app to figure out which behaviour changes can be applied to your app without breaking it (this is how Android provides forward compatibility).
The Target Framework and the Target Android version, while having very similar names, are not the same thing. The Target Framework setting communicates target API level information to Xamarin.Android for use at compile time, while the Target Android version communicates target API level information to Android for use at runtime (when the app is installed and running on a device).
In general, the Target Android Version should be bounded by the Minimum Android Version and the Target Framework. That is:
Minimum Android Version <= Target Android Version <= Target Framework
Support Libraries
Android Support Libraries are an essential part of every Android application and you’ll find them absolutely everywhere. The Support Libraries offer developers the ability to add the latest and greatest features of Android to their application while maintaining backwards compatibility with older versions of Android. As new versions of the Android SDK continue to roll out, so do updates to the Support Libraries; keeping them up-to-date and installing the correct versions is an important (and sometimes frustrating) part of Android development. In this blog, I hope to demystify the Support Libraries and help you upgrade to the latest versions
For more understanding and Reference for Support libraries:https://blog.xamarin.com/mastering-android-support-libraries/

VST for Cordova only support API Level 19?

The requirements for the Visual Studio Tools for Apache Cordova specify that SDK for the API Level 19 must be installed. Do that means that apps created with it will only run on android KitKat devices? Any way to target older devices?
Please review the following article for reference:
https://msdn.microsoft.com/en-us/library/dn757054.aspx
Cordova targets a single SDK (currently 19 though a upcoming release will move this to 21). However this is just the SDK used to build - by default Cordova apps can be deployed on devices running API level 10 or higher (2.3.3). Unless you're creating a custom plugin that will use an API only available on Android 5.0, you won't be affected by the SDK used.
The Android tab on the config.xml designer allows you to set alternate values for what goes in "AndroidManifest.xml" file, but the build itself will always use SDK 19.
http://developer.android.com/guide/topics/manifest/uses-sdk-element.html
Android 4.4.x (API level 19) is required by Visual Studio to build app or create app package targeting Android platform not for running the app. You can create Cordova app targeting device running Android released before KitKat.

Resources