dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.93k stars 531 forks source link

Missing `androidx.window.[extensions|sidecar]` warnings #6809

Closed gmck closed 3 months ago

gmck commented 2 years ago

Android application type

Classic Xamarin.Android (MonoAndroid12.0, etc.)

Affected platform version

VS2022 17.2.0 Preview 1.0

Description

After upgrading all my nugets to the latest versions, the following are new warnings.

Severity    Code    Description Project File    Line    Suppression State
Warning     Found conflicts between different versions of "System.Numerics.Vectors" that could not be resolved.
There was a conflict between "System.Numerics.Vectors, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
    "System.Numerics.Vectors, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
    References which depend on "System.Numerics.Vectors, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Numerics.Vectors.dll].
        C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Numerics.Vectors.dll
          Project file item includes which caused reference "C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Numerics.Vectors.dll".
            System.Numerics.Vectors
    References which depend on "System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
        C:\Users\gmcke\.nuget\packages\system.text.json\5.0.2\lib\netstandard2.0\System.Text.Json.dll
          Project file item includes which caused reference "C:\Users\gmcke\.nuget\packages\system.text.json\5.0.2\lib\netstandard2.0\System.Text.Json.dll".
            C:\Users\gmcke\.nuget\packages\system.text.json\5.0.2\lib\netstandard2.0\System.Text.Json.dll
            C:\Users\gmcke\.nuget\packages\xamarin.googleplayservices.safetynet\117.0.1.3\lib\monoandroid90\Xamarin.GooglePlayServices.SafetyNet.dll    OBDNowPros  C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets 2301    
Warning     Unable to find //manifest/application/uses-library at path: C:\Program Files (x86)\Android\android-sdk\platforms\android-31\optional\androidx.window.sidecar.jar    OBDNowPros  C:\ProjectsVS2022Preview\Android12Pros\OBDNowPro\obj\Release\120\android\AndroidManifest.xml        
Warning     Unable to find //manifest/application/uses-library at path: C:\Program Files (x86)\Android\android-sdk\platforms\android-31\optional\androidx.window.extensions.jar OBDNowPros  C:\ProjectsVS2022Preview\Android12Pros\OBDNowPro\obj\Release\120\android\AndroidManifest.xml        
Warning     Missing class androidx.window.extensions.WindowExtensions (referenced from: androidx.window.extensions.embedding.ActivityEmbeddingComponent androidx.window.embedding.EmbeddingCompat$Companion.embeddingComponent() and 3 other contexts)  OBDNowPros  C:\ProjectsVS2022Preview\Android12Pros\OBDNowPro\R8     
Warning     XA4218: Unable to find //manifest/application/uses-library at path: C:\Program Files (x86)\Android\android-sdk\platforms\android-31\optional\androidx.window.sidecar.jar            0   
Warning     MSB3073: The command ""C:\Program Files (x86)\Android\android-sdk\platform-tools\adb" -s 1A141FDF600D7C uninstall -k "com.glmsoftware.obdnowpros"" exited with code 1.          0   
Warning     XA4218: Unable to find //manifest/application/uses-library at path: C:\Program Files (x86)\Android\android-sdk\platforms\android-31\optional\androidx.window.extensions.jar         0   
Warning     MSB3277: Found conflicts between different versions of "System.Numerics.Vectors" that could not be resolved.
There was a conflict between "System.Numerics.Vectors, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
    "System.Numerics.Vectors, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
    References which depend on "System.Numerics.Vectors, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Numerics.Vectors.dll].
        C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Numerics.Vectors.dll
          Project file item includes which caused reference "C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Numerics.Vectors.dll".
            System.Numerics.Vectors
    References which depend on "System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
        C:\Users\gmcke\.nuget\packages\system.text.json\5.0.2\lib\netstandard2.0\System.Text.Json.dll
          Project file item includes which caused reference "C:\Users\gmcke\.nuget\packages\system.text.json\5.0.2\lib\netstandard2.0\System.Text.Json.dll".
            C:\Users\gmcke\.nuget\packages\system.text.json\5.0.2\lib\netstandard2.0\System.Text.Json.dll
            C:\Users\gmcke\.nuget\packages\xamarin.googleplayservices.safetynet\117.0.1.3\lib\monoandroid90\Xamarin.GooglePlayServices.SafetyNet.dll            0   

Also attaching the MS Build log. Do you need anything else from me?

