Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Xamarin.Firebase.Messaging crashing on failed resolution of datatransport/TransportFactory #604

Closed
pfiggins opened this issue Apr 20, 2022 · 9 comments

Comments

@pfiggins
Copy link

Xamarin.Android Version (eg: 6.0):

MAUI RC1, net6.0-android

Google Play Services Version

The ones included as dependencies of Xamarin.Firebase.Messaging package version 122.0.0.5

Describe your Issue

Upgraded from MAUI Preview 14 to RC1. Had to update Xamarin.Firebase.Messaging reference from 122.0.0 to 122.0.0.5 to get it to build. It now builds and runs, but immediately crashes with the stack trace below.

Relevant information

Add relevant project settings from *.csproj file:

Packages used:

    <PackageReference Include="Google.Apis.FirebaseDynamicLinks.v1" Version="1.55.0.2510" />
    <PackageReference Include="Xamarin.Firebase.Messaging" Version="122.0.0.5" />

(I tried updating Google.Apis.FirebaseDynamicLinks.v1 to latest just to make sure that isn't creating any conflicts, but there was no change.)

Build settings (tools)

                <AndroidPackageFormat>apk</AndroidPackageFormat>
		<AndroidUseAapt2>true</AndroidUseAapt2>
		<AndroidUseSharedRuntime>true</AndroidUseSharedRuntime>
		<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
		<AndroidEnableMultiDex>true</AndroidEnableMultiDex>
		<AndroidLinkMode>None</AndroidLinkMode>

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

[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: com.company.app, PID: 14146
[AndroidRuntime] java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/datatransport/TransportFactory;
**Java.Lang.NoClassDefFoundError:** 'Failed resolution of: Lcom/google/android/datatransport/TransportFactory;'

[AndroidRuntime] 	at com.google.firebase.datatransport.TransportRegistrar.getComponents(TransportRegistrar.java:32)
[AndroidRuntime] 	at com.google.firebase.components.ComponentRuntime.discoverComponents(ComponentRuntime.java:109)
[AndroidRuntime] 	at com.google.firebase.components.ComponentRuntime.<init>(ComponentRuntime.java:91)
[AndroidRuntime] 	at com.google.firebase.components.ComponentRuntime.<init>(ComponentRuntime.java:45)
[AndroidRuntime] 	at com.google.firebase.components.ComponentRuntime$Builder.build(ComponentRuntime.java:360)
[AndroidRuntime] 	at com.google.firebase.FirebaseApp.<init>(FirebaseApp.java:427)
[AndroidRuntime] 	at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:299)
[AndroidRuntime] 	at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:267)
[AndroidRuntime] 	at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:252)
[AndroidRuntime] 	at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:51)
[AndroidRuntime] 	at android.content.ContentProvider.attachInfo(ContentProvider.java:2404)
[AndroidRuntime] 	at android.content.ContentProvider.attachInfo(ContentProvider.java:2374)
[AndroidRuntime] 	at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:45)
[AndroidRuntime] 	at android.app.ActivityThread.installProvider(ActivityThread.java:7422)
[AndroidRuntime] 	at android.app.ActivityThread.installContentProviders(ActivityThread.java:6939)
[AndroidRuntime] 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6710)
[AndroidRuntime] 	at android.app.ActivityThread.access$1500(ActivityThread.java:247)
[AndroidRuntime] 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2053)
[AndroidRuntime] 	at android.os.Handler.dispatchMessage(Handler.java:106)
[AndroidRuntime] 	at android.os.Looper.loopOnce(Looper.java:201)
[AndroidRuntime] 	at android.os.Looper.loop(Looper.java:288)
[AndroidRuntime] 	at android.app.ActivityThread.main(ActivityThread.java:7839)
[AndroidRuntime] 	at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
[AndroidRuntime] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
[AndroidRuntime] Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.datatransport.TransportFactory" on path: DexPathList[[zip file "/data/app/~~0eKJCDsujktl_Xhgt00IqA==/com.companyname.app-G7Z_XtVMiOqVpqIAkKL3pA==/base.apk"],nativeLibraryDirectories=[/data/app/~~0eKJCDsujktl_Xhgt00IqA==/com.companyname.app-G7Z_XtVMiOqVpqIAkKL3pA==/lib/x86_64, /data/app/~~0eKJCDsujktl_Xhgt00IqA==/com.companyname.app-G7Z_XtVMiOqVpqIAkKL3pA==/base.apk!/lib/x86_64, /system/lib64, /system_ext/lib64]]
[AndroidRuntime] 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:218)
[AndroidRuntime] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
[AndroidRuntime] 	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
[AndroidRuntime] 	... 25 more
@dtaylorus
Copy link

I was able to work around this issue by adding the following to my csproj file:

    <ItemGroup>
        <AndroidLibrary Include="Dependencies\transport-runtime-3.1.2.aar" Bind="false" />
        <AndroidLibrary Include="Dependencies\transport-backend-cct-3.1.2.aar" Bind="false" />
        <AndroidLibrary Include="Dependencies\transport-api-3.0.0.aar" Bind="false" />
    </ItemGroup>

I downloaded the .aar files from gradle/Maven.

After resolving this issue the app still crashes with the following error:

java.lang.IllegalArgumentException: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.

But that's another issue.

@moljac
Copy link
Member

moljac commented Apr 23, 2022

Xamarin.Google.Android.DataTransport.TransportRuntime
Xamarin.Google.Android.DataTransport.TransportBackendCct

version 3.1.2 were bound in:

#575

https://github.com/xamarin/GooglePlayServicesComponents/blob/mu-20220215/config.json#L1372-L1398

@moljac
Copy link
Member

moljac commented Apr 25, 2022

Related:

#560

@dtaylorus
Copy link

Does anyone have any version of Xamarin.GooglePlayServices.Ads working in a net6.0-android project?

I either get build errors or runtime crashes no matter what combination of things I've tried.

And when I try to build the project myself I just get a bunch of these:

Failed to download play-services-ads-sources.jar: Response status code does not indicate success: 404 (Not Found).

The build instructions reference some build.ps1 file that doesn't exist as well.

@tstpierre
Copy link

Having identical issue with a brand new MAUI new project template with any Xamarin.Firebase.* package added.

@moljac
Copy link
Member

moljac commented Jun 4, 2022

try adding proguard rules for missing classes R8 might be overly optimistic

@attilavlacsil
Copy link

@dtaylorus Firebase Messaging setup broke again with VS 17.3.0 Preview 2.0 upgrade, but your workaround works just fine. I guess the transport aar package versions must match the ones referenced by Xamarin.Firebase.Messaging NuGet package.

@moljac
Copy link
Member

moljac commented Jun 16, 2022

the problem with Firebase is simply dependencies and transitive dependencies. They have to be "aligned" or correct. Firebase team uses firebase-bom via gradle for that. We don't have anything similar for that.

I am facing similar issue in #607

stripped down error is:

Type 
    com.google.android.gms.measurement.internal.zzga 
is defined multiple times: 
    obj/Debug/lp/150/jl/classes.jar:com/google/android/gms/measurement/internal/zzga.class, 
    obj/Debug/lp/161/jl/classes.jar:com/google/android/gms/measurement/internal/zzga.class

@pfiggins
Copy link
Author

Finally circling back to this issue. I was able to get it working by following the workaround posted by @dtaylorus. The only difference was I had to use version 3.1.4 instead of 3.1.2, I assume due to an update to the nuget since his post. Thank you sir!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants