googleads / googleads-mobile-unity

Official Unity Plugin for the Google Mobile Ads SDK
https://developers.google.com/admob/unity
Apache License 2.0
1.34k stars 1.09k forks source link

Duplicate class with Firebase #3101

Closed cephalo3 closed 5 months ago

cephalo3 commented 5 months ago

Step 0: Are you in the right place?

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

What happened? How can we make the problem occur? This could be a description, log/console output, etc.

Please share a downloadable sample project that reproduces the bug, if available. This greatly helps us to diagnose and fix the issue faster.

Relevant Code:

Can't build latest GoogleMobileAds with the latest Firebase

There is a module collision with the following error message:
Duplicate class com.google.android.gms.internal.consent_sdk.zza found in modules jetified-com.google.android.ump.user-messaging-platform-2.0.0-runtime (:com.google.android.ump.user-messaging-platform-2.0.0:) and jetified-user-messaging-platform-2.1.0-runtime (com.google.android.ump:user-messaging-platform:2.1.0)

There are many similar messages but it all refers to the same module.

I tried exporting to Android Studio but I can't make the problem go away. I don't even know why this is a collision because the two packages use different version of the same package. How can I edit the right build.gradle file to force one or the other to use the other module. I'm not even sure I know what needs to be done. I don't know why this is a collision.

I tried downgrading GoogleMobileAds to the last one that uses com.google.android.ump.user-messaging-platform-2.0.0 but I still got the same error. What is going on and what do I need to put in my build.gradle file?
NVentimiglia commented 5 months ago

Hi @cephalo3

It sounds like the google mobile ads and firebase are both pulling in the UMP SDK.

The solution here is to modify the Google Mobile Ads Dependency file to make sure that both SDKs are pulling in the same version of the UMP SDK.

Alternatively, you can try using gradle resolution.

NVentimiglia commented 5 months ago

@cephalo3

I was unable to see any conflict when installing Firebase Analytics alongside Google Mobile Ads.

Can you let me know what firebase plugin which shows this problem?

cephalo3 commented 5 months ago

Ok, I finally after months solved this problem. Firebase puts the library in a weird spot in the assets folder, and EDM4U doesn't catch it. I solved the problem by merely deleting it. It is an aar file. I don't have access to the exact name at the moment. I'm not sure which Firebase package contributes that library, but I am using Firestore, Auth, Functions and Messaging.

To find this, I had to remove the package manager version of Firebase and do unitypackage instead hoping to match it with googlemobileads. That alone didn't fix the problem but I happened to catch the filename while browsing the assets folder.

EDIT: never mind. Now I am getting a missing class. I have tried gradle resolution in Android Studio and I can't make heads or tails of it and frankly, I can't even understand the problem I'm trying to solve. Google software compatibility with Unity is a real dumpster fire right now.

EDIT2: Ok, the last thing was a proguard issue. I need a custom progaurd file for another library I use, and google ads needs some stuff in there too, so it's unrelated to my original problem. I saw an ad! Hallelujah.

NVentimiglia commented 5 months ago

Glad you fixed it. Some of these Android issues can be confusing to diagnose.