-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android API level or OS version for platform checks/TFM #43531
Comments
There is a mention of |
My working assumption was that we pick one model (either API level or OS version) because the various MSBuild properties/custom attribute are based on each other:
If some of these values are API levels while others are OS versions, we'd need a mapping table at least somewhere in MSBuild. If we can contain it there, it might be workable. For instance, we might say that I would, however, push back on a design where the attributes use API levels while the OS checks use OS version because this would mean that developer no longer knows which versions to use in checks (even if we somehow could apply the mapping to the analyzer). |
Agreed we should be consistent between attributes and build props. I'm a little conflicted on this. Ultimately API levels are an important part of the Android developer experience and ecosystem, and they will be used in some parts of the toolchain, either internally or developer-facing. As such, the the API level to OS version mappings will exist somewhere in the tooling. However, using OS versions would be both consistent with our other platforms and more in line with how most folks think about Android. |
I agree that they'd be more consistent with other platforms but I feel like most Android developers think in API levels. It's what you set in your AndroidManifest.xml You'd need to manually translate that back to an OS version before you can pass it to |
Fair, but this functionality will affect folks developing xplat libraries and apps, who may not think in the same way as developers who focus on Android. I don't have strong feelings on which should be the canonical form but I think we need to make it easy to see the mappings. For example, we could define a set of constants such that ANDROID_API_29 with a docs tooltip of "Android 10.0" or vice versa, etc. |
Sorry, what I meant by consistent is within a given platform we are consistent between the various properties and attributes. I've got zero problems with Android using API levels while iOS uses OS versions. What I am concerned about is if an Android developer uses OS version for some properties but API levels in others. Does that make sense? |
I'm torn. The simple answer is to just use the API level everywhere. Thus:
This is also consistent with Android developer guidance, with Question: is using the API level everywhere even possible? Some "historical" constructs have required that values be parsable by However, I think that the API levels are "weird" and "big", and that My heart wants OS versions. My brain wants the simplicity of API levels. |
After some discussion, we think using the Android API level makes the most sense:
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" />
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
// ...
}
// or the value of LOLLIPOP
if (android.os.Build.VERSION.SDK_INT >= 21) {
// ...
}
#include <android/api-level.h>
#if __ANDROID_API__ >= 21
// ...
#endif
// or
#ifdef __ANDROID_API_L__
// ...
#endif If we used the Android OS version in .NET, it seems like it would just be a source of confusion. Android API levels are integers, so that is going to be one difference here. We would not have a |
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Neither the .NET 5 spec nor the minimum OS platform checks spec make it clear whether Android will be using the OS version (e.g. 4.3) or the API level (e.g. 21) for the version number.
@terrajobst @mhutch
The text was updated successfully, but these errors were encountered: