I am new to Android development. I am told to create an android app that should support android Version 5 (Lollipop) and android Version 9 (Pie). How should I approach this? Should i create 2 different apps supporting Version 5 and Version 9?
Is there any way to make a single app that runs on both version 5 and version 9?
If I use AndroidX, then will it make sure that the app look and function same on both version 5 and 9?
P.S.: I am told to build the app using Xamarin Android Native (not Xamarin Forms).
Thanks.
First you need to understand the following Settings:
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.
Normally, all three Xamarin.Android API levels are set to the same value. On the Application page, set Compile using Android version (Target Framework) to the latest stable API version (or, at a minimum, to the Android version that has all of the features you need)strong text
On the Android Manifest page, set the Minimum Android version to Use Compile using SDK version and set the Target Android version to the same value as the Target Framework version.
If you want to maintain backward compatibility with an earlier version of Android, set Minimum Android version to target to the oldest version of Android that you want your app to support.
Then in you case,you could set the Target Framework version to Android 9.0,and Minimum Android Version to Android 5,Target Android Version to Android 9.0.
Related
I'm becoming crazy. I want to compile Xamarin.Forms for Android 8.0 with Visual Studio 2019
I setup all correct, I think, but I always get:
Error The $(TargetFrameworkVersion) for App_test32.Android (v8.0) is less than the minimum required $(TargetFrameworkVersion) for Xamarin.Forms (8.1). You need to increase the $(TargetFrameworkVersion) for App_test32.Android. App_test32.Android
You cannot target 8.0 and that's for a reason. Starting from August 1, 2019 Google doesn't accept new apps that doesn't have targetSdkVersion set below Android 9.0 (for new apps).
You can read more about this here (Meet Google Play's target API level requirement) and more specifically here (Target API level requirements for the Play Console).
If you open the second link, you will see that the targetSdkVersion will be bumped even to Android 10, starting from August 3, 2020 (for new apps)
This is what you are seeing - Xamarin has restricted this, so that you don't set it lower that what it must be. Otherwise, you will be able to build it, but you won't be able to upload it. You can see the minimum version set here
However, you can still set it to 8.0, but you will need to downgrade the Xamarin.Forms & Xamarin.Android to a version that is way back - probably even before 4.0. This way you will be able to build the project, but the end result will be the same - you won't be able to upload the app to the PlayStore.
Useful link to get familiar with the difference between Target Framework, Minimum Android Version & Target Android Version from the official docs
Here is the most important comparison:
Minimum Android Version <= Target Android Version <= Target Framework
To sum up, I will quote again the guys from Microsoft (see in the link above):
We recommend that you explicitly set the Target Android version to the latest version of Android that you use to test your app. Ideally, it should be set to the latest Android SDK version – this allows you to use new APIs prior to working through the behavior changes. For most developers, we do not recommend setting the Target Android version to Use Compile using SDK version.
I am trying to make a basic Xamarin.forms (pcl) application (in Visual studio 2017) and i want to Target Lolipop (5.0.0, api level 21).
So i made a basic Xamarin solution and i adjusted the Android properties all to Android 5.0 lollipop
Compile using Android version "Android 5.0 (Lollipop)"
Minimum Android to target "Android 5.0 (API Level 21 - Lollipop)"
Target Android Version "Android 5.0 (API Level 21 - Lollipop)"
Unfortunately in my warning list i get the following
Severity Code Description Project File Line Suppression State
Warning The $(TargetFrameworkVersion) for Xamarin.Forms.Platform.dll (v7.0) is greater than the $(TargetFrameworkVersion) for your project (v5.0). You need to increase the $(TargetFrameworkVersion) for your project. Prolang.Android C:\Projects\Prolang\Prolang\Prolang.Android\Prolang.Android.csproj
If i google for this error most people say to indeed update your android project to use the latest Targetframework version. But in my case i really want to only be able to call Api calls that are available to level 21 aka Android 5.0 Lollipop. As in i want the compile time safety net that i only use Api Calls from Api level 21.
To me it seems like i have to downgrade my xamarin.Forms dll to a version that is made specifically for android lollipop since the one i use right now targets a higher version.
So should i downgrade my xamarin.forms dll to achieve this and get rid of the error? And if i downgrade to what version do i need to downgrade so i target Android 5.0 Lollipop? This information is all pretty unclear to me.
Xamarin.Forms is designed using the Android's support libraries so it will run on a wide range of APIs without any additional actions from the developer.
If you are using native APIs via Xamarin.Android (assumably via Forms' Dependency Service) then yes you would have to be aware of the API level of the method calls.
That said, since Xamarin.Forms uses the com.android.support.* libraries and you would have to have to a Forms versions that uses com.android.support:design:21.x.x and the associated Android build tools for API 21.
Now you can review the package dependancies and you will see that your choices are Forms' is 1.4
`1.4.0.6336-pre1` to `1.4.4.6449`
Note: v1.5.x moved to version 22 of the Android support libraries
IMHO using Forms's 1.4 would a bad mistake due to its age and the mountain of improvements and bugs fixes since 2015, you are so much better off:
Using the latest Forms version
Set the Framework version to latest (7.1)
Set the Target Android version to Android 5.0 (API Level 21)
Set the Minimum Android version to whatever you need...
Forgo the compile time API checks
Check runtime API issues via API-21 devices and emulators
I am using Visual Studio with Xamarin, as shown in the picture, the latest available android version for me is JellyBean, this is preventing me from using quite some new features. I have set the target version to 6.0 and minimum required version to 4.0.3. Current Configuration in Visual Studio
Does anyone has experience how to solve this issue?
Many thanks!
Greeting,
Kyle
the screenshot at version selection
This happens because of the current referenced Mono.Android.dll in your project. You are most likely setting your <TargetFrameworkVersion> to only Jellybean here. That or the highest level of Android you have installed is Jellybean and it's using the latest platform available via the following in your .csproj:
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
EX:
If you set your <TargetFrameworkVersion> in your .csproj to Jellybean:
<TargetFrameworkVersion>v4.3</TargetFrameworkVersion>
Or via the GUI in Properties -> Application -> Compile using Android version:
Android 4.3 (Jelly Bean)
You would then only have a reference to the 4.3 version of Mono.Android.dll which only includes Android.OS.BuildVersionCodes enums up to Jellybean.
Thus if you had changed your <TargetFrameworkVersion> to v6.0 you would have access to all the current Android.OS.BuildVersionCodes enums up to Marshmallow. You may need to ensure that you have these API levels installed in your Android SDK, and that the respective <TargetFrameworkVersion> is the correct version of the respective API version you'd like to use in the enum.
Im trying to compile an andriod app API level 7 with Admob Sdk 6.3.1 but Im get an error related to
"android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize">"
I googled it and learnt that I've to compile against Android 3.2 and set SDK Min to 13. But that way my app will not be compatible with Android 2.1, am I correct? Is there any workaround? Am I missing something?
No, you can compile against a higher level, but still support lower SDK levels. Per the Admob Documentation:
The Google AdMob Ads SDK for Android requires a run-time of Android 1.5 or later (set android:minSdkVersion to at least 3 in your AndroidManifest.xml). This means you can develop with the latest version of the Android SDK and your app will still run on an earlier Android version (1.5 minimum).
While creating an android project if i say that the Build Target of my Android porject is 2.2 (API Level is picked as 8) and in the text box for Min SDK version. If i put some value apart from the API level (smaller or greater than 8) of the build target then what happens?
Does the build happen according to the build target specified, but the application developed is compatible with the smaller android versions (if i specify API level < 8 ). Or the application developed is only compatible for the higher android version (if i specify API level > 8 ).
Can anyone please explain?
There is a similiar question already posted with an excellent answer:
Read the post by Steve H.
Android Min SDK Version vs. Target SDK Version
Say you set the manifest API level to 4, then the app will work on any api 4 device provided. BUT the project will be built to API level 8 so if you have any post-level 4 api methods in your code then the app will crash.
You can only put min SDK version less than your target version,it tell that your application can support to that min SDK version,but you should confirm that your application should run under min SDK version supported devices since the Build target versions may use new APIs which are available for that specific version and those APIs may not available in min SDK versions
ok.. if you have developed an application using particular sdk for instance Android 2.2 and your minSDKversion is < 8 then application is falsely declaring to android system that It can be installed in Android device having sdk version less than Android 2.2. In that case if application happens to install on Android 2.1 and if you re using API that are exculsiviely avaialbe in Android 2.2 platform and not on Android 2.1 then your application will crash on the device. if your minsdkversion > 8 then application won't get installed on the device having Android sdk 2.2 or lower version