Skip to content
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

Build error when using some packages on Android #10152

Closed
nCastle1 opened this issue Sep 15, 2022 · 13 comments
Closed

Build error when using some packages on Android #10152

nCastle1 opened this issue Sep 15, 2022 · 13 comments
Labels
nuget Bumps for nuget packages p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/android 🤖 t/bug Something isn't working
Milestone

Comments

@nCastle1
Copy link

Description

When attempting to build an Android project there is the following error:

/Users//Projects/ARCoreBuildTest/ARCoreBuildTest/obj/Debug/net6.0-android/AndroidManifest.xml(18,18): Error AMM0000: 
	Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from AndroidManifest.xml:22:18-91
	is also present at AndroidManifest.xml:24:18-86 value=(androidx.core.app.CoreComponentFactory).
	Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:12:3-29:17 to override.
 (AMM0000) (ARCoreBuildTest) java

SceneForm.UX package depends on Xamarin.Android.Support.Fragment. Referencing Xamarin.Android.Support.Fragment also fails to build but with a different error.

Steps to Reproduce

  1. Create a new MAUI app
  2. Add a reference to Xamarin.Android.SceneForm.UX version 1.17.1
  3. Attempt to build the app for Android

Link to public reproduction project repository

https://github.com/nCastle1/maui-bug-repro-repo

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android

Did you find any workaround?

No

Relevant log output

Build FAILED.

MANIFESTMERGER : /Users//Projects/ARCoreBuildTest/ARCoreBuildTest/obj/Debug/net6.0-android/lp/121/jl/AndroidManifest.xml warning : 
MANIFESTMERGER : /Users//Projects/ARCoreBuildTest/ARCoreBuildTest/obj/Debug/net6.0-android/lp/18/jl/AndroidManifest.xml warning : 
/Users//Projects/ARCoreBuildTest/ARCoreBuildTest/obj/Debug/net6.0-android/AndroidManifest.xml(22,18): java error AMM0000: 
/Users//Projects/ARCoreBuildTest/ARCoreBuildTest/obj/Debug/net6.0-android/AndroidManifest.xml(22,18): java error AMM0000: 	Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from AndroidManifest.xml:22:18-91
/Users//Projects/ARCoreBuildTest/ARCoreBuildTest/obj/Debug/net6.0-android/AndroidManifest.xml(22,18): java error AMM0000: 	is also present at AndroidManifest.xml:24:18-86 value=(androidx.core.app.CoreComponentFactory).
/Users//Projects/ARCoreBuildTest/ARCoreBuildTest/obj/Debug/net6.0-android/AndroidManifest.xml(22,18): java error AMM0000: 	Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:12:3-29:17 to override.
/Users//Projects/ARCoreBuildTest/ARCoreBuildTest/obj/Debug/net6.0-android/AndroidManifest.xml(22,18): java error AMM0000: 
    2 Warning(s)
    1 Error(s)
@nCastle1 nCastle1 added the t/bug Something isn't working label Sep 15, 2022
@rachelkang rachelkang added this to the Backlog milestone Sep 16, 2022
@ghost
Copy link

ghost commented Sep 16, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@rachelkang rachelkang added the nuget Bumps for nuget packages label Sep 16, 2022
@dotMorten
Copy link
Contributor

dotMorten commented Oct 5, 2022

This issue is a showstopper for us wrt supporting .NET MAUI. We can't add AR support to our libraries without this, and are stuck on Xamarin.Forms.

@moljac
Copy link
Contributor

moljac commented Oct 6, 2022

Those are old libraries/components/packages in XamarinComponents

https://github.com/xamarin/XamarinComponents/tree/main/Android/ARCore

https://github.com/xamarin/XamarinComponents/tree/main/Android/SceneForm

and they don't have net6 support

https://github.com/xamarin/XamarinComponents/blob/main/Android/SceneForm/source/Core/Core.csproj#L3

and do not depend on AndroidX, rather on triassic legacy Android.Support packages.

@dotMorten
Copy link
Contributor

So how are we going to use ARCore in a MAUI app?

@moljac
Copy link
Contributor

moljac commented Oct 8, 2022

Best bet would be - update for ARCore and SceneForm and some testing. I will try to do it, but cannot promise when.

@dotMorten
Copy link
Contributor

Any update to this and getting the bindings updated for .NET 6?

@SokoFromNZ
Copy link

When can we expect a fix for this so Toolkit will work on MAUI? I would only need Android support at the moment...

@mgierlasinski
Copy link
Contributor

@nCastle1 You are referencing Support packages and AndroidX, usually sooner or later it will cause troubles. There is the same attribute defined in 2 packages:

  • android.support.v4.app.CoreComponentFactory
  • androidx.core.app.CoreComponentFactory)

