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

java.lang.IllegalStateException: FirebaseApp name [DEFAULT] already exists! #8

Open
dekart opened this issue Nov 29, 2019 · 9 comments

Comments

@dekart
Copy link

dekart commented Nov 29, 2019

Hi,

We experience this exception with installed Push SDK:

java.lang.Throwable: 
java.lang.IllegalStateException: FirebaseApp name [DEFAULT] already exists!
com.google.android.gms.common.internal.Preconditions.checkState(Unknown Source)
com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.1.0:293)
com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.1.0:266)
com.yandex.metrica.push.impl.al.a(SourceFile:30)
com.yandex.metrica.push.impl.ag.a(SourceFile:48)
com.yandex.metrica.push.impl.b.a(SourceFile:83)
com.yandex.metrica.push.YandexMetricaPush.init(SourceFile:139)
com.unity3d.player.UnityPlayer.nativeRender(Native Method)
com.unity3d.player.UnityPlayer.access$300(Unknown Source)
com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source)
android.os.Handler.dispatchMessage(Handler.java:98)
android.os.Looper.loop(Looper.java:163)
com.unity3d.player.UnityPlayer$e.run(Unknown Source)
UnityEngine.AndroidJNISafe.CheckException () (at <dcb3aea45c9345de8667cb9cbdf166d6>:0)
UnityEngine.AndroidJNISafe.CallStaticVoidMethod (System.IntPtr clazz, System.IntPtr methodID, UnityEngine.jvalue[] args) (at <dcb3aea45c9345de8667cb9cbdf166d6>:0)
UnityEngine.AndroidJavaObject._CallStatic (System.String methodName, System.Object[] args) (at <dcb3aea45c9345de8667cb9cbdf166d6>:0)
UnityEngine.AndroidJavaObject.CallStatic (System.String methodName, System.Object[] args) (at <dcb3aea45c9345de8667cb9cbdf166d6>:0)
YandexMetricaPushAndroid.Initialize () (at <12300fb6f16248a59995018ab85cdc84>:0)
AppMetricaPush.Start () (at <12300fb6f16248a59995018ab85cdc84>:0)

	at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
	at com.unity3d.player.UnityPlayer.access$300()
	at com.unity3d.player.UnityPlayer$e$1.handleMessage()
	at android.os.Handler.dispatchMessage(Handler.java:98)
	at android.os.Looper.loop(Looper.java:163)
	at com.unity3d.player.UnityPlayer$e.run()

Any ideas how to fix it?

@NesterovichAlexey
Copy link
Contributor

Hi!
Use ymp_firebase_app_id instead of ymp_firebase_default_app_id and ymp_gcm_sender_id instead of ymp_gcm_default_sender_id in AndroidManifest.XML

@dekart
Copy link
Author

dekart commented Nov 29, 2019

Thanks. The error has changed to:

