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

Duplicate Classes Issue #930

Closed
bauervision opened this issue Jan 12, 2021 · 0 comments
Closed

Duplicate Classes Issue #930

bauervision opened this issue Jan 12, 2021 · 0 comments
Labels

Comments

@bauervision
Copy link

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2020.1.7f1
  • Firebase Unity SDK version: 7.0.2
  • Source you installed the SDK: UPM
  • Problematic Firebase Component: Database
  • Other Firebase Components in use: Auth
  • Additional SDKs you are using: None
  • Platform you are using the Unity editor on: Windows
  • Platform you are targeting: Android
  • Scripting Runtime: IL2CPP

[REQUIRED] Please describe the issue here:

Trying to build an Android app with Unity 2020 and Firebase results in

 java.lang.RuntimeException: Duplicate class android.support.v4.os.ResultReceiver found in modules jetified-androidx.core.core-1.2.0-runtime.jar (:androidx.core.core-1.2.0:) and jetified-support-compat-27.1.1-runtime.jar (:support-compat-27.1.1:)
  • 426 more conflicts

This is common issue I've seen raised many times, for example here
but none of the prescribed solutions are working for me.

I have added the following to my custom gradleTemplate.properties:

android.useAndroidX=true
android.enableJetifier=true

I've tried this solution: onesignal

Steps to reproduce:

I've completely removed firebase, built and successfully deployed to my device.
I add Firebase Realtime Database via the UPM, test in editor which works great, build and run to device and all the duplicate class errors re-surface.

Relevant Code:

Here is my gradleTemplate.properties:

org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
android.enableR8=**MINIFY_WITH_R_EIGHT**
android.useAndroidX=true
android.enableJetifier=true

This is the only code I have that accesses Firebase, and it works perfectly in the Editor.

using System.Collections;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Events;
using Firebase;
using Firebase.Extensions;
using Firebase.Database;

public class FirebaseInit : MonoBehaviour
{
    public static FirebaseInit instance;
    public UnityEvent OnFirebaseInit = new UnityEvent();
    [HideInInspector] public static bool initialized = false;

    Firebase.FirebaseApp app;
    private FirebaseDatabase _db;
    public ARTargets arTargets = null;
    private string dataReferenceString = "cxrave";

    private void Start()
    {
        instance = this;
        Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task =>
        {

            if (task.Exception != null)
            {
                Debug.LogError(System.String.Format(
                   "Could not resolve all Firebase dependencies: {0}", task.Exception));
                return;
            }

            OnFirebaseInit.Invoke();
            initialized = true;
            _db = FirebaseDatabase.DefaultInstance;
            // listen for future data updates
            _db.GetReference(dataReferenceString).ValueChanged  = HandleValueChanged;

        });

    }

    private void LoadARTargetData()
    {
        _db.GetReference(dataReferenceString).GetValueAsync().ContinueWith(task =>
        {
            if (task.IsFaulted)
                Debug.LogError("task faulted"   task.Exception);
            else if (task.IsCompleted)
            {
                DataSnapshot rawData = task.Result;
                arTargets = JsonUtility.FromJson<ARTargets>(rawData.GetRawJsonValue());
            }
        });
    }

    void HandleValueChanged(object sender, ValueChangedEventArgs args)
    {
        if (args.DatabaseError != null)
        {
            Debug.LogError(args.DatabaseError.Message);
            return;
        }
        // Do something with the data in args.Snapshot
        var data = args.Snapshot.GetRawJsonValue();
        arTargets = JsonUtility.FromJson<ARTargets>(data);
        // send update to target manager to add targets to the scene
        TargetManager.HandleDataUpdate(arTargets);
    }

}

What am I missing concerning these duplicate classes?

Thanks in advance.

@bauervision bauervision added the new New issue. label Jan 12, 2021
@firebase firebase locked and limited conversation to collaborators Feb 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants