Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin.Android check API Level

I have an Android App that has been developed, compiled and released using the default SDK option

Use Compile using SDK Version

I need to make additions to this application, however I do not know what SDK it targeted at compiled time when it was last tested and released.

The problem being later API levels have different requirements, such as Authorization changes where you need to seek permission from the user. I can see from the code this does not do this, so it must be earlier.

Is there a way to know from source or the previous compiled .apk which SDK was used? I do not have permission to update all of the code to add in all of these authorization changes, just have a few small changes to do.

like image 913
Lotok Avatar asked Dec 12 '25 08:12

Lotok


2 Answers

Maybe you can add your changes inside an if like this:

if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.**TheVersionYouNeed**) {
   // Your code
}
like image 184
deimian86 Avatar answered Dec 13 '25 22:12

deimian86


An .apk is just a zip file, so unzip it and look at the manifest xml file.

Near the top of the file you should find an element that can contain the min, target and max SDK.

<uses-sdk android:minSdkVersion="integer"
          android:targetSdkVersion="integer"
          android:maxSdkVersion="integer" />

You will be looking for the targetSdkVersion API level

re: https://developer.android.com/guide/topics/manifest/uses-sdk-element.html

like image 20
SushiHangover Avatar answered Dec 13 '25 20:12

SushiHangover



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!