java.lang.Throwable: 
java.lang.IllegalArgumentException: Given String is empty or null
com.google.android.gms.common.internal.Preconditions.checkNotEmpty(Unknown Source)
com.google.firebase.auth.api.internal.zzej.<init>(com.google.firebase:firebase-auth@@19.0.0:2)
com.google.firebase.auth.FirebaseAuth.<init>(com.google.firebase:firebase-auth@@19.0.0:7)
com.google.firebase.auth.internal.zzl.<init>(com.google.firebase:firebase-auth@@19.0.0:1)
com.google.firebase.auth.zzt.create(com.google.firebase:firebase-auth@@19.0.0:3)
com.google.firebase.components.ComponentRuntime.lambda$new$0(com.google.firebase:firebase-common@@19.1.0:70)
com.google.firebase.components.ComponentRuntime$$Lambda$1.get(com.google.firebase:firebase-common@@19.1.0)
com.google.firebase.components.Lazy.get(com.google.firebase:firebase-common@@19.1.0:55)
com.google.firebase.components.ComponentRuntime.initializeEagerComponents(com.google.firebase:firebase-common@@19.1.0:159)
com.google.firebase.FirebaseApp.initializeAllApis(com.google.firebase:firebase-common@@19.1.0:559)
com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.1.0:302)
com.yandex.metrica.push.impl.ai.a(SourceFile:32)
com.yandex.metrica.push.impl.ag.a(SourceFile:48)
com.yandex.metrica.push.impl.b.a(SourceFile:83)
com.yandex.metrica.push.YandexMetricaPush.init(SourceFile:139)
com.unity3d.player.UnityPlayer.nativeRender(Native Method)
com.unity3d.player.UnityPlayer.access$300(Unknown Source)
com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source)
android.os.Handler.dispatchMessage(Handler.java:98)
android.os.Looper.loop(Looper.java:163)
com.unity3d.player.UnityPlayer$e.run(Unknown Source)
UnityEngine.AndroidJNISafe.CheckException () (at <dcb3aea45c9345de8667cb9cbdf166d6>:0)
UnityEngine.AndroidJNISafe.CallStaticVoidMethod (System.IntPtr clazz, System.IntPtr methodID, UnityEngine.jvalue[] args) (at <dcb3aea45c9345de8667cb9cbdf166d6>:0)
UnityEngine.AndroidJavaObject._CallStatic (System.String methodName, System.Object[] args) (at <dcb3aea45c9345de8667cb9cbdf166d6>:0)
UnityEngine.AndroidJavaObject.CallStatic (System.String methodName, System.Object[] args) (at <dcb3aea45c9345de8667cb9cbdf166d6>:0)
YandexMetricaPushAndroid.Initialize () (at <db2abaff69d948c58a7f49ca6d55a928>:0)
AppMetricaPush.Start () (at <db2abaff69d948c58a7f49ca6d55a928>:0)

	at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
	at com.unity3d.player.UnityPlayer.access$300()
	at com.unity3d.player.UnityPlayer$e$1.handleMessage()
	at android.os.Handler.dispatchMessage(Handler.java:98)
	at android.os.Looper.loop(Looper.java:163)
	at com.unity3d.player.UnityPlayer$e.run()

@NesterovichAlexey
Copy link
Contributor

Add in AndroidManifest:
<meta-data android:name="ymp_firebase_api_key" android:value="API_KEY"/>
API_KEY — App key in Firebase. You can find it in the current_key field of the google-services.json file. You can download the file in the Firebase console.

@dekart
Copy link
Author

dekart commented Nov 29, 2019

@NesterovichAlexey I've just checked it, the value is already there, but the error still appears.

@NesterovichAlexey
Copy link
Contributor

mata-data named ymp_firebase_api_key only works with AppMetrica Push SDK Android version 1.4.0.
But the Push Unity plugin uses version 1.1.0.
To upgrade to unity SDK version to 1.5.1 (now the latest) is a bit difficult.
I can help with that. What is the version of Unity and is there a file Assets/Plugins/Android/mainTemplate.Gradle?

@dekart
Copy link
Author

dekart commented Nov 29, 2019

  1. We use Unity 2019.3.0b9
  2. There's file mainTemplate.Gradle.DISABLED , and it's marked as "generated by unity"

@NesterovichAlexey
Copy link
Contributor

Cool! With this version, everything will be easier.
The file ends with DISABLED, so you used it before, but now you don't.
You will need to start using it again, you can remove DISABLED or select Custom Gradle Template in Unity.
image
And add to the dependencies block:

implementation ("com.yandex. android: mobmetricapushlib:1.5.1") {
    exclude group: "com.yandex. android", module: "mobmetricalib"
}
implementation " com.google.firebase:firebase-messaging:18.0.0"
implementation " com.google.android.gms: play-services-base:16.1.0"
implementation " com.android.support:support-v4:28.0.0"

When creating this file from scratch and adding these lines I succeeded:
mainTemplate.txt

Need to still from folders Assets/AppMetricaPush/Plugins/Android to remove all except appmetrica-push-plugin.aar

@dekart
Copy link
Author

dekart commented Nov 30, 2019

Moving whole project to manual gradle support seems to be a serious move that requires a lot of hassle. At least, it stopped build after the switch and I'm not sure that it's a good idea to keep digging this way.

Do you have any idea when the Unity plugin will start supporting the new version?

@dekart
Copy link
Author

dekart commented Dec 2, 2019

UPD: I've managed to build the app with custom gradle template, but now I receive this error message:

Caused by: java.lang.ClassNotFoundException: Didn't find class "android.app.NotificationChannel"

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

No branches or pull requests

2 participants