Closed beeradmoore closed 2 years ago
Hello @beeradmoore , I think I found a temporary workaround to develop and run Android Wear OS while the official fix is provided.
I'm on using .NET 6.0.300, Visual Studio for Mac RC2 and MAUI RC3
Error: java.nio.file.NoSuchFileException: /Users/demo/Personal/demo/App/src/demo/Acceso.Wear/Acceso.Wear/obj/Debug/lp/48/jl/res/values/values.xml
just ignore them and even with errors, just click on RUN.Note: I created a Wear OS emulator using Android 11, it is the one you can see on the screenshot I shared above. Note 2: When closing and opening VS for Mac, I get this error on package console, just for your information:
Detected package version outside of dependency constraint: Xamarin.Android.Support.Percent 26.1.0.1 requires Xamarin.Android.Support.Compat (= 26.1.0.1) but version Xamarin.Android.Support.Compat 28.0.0.3 was resolved.
I hope this helps with some insights to solve the root cause of the issue with the tooling on VS for Mac or the update for nugets packages officially from Microsoft to support WearOS.
Oh, neato! Followed your directions and I found a few things.
Unsure if this is what the java.nio.file.NoSuchFileException
warning you were getting is relating to but I found adding xml files the build type was set to none by default and not AndroidResource.
The
Xamarin.Android.Support.Percent 26.1.0.1 requires Xamarin.Android.Support.Compat (= 26.1.0.1)
warning appears to be because Xamarin.Android.Wear has it as a dependency like that.
At this point I have not installed Xamarin.AndroidX.ConstraintLayout
or Xamarin.AndroidX.Lifecycle.LiveData
. But now get different errors building.
/Users/bradmoore/.nuget/packages/xamarin.android.support.annotations/28.0.0.3/build/monoandroid90/Xamarin.Android.Support.Annotations.targets(20,3): error MSB4062: The "Xamarin.Android.Support.BuildTasks.VerifyVersionsTask" task could not be loaded from the assembly /Users/bradmoore/.nuget/packages/xamarin.android.support.annotations/28.0.0.3/build/monoandroid90/Xamarin.Android.Support.BuildTasks.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
/Users/bradmoore/.nuget/packages/xamarin.android.support.annotations/28.0.0.3/build/monoandroid90/Xamarin.Android.Support.Annotations.targets(20,3): error MSB4062: Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
VS gave me the option to enable building MSBuild on Mono, and a link to this site for more information.
But even enabling that I don't get past this error. Even attempted restarting VS but it was a big fat nope.
Here is my current project without Xamarin.AndroidX.ConstraintLayout
and Xamarin.AndroidX.Lifecycle.LiveData
(although adding them didn't change this error)
Hello @beeradmoore , I was able to simplify the packages dependencies and compile without any errors and no more warnings on the packages.
Please find below the project zipped and a screenshot of the configuration. One thing, I forgot to mention on my previous comment was that I had to increase the Minimum Android Version Target to 6.0 API level 23.
However, I believe, I have been using the MonoCompiler instead of the MS Build new project structure, because I noticed that your .csproj is different from the one the VS for Mac 2022 RC2 created automatically for me.
Hello again @beeradmoore, After being in touch with the community on Discord, we were able to solve the issue.
The following project has been updated by removing the old dependencies and just leave the AndroidX ones. Also updated the MainActivity.cs to reflect the new APIs provided on AndroidX.
@maddymontaquila do you think the MS can give us a hand to update the VS for Mac and Windows 2022 tooling for creating Android WearOS Apps for .NET 6 new csproj styles and also include the new packages and MainActivity.cs layout, please.
Reminder: Set the Minimum Android Version Target to 6.0 API level 23 (it never compiled on version 21 or 22)
See also:
The big takeaways:
Xamarin.Android.Support
packages, and all other Xamarin.Android.Support
packages for that matter.WearableActivity
is dead, just use Activity
and the new AmbientModeSupport
fragmentThe really big takeaway: we need to update the Wear template in VSMac.
@vhugogarcia awesome job! I was able to replicate the steps you had done (and with what @jonpryor had said) but to my own project and got it working. With my new project and the two you posted above I still have the same warnings I had before but everything still works. Unsure if I am missing something from being installed.
obj/Debug/net6.0-android31/android/AndroidManifest.xml : warning XA4218: Unable to find //manifest/application/uses-library at path: /Users/bradmoore/Library/Developer/Xamarin/android-sdk-macosx/platforms/android-31/optional/com.google.android.wearable.jar
obj/Debug/net6.0-android31/android/AndroidManifest.xml : warning XA4218: Unable to find //manifest/application/uses-library at path: /Users/bradmoore/Library/Developer/Xamarin/android-sdk-macosx/platforms/android-31/optional/androidx.window.extensions.jar
obj/Debug/net6.0-android31/android/AndroidManifest.xml : warning XA4218: Unable to find //manifest/application/uses-library at path: /Users/bradmoore/Library/Developer/Xamarin/android-sdk-macosx/platforms/android-31/optional/androidx.window.sidecar.jar
@jonpryor what server are those discord channels on? When I try go to them it just says no text channel here, probably because I am not on that server.
What's the process for submitting/requesting new templates for VS4Mac (and VS for Windows as well I guess) so we can get those updated?
In .NET 6, template live inside optional workloads, and what was offer right now is here:
https://github.com/xamarin/xamarin-android/tree/main/src/Microsoft.Android.Templates
Was the mentioned template above for Xamarin.Android?
We could add an android-wear
template for .NET 6. Is this common enough to be needed? If someone is really interested in this, send a PR, thanks!
We could add an
android-wear
template for .NET 6. Is this common enough to be needed? If someone is really interested in this, send a PR, thanks!
I think they created an old Wear template then converted it. So we should probably do one for .NET 6.
The ones I was making was with 'dotnet new android' and the copying over things from one templates in VS4mac 2019 to make files match (eg. dimens.xml, activity_main.xml)
EDIT: @jonathanpeppers , do you know if workload templates show up in Visual Studio on both Windows and Mac (or at least the preview versions of them both)?
The templates in VS Mac do not yet support finding templates inside .NET optional workloads -- when that feature is available, it should display the latest .NET 6+ or MAUI templates.
So I think we are good to close this? Anyone looking to target Android Wear should try the template in #7013 thanks!
Android application type
Android for .NET (net6.0-android, etc.)
Affected platform version
VS4Mac 2022 Preview (17.0 build 8904), .NET 6.0.300, Xamarin.Android 12.3.0.3
Description
I have been trying to use net6.0-android as the target framework to build a WearOS wearable app after it was mentioned in an (unofficial) .NET MAUI Platforms Support gist that it was supported.
The warnings below seem to indicate
android-31/optional/com.google.android.wearable.jar
is missing when in actual factcom.google.android.wearable.jar
does not exist inandroid-30/optional/
andandroid-28/optional/
which are the other folders I have there.I am unsure if those warnings relate to the R8 compilation or not.
Repro: WearOSMonoTest.zip WearOSNet6Test.zip
Extra info: I did update target framework on the first project to MonoAndroid12.0 I also updated
TargetFramework
tonet6.0-android31
because that is what was listed as the required framework on nuget.org for the nugets I added but I don't believe this is required as it has the same issues if I use net6.0-android.Steps to Reproduce
dotnet new android --name WearOSNet6Test
WearOSMonoTest
project.Did you find any workaround?
Nope.
Relevant log output