Manifestest merger doesn't know which one is correct. Try adding to AndroidManifest.xml in your app:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
          xmlns:tools="http://schemas.android.com/tools">
        <application android:appComponentFactory="androidx.core.app.CoreComponentFactory" 
                     tools:replace="android:appComponentFactory"/>
</manifest>

This tells manifest merger that your app is overriding attribute android:appComponentFactory with value androidx.core.app.CoreComponentFactory.

You can look at AndroidManifest.xml from AndroidX for reference:
https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-main/core/core/src/main/AndroidManifest.xml

@dotMorten
Copy link
Contributor

You are referencing Support packages and AndroidX

It looks like the issue here then is that Xamarin.Android.SceneForm.UX is pulling in the support dependency. We really need an updated version of the SceneForm bindings that works with .NET 6.

/cc @moljac

@dotMorten
Copy link
Contributor

Btw wrt the proposed app manifest workaround, that just gets me to a new exception:

2>Exception in thread "main" java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj\Release\net6.0-android\lp\32\jl\bin\classes.jar:androidx/versionedparcelable/NonParcelField.class
2>	at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:98)
2>	at com.android.tools.r8.D8.main(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:4)
2>Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj\Release\net6.0-android\lp\32\jl\bin\classes.jar:androidx/versionedparcelable/NonParcelField.class
2>	at Version.fakeStackEntry(Version_3.3.28.java:0)
2>	at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:75)
2>	at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:28)
2>	at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:27)
2>	at com.android.tools.r8.internal.Bj.b(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:2)
2>	at com.android.tools.r8.D8.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:22)
2>	at com.android.tools.r8.D8.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:17)
2>	at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:85)
2>	... 1 more
2>Caused by: com.android.tools.r8.internal.f: Type androidx.versionedparcelable.NonParcelField is defined multiple times: obj\Release\net6.0-android\lp\32\jl\bin\classes.jar:androidx/versionedparcelable/NonParcelField.class, obj\Release\net6.0-android\lp\72\jl\classes.jar:androidx/versionedparcelable/NonParcelField.class
2>	at com.android.tools.r8.internal.DT.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:14)
2>	at com.android.tools.r8.internal.DT.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:22)
2>	at com.android.tools.r8.internal.CN.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:33)
2>	at com.android.tools.r8.internal.CN.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:10)
2>	at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2048)
2>	at com.android.tools.r8.internal.CN.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:6)
2>	at com.android.tools.r8.graph.B2$a.e(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:4)
2>	at com.android.tools.r8.dex.b.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:105)
2>	at com.android.tools.r8.dex.b.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:28)
2>	at com.android.tools.r8.D8.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:25)
2>	at com.android.tools.r8.D8.d(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:606)
2>	at com.android.tools.r8.D8.c(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:1)
2>	at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:24)
2>	... 5 more
2>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.476\tools\Xamarin.Android.D8.targets(79,5): error : java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj\Release\net6.0-android\lp\32\jl\bin\classes.jar : androidx/versionedparcelable/NonParcelField.class
2>Done building project "ARToolkit.SampleApp.Android.csproj" -- FAILED.
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

@mikeparker104 mikeparker104 added the partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with label Feb 16, 2023
@samhouts samhouts added the p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint label Feb 16, 2023
@jpobst
Copy link
Contributor

jpobst commented Mar 24, 2023

Note that packages in XamarinComponents (including Xamarin.Android.SceneForm.UX) are no longer maintained by Microsoft: https://github.com/xamarin/XamarinComponents/blob/main/README.md.

Also note that it appears Google has discontinued SceneForm, so you may want to pursue an alternative library to use:
https://developers.google.com/sceneform/develop

The Microsoft provided bindings bind the latest version of SceneForm from Google (https://maven.google.com/web/index.html?q=sceneform#com.google.ar.sceneform.ux:sceneform-ux) and it appears Google never updated the library to use AndroidX instead of Android Support Libraries.

One thing you can try is adding the Xamarin.AndroidX.Migration package to your project. If this package is referenced then the AndroidSupport -> AndroidX migration is run on your project. This is no longer done by default on .NET 6+, but adding the package to your project will cause it to run.

@jonathanpeppers
Copy link
Member

I concur with @jpobst's assessment here.

To reiterate some things:

So, I don't think there is anything to be done here. But please file a new issue if you are hitting a similar problem with a different combination of NuGet packages that are supported. Thanks!

@dotMorten
Copy link
Contributor

@jonathanpeppers @jpobst I think that's fair to skip SceneForm considering its outdated support. It does still beg the question around the base ARCore library. It's by now several versions behind, and while it doesn't exhibit the above build error, it is still only targeting the old xamarin.android runtime. Having all the XamarinComponents deprecated is still a bit of an issue - some of them are still very valuable.

@ghost ghost locked as resolved and limited conversation to collaborators May 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
nuget Bumps for nuget packages p/1 Work that is important, and has been scheduled for release in this or an upcoming sprint partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/android 🤖 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests