how to make apps for several android version ?

cristopheB 551 Reputation points
2022-12-05T14:41:50.29+00:00

Hello,

we have an app xamarin android (broadcast, call web service, bluethooth connexion, sqlite, ..) who run exclusively under android 7.
All works fine since several years.

Unhappy now, it's not possible to buy device under android 7.
Production of this device is finished and it's not possible to update old device with new version of android..
The only new device we can buy now, it's now on 10 / 11 / ..

My question concerns, how to keept the app for to run on the two version of android:

  • android 7
  • android 11

If know it's possible to know the version of the sdk by some property.
But, i don't want the app becomes a big IF statement ...
And, we don't want to have two line of development :
-> 1 line for old android 7
-> 1 line new android 10

I don't have experience about this, perhpas some persons can guide me.

thanks for time

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,377 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 81,191 Reputation points Microsoft External Staff
    2022-12-06T02:37:44.56+00:00

    Hello,

    There is no need a big IF statement and two lines of development. But you have to change some places.
    You need to set target framework to Android 11 and make sure your minimum Android Version is lower than Android 7 for your project.

    After you set the target framework to Android 11, there might be some APIs will be deprecated, you will get some deprecated warnings.

    To fix these warnings, you need to use new APIs for android 7 later and keep the old APIs for android 7 or before. You can execute runtime checks for Android versions for different APIs from different android versions.

    By the way, with the update of android version, there are some features and limitation. Please read android releases and make sure you know them before you update the android target framework.

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. cristopheB 551 Reputation points
    2022-12-06T08:28:38.713+00:00

    Hello @Leon Lu (Shanghai Wicresoft Co,.Ltd.)

    thanks for your time that exactly what i want to know

    thanks

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.