Could you please advise about the following, where it comes from etc? Missing class androidx.window.extensions.WindowExtensions (referenced from: androidx.window.extensions.embedding.ActivityEmbeddingComponent

Build04032022.zip

Steps to Reproduce

N/A

Did you find any workaround?

The app deploys and runs just fine.

Relevant log output

No response

MagicAndre1981 commented 2 years ago

I've already reported this some time ago via #6375, the app still works for me even if you see the messages.

tipa commented 2 years ago

I also see those XA4218 warnings that I think have nor seen before in VS 17.0 Also, deploying an app to the simulator becomes a gamble. 90% of the times when I change my .xml files (e.g. styles.xml) and try to build+deploy the app, if fails with:

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========
MagicAndre1981 commented 2 years ago

I also see those XA4218 warnings that I think have nor seen before in VS 17.0

yes, this is new, but I also get it in VS2019 16.11.10 and started since last AndroidX Nuget updates from end of last week.

jonathanpeppers commented 2 years ago

@jpobst / @moljac would you know if there is something new about these libraries?

Warning     Unable to find //manifest/application/uses-library at path: C:\Program Files (x86)\Android\android-sdk\platforms\android-31\optional\androidx.window.sidecar.jar    OBDNowPros  C:\ProjectsVS2022Preview\Android12Pros\OBDNowPro\obj\Release\120\android\AndroidManifest.xml        
Warning     Unable to find //manifest/application/uses-library at path: C:\Program Files (x86)\Android\android-sdk\platforms\android-31\optional\androidx.window.extensions.jar OBDNowPros  C:\ProjectsVS2022Preview\Android12Pros\OBDNowPro\obj\Release\120\android\AndroidManifest.xml        
Warning     Missing class androidx.window.extensions.WindowExtensions (referenced from: androidx.window.extensions.embedding.ActivityEmbeddingComponent androidx.window.embedding.EmbeddingCompat$Companion.embeddingComponent() and 3 other contexts)  OBDNowPros  C:\ProjectsVS2022Preview\Android12Pros\OBDNowPro\R8     
Warning     XA4218: Unable to find //manifest/application/uses-library at path: C:\Program Files (x86)\Android\android-sdk\platforms\android-31\optional\androidx.window.sidecar.jar            0   
Warning     XA4218: Unable to find //manifest/application/uses-library at path: C:\Program Files (x86)\Android\android-sdk\platforms\android-31\optional\androidx.window.extensions.jar

Would these be something new where you define <uses-library> for these in your AndroidManifest.xml? We might need to add some build-time support for this.

dellis1972 commented 2 years ago

Also, deploying an app to the simulator becomes a gamble. 90% of the times when I change my .xml files (e.g. styles.xml) and try to build+deploy the app, if fails with:

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========

We are tracking this in https://github.com/xamarin/xamarin-android/issues/6652. The IDE team have an internal ticket which they are working on. I'll keep #6652 as up to date as I can.

moljac commented 2 years ago

@conceptdev Would you be so kind and help? Do you have any experience with this?

@jpobst / @moljac would you know if there is something new about these libraries?

Warning       Unable to find //manifest/application/uses-library at path: C:\Program Files (x86)\Android\android-sdk\platforms\android-31\optional\androidx.window.sidecar.jar    OBDNowPros  C:\ProjectsVS2022Preview\Android12Pros\OBDNowPro\obj\Release\120\android\AndroidManifest.xml        
Warning       Unable to find //manifest/application/uses-library at path: C:\Program Files (x86)\Android\android-sdk\platforms\android-31\optional\androidx.window.extensions.jar OBDNowPros  C:\ProjectsVS2022Preview\Android12Pros\OBDNowPro\obj\Release\120\android\AndroidManifest.xml        
Warning       Missing class androidx.window.extensions.WindowExtensions (referenced from: androidx.window.extensions.embedding.ActivityEmbeddingComponent androidx.window.embedding.EmbeddingCompat$Companion.embeddingComponent() and 3 other contexts)  OBDNowPros  C:\ProjectsVS2022Preview\Android12Pros\OBDNowPro\R8     
Warning       XA4218: Unable to find //manifest/application/uses-library at path: C:\Program Files (x86)\Android\android-sdk\platforms\android-31\optional\androidx.window.sidecar.jar            0   
Warning       XA4218: Unable to find //manifest/application/uses-library at path: C:\Program Files (x86)\Android\android-sdk\platforms\android-31\optional\androidx.window.extensions.jar

Would these be something new where you define <uses-library> for these in your AndroidManifest.xml? We might need to add some build-time support for this.

jpobst commented 2 years ago

I cannot find these types in any of Google's AndroidX packages:

But the latest releases of AndroidX do now generally have a dependency on AndroidX.Window (via Xamarin.AndroidX.SlidingPaneLayout).

conceptdev commented 2 years ago

It's my understanding that the sidecar and extensions code are what we ship on device (ie. Surface Duo), to provide the OEM-specific implementation of the Window Manager dual-screen/foldable API surface. Other OEMS (like Samsung) would ship their own packages (again, in their OS).

Android native (Kotlin/Java) apps that consume AndroidX Window Manager do not reference these libraries via gradle. Not sure where these warnings are coming from in Xamarin.Android.

On maven.google.com I don't see corresponding packages there either.

jonathanpeppers commented 2 years ago

@jpobst do any of the .aar files contain an AndroidManifest.xml file with new <uses-library/> entries?

jpobst commented 2 years ago

Hmm, yes. The androidx.window.window.aar AndroidManifest.xml contains:

<application>
    <uses-library
        android:name="androidx.window.extensions"
        android:required="false" />
    <uses-library
        android:name="androidx.window.sidecar"
        android:required="false" />
</application>
jonathanpeppers commented 2 years ago

Previously these would map to .jar files in C:\Program Files (x86)\Android\android-sdk\platforms\android-32\optional:

image

So I don't understand where these come from now...

gmck commented 2 years ago

@jonathanpeppers, @dellis1972, @jpobst

From the comments above, it would seem that the androidx.window stuff is being addressed, however, there has been no mention of the conflict between the two versions of System.Numeric.Vectors or has it been addressed in another issue?

jonathanpeppers commented 2 years ago

There was a conflict between "System.Numerics.Vectors, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

The solution for this one is to use .NET 6 unfortunately. The problem here is that Mono has a different version of this assembly, and some package is trying to bring in a newer version from NuGet.

lilunxm12 commented 2 years ago

For my project, upgrade Xamarin.AndroidX.Legacy.Support.V13 to newest 1.0.0.13 triggers the error, revert back to 1.0.0.12 and errors disappear.

dooferorg commented 2 years ago

Confirmed that version 1.0.0.12 on the Xamarin.AndroidX.Legacy.SupportV4 also makes this error go away. 1.0.0.13 has quite the breaking change for a point release.

jpobst commented 2 years ago

Which error are you referring to? This issue lists 2 new warnings.

lilunxm12 commented 2 years ago

Which error are you referring to? This issue lists 2 new warnings.

For me it's the two XA4218 missing jars. androidx.window.sidecar.jar and androidx.window.extensions.jar

gmck commented 2 years ago

@jpobst I still get all the same warnings as to when I first reported it. I'm now using VS2022 17.3.0 Prev 1.1

moljac commented 2 years ago

For me it's the two XA4218 missing jars. androidx.window.sidecar.jar and androidx.window.extensions.jar

Sec! Missing androidx.window.sidecar.jar???

Official google maven does not mention androidx.window.sidecar artifact (neither jar or aar):

https://maven.google.com/web/index.html?q=androidx.window#androidx.window

if you step out of Microsoft world there are few pointers (though there is MS FTE working on the issue):

In

https://groups.google.com/a/chromium.org/g/java/c/bf9if0l3VJ4?pli=1

there is explanation (seems like internal classes and interfaces, kotlin vs java and R8/proguard tooling) and horrible workaround.

Seems that problem is 2+ years old. Seems our tooling just got better with surfacing warnings too.

moljac commented 2 years ago

Also related;

https://github.com/xamarin/AndroidX/issues/542

moljac commented 2 years ago

@jonathanpeppers @jpobst From AndroidX issue

TL&DR;

where would:

sun.misc.Signal
sun.misc.SignalHandler
java.lang.ClassValue
java.lang.instrument.ClassFileTransformer

come from???

dooferorg commented 2 years ago

Which error are you referring to? This issue lists 2 new warnings.

It was the ones I googled for that got me to this thread.

Warning Unable to find //manifest/application/uses-library at path: C:\Program Files (x86)\Android\android-sdk\platforms\android-31\optional\androidx.window.sidecar.jar Warning Unable to find //manifest/application/uses-library at path: C:\Program Files (x86)\Android\android-sdk\platforms\android-31\optional\androidx.window.extensions.jar

These were not files I intentionally included.

So something changed between the 1.0.0.12 and 1.0.0.13 releases that caused this since reverting made the error go away.

jpobst commented 2 years ago

Ok, those are just warnings, not errors. It is suggested to ignore them.

jonathanpeppers commented 2 years ago

For apps that end up with this in their manifest:

<application>
    <uses-library
        android:name="androidx.window.extensions"
        android:required="false" />
    <uses-library
        android:name="androidx.window.sidecar"
        android:required="false" />
</application>

We look for these libraries in platforms\android-*\optional and if we don't find them, emit these warnings:

XA4218: Unable to find //manifest/application/uses-library at path: C:\Program Files (x86)\Android\android-sdk\platforms\android-31\optional\androidx.window.sidecar.jar            0   
XA4218: Unable to find //manifest/application/uses-library at path: C:\Program Files (x86)\Android\android-sdk\platforms\android-31\optional\androidx.window.extensions.jar

We could remove these warnings, but I'm not sure that's the right path.

These libraries are passed to d8/r8 as a "reference" and they don't get included on the app. They are normally libraries that OEMs provide on certain devices. If we had them we could solve the XA4218 warning, and the d8/r8 warning.

I found one library:

Are we supposed to be using this somehow? It's only in alpha.

jpobst commented 2 years ago

I still get all the same warnings as to when I first reported it. I'm now using VS2022 17.3.0 Prev 1.1

@gmck

These warnings are coming from AndroidX (Xamarin.AndroidX.Window), VS updates will not fix it.

dooferorg commented 2 years ago

Ok, those are just warnings, not errors. It is suggested to ignore them.

Not good practice to simply 'ignore warnings'. Not how I like to write my programs. Thank you for your opinion.

jpobst commented 2 years ago

@jonathanpeppers

It comes from Xamarin.AndroidX.Window.

Most Android apps will eventually depend on this package through a long enough dependency chain:

Microsoft.Maui.Dependencies
-> Xamarin.AndroidX.Navigation.Fragment
  -> Xamarin.AndroidX.SlidingPaneLayout
    -> Xamarin.AndroidX.Window
jonathanpeppers commented 2 years ago

What about window-extensions, though? It seems like r8 wants that .jar to avoid some warnings? If that file was added to the AndroidExternalJavaLibrary item group, it would go away.

We'd have to change something in Xamarin.Android to fix our warning, it could probably check the AndroidExternalJavaLibrary item group to skip the warning.

jpobst commented 2 years ago

What about window-extensions, though?

It might fix one of the warnings, but not the sidecar one. The "jar" is also called window-extensions-1.0.0-alpha01.aar so I'm not sure if that will work?

Maybe we should be looking at the required attribute and not warning if it's false?

<uses-library
        android:name="androidx.window.extensions"
        android:required="false" />

Granted, that's why it's only a warning and not an error.

jonathanpeppers commented 2 years ago

The required="false", means it is a library only present on some devices (OEMs put it there).

The example is android.car.jar:

image

Your app might use that but work on phones, and it would only be present on embedded Android Auto devices.

jpobst commented 2 years ago

Maybe when these libraries are stable Google will add them to /optional?

dellis1972 commented 2 years ago

For apps that end up with this in their manifest:

<application>
    <uses-library
        android:name="androidx.window.extensions"
        android:required="false" />
    <uses-library
        android:name="androidx.window.sidecar"
        android:required="false" />
</application>

Maybe we should not emit the warning when we cannot find the library in optional if required is false ?

moljac commented 2 years ago

@jonathanpeppers

We could remove these warnings, but I'm not sure that's the right path.

I would not do that. Warnings are not caused by us.

These libraries are passed to d8/r8 as a "reference" and they don't get included on the app. They are normally libraries that OEMs provide on certain devices. If we had them we could solve the XA4218 warning, and the d8/r8 warning.

I found one library:

This leads to correct official location

https://maven.google.com/web/index.html?q=androidx.window#androidx.window:window-extensions

Are we supposed to be using this somehow? It's only in alpha.

No. It was bound when androidx.window.* was in preview for Screen Duo work, but not touched/updated afterwards.

https://github.com/xamarin/AndroidX/blob/main/config.json#L1325-L1348

see my comment:

https://github.com/xamarin/xamarin-android/issues/6809#issuecomment-1060800332

workgroupengineering commented 2 years ago

the warnings are still present in Visual Studio Version 17.3.0 Preview 6.0

moljac commented 2 years ago

the warnings are still present in Visual Studio Version 17.3.0 Preview 6.0

Thanks for the feedback, but Visual Studio version has nothing to do with this issue.

See: https://github.com/xamarin/xamarin-android/issues/6809#issuecomment-1138617639

rvalitov commented 1 year ago

I still get all the same warnings as to when I first reported it. I'm now using VS2022 17.3.0 Prev 1.1

@gmck

These warnings are coming from AndroidX (Xamarin.AndroidX.Window), VS updates will not fix it.

I have the same warnings after upgrading the project to a newer Xamarin version using VS 17.5.2. I didn't have the Xamarin.AndroidX.Window package installed but still I got the errors. After installing this package just to test there were no changes in the build output log.

ivmirx commented 5 months ago

Both warnings are still present after migrating a Xamarin.Android app to .NET 8