uno
uno copied to clipboard
[net6][android] SupportedOSPlatformVersion vs minSdkVersion
Current behavior
For net6.0-android the templates (both UWP and WinUI) sets the SupportedOSPlatformVersion property to 21
https://github.com/unoplatform/uno/blob/197533bd2e74c9ada52d82cf47830b87f6e94707/src/SolutionTemplate/UnoSolutionTemplate.net6/Mobile/UnoQuickStart.Mobile.csproj#L22
However the AndroidManifest.xml file sets the minSdkVersion to 16 for UWP projects
https://github.com/unoplatform/uno/blob/197533bd2e74c9ada52d82cf47830b87f6e94707/src/SolutionTemplate/UnoSolutionTemplate.net6/Mobile/Android/AndroidManifest.xml#L3
and to 21 (same as .csproj) for WinUI projects
https://github.com/unoplatform/uno/blob/197533bd2e74c9ada52d82cf47830b87f6e94707/src/SolutionTemplate/UnoSolutionTemplate.WinUI.net6/Mobile/Android/AndroidManifest.xml#L3
This leads to problems
16is too low and and fails with
DebugMyApp.Mobile/Android/AndroidManifest.xml(0,0): Error: AndroidManifest.xml //uses-sdk/@android:minSdkVersion '16' is less than API-19, this configuration is not supported.
Should it be set to 19 (which is closest to the current value) ?
or 21 which match WinUI ?
- Who wins when the values are different ?
aapt d xmltree /Users/poupou/git/uno/uno-debug-test/DebugMyApp/DebugMyApp.Mobile/obj/Debug/net6.0-android/android-arm64/android/bin/DebugMyApp.DebugMyApp.apk AndroidManifest.xml
N: android=http://schemas.android.com/apk/res/android
E: manifest (line=8)
A: android:versionCode(0x0101021b)=(type 0x10)0x1
A: android:versionName(0x0101021c)="1.0" (Raw: "1.0")
A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1f
A: android:compileSdkVersionCodename(0x01010573)="12" (Raw: "12")
A: package="DebugMyApp.DebugMyApp" (Raw: "DebugMyApp.DebugMyApp")
A: platformBuildVersionCode=(type 0x10)0x1f
A: platformBuildVersionName=(type 0x10)0xc
E: uses-sdk (line=9)
A: android:minSdkVersion(0x0101020c)=(type 0x10)0x13
A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1f
E: uses-permission (line=10)
A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
E: queries (line=11)
E: intent (line=12)
E: action (line=13)
A: android:name(0x01010003)="android.media.browse.MediaBrowserService" (Raw: "android.media.browse.MediaBrowserService")
E: application (line=16)
A: android:theme(0x01010000)=@0x7f0f0008
A: android:label(0x01010001)=@0x7f0e0000
A: android:icon(0x01010002)=@0x7f0c0000
A: android:name(0x01010003)="crc64eb2734f1e0c2babe.Application" (Raw: "crc64eb2734f1e0c2babe.Application")
A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
A: android:allowBackup(0x01010280)=(type 0x12)0xffffffff
A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xffffffff
A: android:largeHeap(0x0101035a)=(type 0x12)0xffffffff
A: android:extractNativeLibs(0x010104ea)=(type 0x12)0xffffffff
A: android:appComponentFactory(0x0101057a)="androidx.core.app.CoreComponentFactory" (Raw: "androidx.core.app.CoreComponentFactory")
E: activity (line=17)
A: android:name(0x01010003)="crc647c90b8909228a8dc.MainActivity" (Raw: "crc647c90b8909228a8dc.MainActivity")
A: android:exported(0x01010010)=(type 0x12)0xffffffff
A: android:configChanges(0x0101001f)=(type 0x11)0x40002fff
A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x22
E: intent-filter (line=18)
where the 0x13 in A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1f turns out to be decimal 19, which is the value I used inside AndroidManifest.xml to stop the error.
IOW the winner is the AndroidManifest.xml value
Expected behavior
- Ideally the template would not duplicate settings for the same value.
- If it cannot be avoided they should be identical.
- If possible a warning should tell the developer of any mismatch.
How to reproduce it (as minimally and precisely as possible)
- Create an UWP app for net6 mobile.
- Double check that the
.csprojset theSupportedOSPlatformVersionto21for Android. - Inside the
AndroidManifest.xmlsetminSdkVersionto 19 (to avoid build error) - Build app for
net6.0-android - Check the minSdkVersion inside the
.apk
Workaround
No response
Works on UWP/WinUI
No response
Environment
Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia
NuGet package version(s)
4.5.9
Affected platforms
Android
IDE
No response
IDE version
No response
Relevant plugins
No response
Anything else we need to know?
Might be related to https://github.com/xamarin/xamarin-android/issues/6739
Interesting, we should indeed at least align both, but it may automatically be generated now in net6? Some of the other parts of the manifest are, if I'm not mistaken.
I have not checked what is generated (in the manifest) with a MAUI project/template. Ideally we would only have the net6+ configuration (that was the goal) but it could be a bug too.
Also the SDK (android) does not seem to detect the different values :(