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

[Bug] Duplicate class com.google.firebase.iid.FirebaseInstanceIdReceiver found #1274

Closed
revolt3r opened this issue May 16, 2022 · 10 comments
Closed

Comments

@revolt3r
Copy link

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2020.3.34
  • Firebase Unity SDK version: 8.10.1
  • Source you installed the SDK: .tgz with Unity Package Manager
  • Problematic Firebase Component: Messaging?
  • Other Firebase Components in use: Auth, Database, Firestore, Functions, Messaging, RemoteConfig, Analytics
  • Additional SDKs you are using: I think that's not relevant for this issue
  • Platform you are using the Unity editor on: Windows
  • Platform you are targeting: iOS, Android
  • Scripting Runtime: IL2CPP

[REQUIRED] Please describe the issue here:

(Please list the full steps to reproduce the issue. Include device logs, Unity logs, and stack traces if available.)

Steps to reproduce:

Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)?
What's the issue repro rate? 100%

What happened? How can we make the problem occur?
Building fails with the following error:

Execution failed for task ':launcher:checkDebugDuplicateClasses'.

1 exception was raised by workers:
java.lang.RuntimeException: Duplicate class com.google.firebase.iid.FirebaseInstanceIdReceiver found in modules jetified-firebase-iid-20.0.1-runtime.jar (com.google.firebase:firebase-iid:20.0.1) and jetified-firebase-messaging-23.0.3-runtime.jar (com.google.firebase:firebase-messaging:23.0.3)

@paulinon paulinon removed the new New issue. label May 16, 2022
@paulinon
Copy link
Contributor

Hi @revolt3r,

Thanks for reporting this issue. Could you try these steps and see if they help resolve the issue:

  1. Enable Custom Gradle Properties Template under Player Settings > Settings for Android > Publishing Settings
  2. Make sure these lines of code are present in your gradleTemplate.properties file:
android.useAndroidX = true
android.enableJetifier = true
  1. Select Force Resolve under Assets > External Dependency Manager > Android Resolver

I'm looking forward to your results.

@paulinon paulinon added the needs-info Need information for the developer label May 17, 2022
@revolt3r
Copy link
Author

Hi @paulinon,

These settings were all already in place. "Force Resolve" was successful, but I'm still getting the same "duplicate class" error during the build.

I forgot to mention that I'm upgrading from 8.6.2 to 8.10.1 -> I had no issues before the update.

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels May 17, 2022
@mrtrizer
Copy link

mrtrizer commented May 18, 2022

Same problem here.
Firebase version: 8.10.1 upgrading from 8.7
Unity 2019.4.35f1
Gradle template already contains useAndroidX and enableJetifier set true

* What went wrong:
Execution failed for task ':launcher:checkReleaseDuplicateClasses'.
> 1 exception was raised by workers:
  java.lang.RuntimeException: Duplicate class com.google.firebase.iid.FirebaseInstanceIdReceiver found in modules jetified-firebase-iid-20.0.1-runtime.jar (com.google.firebase:firebase-iid:20.0.1) and jetified-firebase-messaging-23.0.3-runtime.jar (com.google.firebase:firebase-messaging:23.0.3)

@paulinon
Copy link
Contributor

Thanks for the additional details, folks. I haven't encountered the error message yet. Could you provide the complete steps you've taken in replicating this issue?

@paulinon paulinon added needs-info Need information for the developer and removed needs-attention Need Googler's attention labels May 18, 2022
@revolt3r
Copy link
Author

There are no specific steps, it's just failing during a normal build.
With Firebase 8.6.2 the build finished with no issues.
After updating all Firebase libs to 8.10.1, the build started failing with this error.

It seems like the Messaging module is conflicting with the core Firebase (at least that's what it looks like from the error)
@paulinon did you try to make a build with this mix of modules and it succeeds with no issues?

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels May 19, 2022
@mrtrizer
Copy link

mrtrizer commented May 19, 2022

I'm updating Firebase for the first time. This is how I did this:

  1. Downloaded Firebase 8.10.1 archive
  2. Deleted Firebase directory from Assets
  3. Imported new packages one by one (Auth, Messaging, Functions, Firestore, Functions, Database, Analytics, Storage)
  4. Restored google-services and GoogleService-Info in Firebase dir
  5. Made Force Reload in External Dependency Manager
  6. Tried to build as usually via BuildPipeline.BuildPlayer function

I also tried Library and obj dirs removal, didn't helped.

Gradle template:

unityStreamingAssets=.unity3d**STREAMING_ASSETS**
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
# Android Resolver Properties Start
android.useAndroidX=true
android.enableJetifier=true
# Android Resolver Properties End
**ADDITIONAL_PROPERTIES**

If you need content of other files, just let me know.

It looks like the deprecated library jetified-firebase-iid is taken from maven. I'm not sure is it really needed for the project or not, but I just can't find out why it's downloaded and what package requires it because it's not present in any of my Dependencies.xml files. Maybe I need to update some other package in addition to Firebase or something like this.

@paulinon
Copy link
Contributor

Thanks for the additional context, folks. I was able to replicate this issue when multiple Firebase products are in the Unity project as you described. I'll relay my findings to the team.

That being said, I'll be marking this as a bug for now. You may refer to this thread for any updates.

@paulinon paulinon added type: bug and removed type: question needs-attention Need Googler's attention labels May 19, 2022
@mrtrizer
Copy link

mrtrizer commented May 19, 2022

Btw looks like the same or at least related problem #1093

The line <androidPackage spec="com.google.firebase:firebase-iid:21.1.0"> </androidPackage> has disapeared from MessagingDependencies.xml according to diff.

Build worked for me after adding this dependency to Messaging and running Resolve

@a-maurice
Copy link
Contributor

Thanks for flagging this, it seems the extra dependency got lost when we transitioned to the new build system. The workaround is as @mrtrizer pointed out above, adding
<androidPackage spec="com.google.firebase:firebase-iid:21.1.0"> </androidPackage> to the MessagingDependencies.xml file manually.

@a-maurice
Copy link
Contributor

We've released a new version of the Firebase for Unity SDK, 9.0.0, available here: https://github.com/firebase/firebase-unity-sdk/releases/tag/v9.0.0, that includes the fix for this. Thanks again for flagging it.

@firebase firebase locked and limited conversation to collaborators Jun 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants