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

Failed resolution of: Lcom/google/android/datatransport/TransportFactory when using Xamarin.Firebase in MAUI #560

Closed
chrfin opened this issue Jan 5, 2022 · 6 comments

Comments

@chrfin
Copy link

chrfin commented Jan 5, 2022

Xamarin.Android Version (eg: 6.0):

.NET MAUI Preview 11 targeting net6.0-android

Operating System & Version (eg: Mac OSX 10.11):

Android 11.0 simulator

Google Play Services Version

  • Xamarin.GooglePlayServices.Base (version 117.6.0.3)
  • Xamarin.Firebase.Messaging (version 122.0.0.3)

Describe your Issue

When I added the Xamarin.Firebase.Messaging package my app crashes when starting the app with the exception:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/datatransport/TransportFactory;

Via trail and error I found out this happens for all Xamarin.Firebase.* packages, but not when referencing e.g. Xamarin.Google.Android.DataTransport.TransportRuntime directly.

Relevant information

Packages used:

		<PackageReference Include="Xamarin.Firebase.Messaging" Version="122.0.0.3" />
		<PackageReference Include="Xamarin.GooglePlayServices.Base" Version="117.6.0.3"/>

Build settings (tools)

    Default template from .NET MAUI P11

Steps to Reproduce (with link to sample solution if possible):

Create a .NET MAUI app using the templates from preview 11 and add the two packages and build and run the app with android.

Include any relevant Exception Stack traces, build logs, adb logs:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/datatransport/TransportFactory;
at com.google.firebase.datatransport.TransportRegistrar.getComponents(TransportRegistrar.java:32)
at com.google.firebase.components.ComponentRuntime.discoverComponents(ComponentRuntime.java:109)
at com.google.firebase.components.ComponentRuntime.(ComponentRuntime.java:91)
at com.google.firebase.components.ComponentRuntime.(ComponentRuntime.java:45)
at com.google.firebase.components.ComponentRuntime$Builder.build(ComponentRuntime.java:360)
at com.google.firebase.FirebaseApp.(FirebaseApp.java:427)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:299)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:267)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:252)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:51)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2388)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2358)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:45)
at android.app.ActivityThread.installProvider(ActivityThread.java:7239)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6780)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6697)
at android.app.ActivityThread.access$1300(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.datatransport.TransportFactory" on path: DexPathList[[zip file "/data/app/.../base.apk"],nativeLibraryDirectories=[/data/app/.../lib/x86_64, /data/app/.../base.apk!/lib/x86_64, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 24 more

During the build I get the following warnings:

Warning in obj\Debug\net6.0-android\lp\153\jl\classes.jar:com/google/firebase/datatransport/TransportRegistrar.class:
Type com.google.android.datatransport.runtime.TransportRuntime was not found, it is required for default or static interface methods desugaring of Lcom/google/firebase/datatransport/TransportRegistrar;lambda$getComponents$0(Lcom/google/firebase/components/ComponentContainer;)Lcom/google/android/datatransport/TransportFactory;

@chrfin chrfin changed the title Failed resolution of: Lcom/google/android/datatransport/TransportFactory` when using Xamarin.Firebase in MAUI Failed resolution of: Lcom/google/android/datatransport/TransportFactory when using Xamarin.Firebase in MAUI Jan 5, 2022
@chrfin
Copy link
Author

chrfin commented Jan 6, 2022

I found a workaround:  
Basically the newest version of the firebase packages are broken. Using the following packages worked:

<ItemGroup>
  <PackageReference Include="Xamarin.Build.Download" Version="0.11.0" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.Contains('-android'))">
  <PackageReference Include="Xamarin.Google.Dagger" Version="2.39.1" />
  <PackageReference Include="Xamarin.Firebase.Messaging" Version="122.0.0.2" />
  <PackageReference Include="Xamarin.GooglePlayServices.Base" Version="117.6.0.2" />
</ItemGroup>

As soon as I use the versions ending with .3 instead of .2 for the last two its broken...

@moljac
Copy link
Member

moljac commented Apr 25, 2022

Related:

#604

@aiscrim
Copy link

aiscrim commented Aug 9, 2022

I'm facing the same issue with the GA version. Applying the workaround suggested above by @chrfin is not working either, as I fall back to this other issue: dotnet/maui#3389

Any idea?

@moljac
Copy link
Member

moljac commented Aug 10, 2022

Try updating to latest package versions and please report here if the new packages fixed the issue.

Thanks.

@aiscrim
Copy link

aiscrim commented Sep 2, 2022

@moljac sorry I couldn't try that before, now I did and I confirm that with the latest package versions it works! Thanks!

@moljac
Copy link
Member

moljac commented Jun 13, 2023

closing this issue.

Thanks

@moljac moljac closed this as completed Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants