Firebase Cloud Messaging not working Unity 3D

1,664 views
Skip to first unread message

Carl Spooner

unread,
Nov 18, 2016, 12:26:15 PM11/18/16
to Firebase Google Group
I get this error when launching my app and initializing the Cloud messaging

ArgumentOutOfRangeException: Cannot be negative.
Parameter name: length
  at System.String.Substring (Int32 startIndex, Int32 length) [0x00000] in <filename unknown>:0
  at Firebase.FirebaseApp.CreateAndTrack (Firebase.CreateDelegate createDelegate) [0x00000] in <filename unknown>:0
  at Firebase.FirebaseApp.Create () [0x00000] in <filename unknown>:0
  at Firebase.FirebaseApp.get_DefaultInstance () [0x00000] in <filename unknown>:0
  at Firebase.Messaging.FirebaseMessaging+Listener..ctor () [0x00000] in <filename unknown>:0
  at Firebase.Messaging.FirebaseMessaging+Listener.Create () [0x00000] in <filename unknown>:0
  at Firebase.Messaging.FirebaseMessaging..cctor () [0x00000] in <filename unknown>:0
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Firebase.Messaging.FirebaseMessaging
  at fireBaseNotifications.Start () [0x00000] in <filename unknown>:0

Using Unity 5.4.1f1 and the latest Firebase Unity packages

Stewart Miles

unread,
Nov 18, 2016, 12:37:58 PM11/18/16
to fireba...@googlegroups.com
Neat, looks like you've found a bug in some code that throws an exception upon app initialization.  I'll file a bug in our internal tracker to get this fixed so that when an initialization error like this occurs at least we'll be able to see the error message being raised.

My first guess at this would be that you're missing the google-services.json config file in your application (see https://firebase.google.com/docs/unity/setup#add_firebase_to_your_app_1)

Are you able to reproduce the problem with the messaging sample?

Cheers,
Stewart



--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/e9dfd25f-d015-4ee4-9e6b-2962934365a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Carl Spooner

unread,
Nov 18, 2016, 2:19:24 PM11/18/16
to Firebase Google Group
Yes the .json is even in the root asset folder. Will try the testapp and see if it works...


On Friday, November 18, 2016 at 12:37:58 PM UTC-5, Stewart Miles wrote:
Neat, looks like you've found a bug in some code that throws an exception upon app initialization.  I'll file a bug in our internal tracker to get this fixed so that when an initialization error like this occurs at least we'll be able to see the error message being raised.

My first guess at this would be that you're missing the google-services.json config file in your application (see https://firebase.google.com/docs/unity/setup#add_firebase_to_your_app_1)

Are you able to reproduce the problem with the messaging sample?

Cheers,
Stewart


On Fri, Nov 18, 2016 at 8:33 AM, Carl Spooner <carl.spo...@gmail.com> wrote:
I get this error when launching my app and initializing the Cloud messaging

ArgumentOutOfRangeException: Cannot be negative.
Parameter name: length
  at System.String.Substring (Int32 startIndex, Int32 length) [0x00000] in <filename unknown>:0
  at Firebase.FirebaseApp.CreateAndTrack (Firebase.CreateDelegate createDelegate) [0x00000] in <filename unknown>:0
  at Firebase.FirebaseApp.Create () [0x00000] in <filename unknown>:0
  at Firebase.FirebaseApp.get_DefaultInstance () [0x00000] in <filename unknown>:0
  at Firebase.Messaging.FirebaseMessaging+Listener..ctor () [0x00000] in <filename unknown>:0
  at Firebase.Messaging.FirebaseMessaging+Listener.Create () [0x00000] in <filename unknown>:0
  at Firebase.Messaging.FirebaseMessaging..cctor () [0x00000] in <filename unknown>:0
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Firebase.Messaging.FirebaseMessaging
  at fireBaseNotifications.Start () [0x00000] in <filename unknown>:0

Using Unity 5.4.1f1 and the latest Firebase Unity packages

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

Carl Spooner

unread,
Nov 18, 2016, 2:19:24 PM11/18/16
to Firebase Google Group
So here's the error with the testapp for messaging


11-18 13:37:25.231  7625  7653 I Unity   : firebase::App initializing app se.unity.messaging.testappmessaging.testapp (default 1).
11-18 13:37:25.231  7625  7653 I Unity   :
11-18 13:37:25.231  7625  7653 I Unity   : (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
11-18 13:37:25.231  7625  7653 I Unity   :
11-18 13:37:25.231  7625  7653 E Unity   : strlen(app_options->app_id()) && strlen(app_options->api_key())
11-18 13:37:25.231  7625  7653 E Unity   :
11-18 13:37:25.231  7625  7653 E Unity   : (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
11-18 13:37:25.231  7625  7653 E Unity   :
11-18 13:37:25.241  7625  7653 E Unity   : java_app
11-18 13:37:25.241  7625  7653 E Unity   :
11-18 13:37:25.241  7625  7653 E Unity   : (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
11-18 13:37:25.241  7625  7653 E Unity   :
11-18 13:37:25.261  7625  7653 I Unity   : Firebase Cloud Messaging API Initialized
11-18 13:37:25.261  7625  7653 I Unity   :
11-18 13:37:25.261  7625  7653 I Unity   : (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
11-18 13:37:25.261  7625  7653 I Unity   :
11-18 13:37:25.331  7625  7653 I Unity   : ArgumentOutOfRangeException: Cannot be negative.
11-18 13:37:25.331  7625  7653 I Unity   : Parameter name: length
11-18 13:37:25.331  7625  7653 I Unity   :   at System.String.Substring (Int32 startIndex, Int32 length) [0x00000] in <filename unknown>:0
11-18 13:37:25.331  7625  7653 I Unity   :   at Firebase.FirebaseApp.CreateAndTrack (Firebase.CreateDelegate createDelegate) [0x00000] in <filename unknown>:0
11-18 13:37:25.331  7625  7653 I Unity   :   at Firebase.FirebaseApp.Create () [0x00000] in <filename unknown>:0
11-18 13:37:25.331  7625  7653 I Unity   :   at Firebase.FirebaseApp.get_DefaultInstance () [0x00000] in <filename unknown>:0
11-18 13:37:25.331  7625  7653 I Unity   :   at Firebase.FirebaseApp.CheckDependencies () [0x00000] in <filename unknown>:0
11-18 13:37:25.331  7625  7653 I Unity   :   at UIHandler.Start () [0x00000] in <filename unknown>:0
11-18 13:37:25.331  7625  7653 I Unity   :
11-18 13:37:25.331  7625  7653 I Unity   : (Filename:  Line: -1)

On Friday, November 18, 2016 at 12:37:58 PM UTC-5, Stewart Miles wrote:
Neat, looks like you've found a bug in some code that throws an exception upon app initialization.  I'll file a bug in our internal tracker to get this fixed so that when an initialization error like this occurs at least we'll be able to see the error message being raised.

My first guess at this would be that you're missing the google-services.json config file in your application (see https://firebase.google.com/docs/unity/setup#add_firebase_to_your_app_1)

Are you able to reproduce the problem with the messaging sample?

Cheers,
Stewart


On Fri, Nov 18, 2016 at 8:33 AM, Carl Spooner <carl.spo...@gmail.com> wrote:
I get this error when launching my app and initializing the Cloud messaging

ArgumentOutOfRangeException: Cannot be negative.
Parameter name: length
  at System.String.Substring (Int32 startIndex, Int32 length) [0x00000] in <filename unknown>:0
  at Firebase.FirebaseApp.CreateAndTrack (Firebase.CreateDelegate createDelegate) [0x00000] in <filename unknown>:0
  at Firebase.FirebaseApp.Create () [0x00000] in <filename unknown>:0
  at Firebase.FirebaseApp.get_DefaultInstance () [0x00000] in <filename unknown>:0
  at Firebase.Messaging.FirebaseMessaging+Listener..ctor () [0x00000] in <filename unknown>:0
  at Firebase.Messaging.FirebaseMessaging+Listener.Create () [0x00000] in <filename unknown>:0
  at Firebase.Messaging.FirebaseMessaging..cctor () [0x00000] in <filename unknown>:0
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Firebase.Messaging.FirebaseMessaging
  at fireBaseNotifications.Start () [0x00000] in <filename unknown>:0

Using Unity 5.4.1f1 and the latest Firebase Unity packages

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

Carl Spooner

unread,
Nov 18, 2016, 2:19:24 PM11/18/16
to Firebase Google Group
In the GUI I get this too

one or more firebase dependencies are not present
Current dependency status: UnavailableOther



On Friday, November 18, 2016 at 12:37:58 PM UTC-5, Stewart Miles wrote:
Neat, looks like you've found a bug in some code that throws an exception upon app initialization.  I'll file a bug in our internal tracker to get this fixed so that when an initialization error like this occurs at least we'll be able to see the error message being raised.

My first guess at this would be that you're missing the google-services.json config file in your application (see https://firebase.google.com/docs/unity/setup#add_firebase_to_your_app_1)

Are you able to reproduce the problem with the messaging sample?

Cheers,
Stewart


On Fri, Nov 18, 2016 at 8:33 AM, Carl Spooner <carl.spo...@gmail.com> wrote:
I get this error when launching my app and initializing the Cloud messaging

ArgumentOutOfRangeException: Cannot be negative.
Parameter name: length
  at System.String.Substring (Int32 startIndex, Int32 length) [0x00000] in <filename unknown>:0
  at Firebase.FirebaseApp.CreateAndTrack (Firebase.CreateDelegate createDelegate) [0x00000] in <filename unknown>:0
  at Firebase.FirebaseApp.Create () [0x00000] in <filename unknown>:0
  at Firebase.FirebaseApp.get_DefaultInstance () [0x00000] in <filename unknown>:0
  at Firebase.Messaging.FirebaseMessaging+Listener..ctor () [0x00000] in <filename unknown>:0
  at Firebase.Messaging.FirebaseMessaging+Listener.Create () [0x00000] in <filename unknown>:0
  at Firebase.Messaging.FirebaseMessaging..cctor () [0x00000] in <filename unknown>:0
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Firebase.Messaging.FirebaseMessaging
  at fireBaseNotifications.Start () [0x00000] in <filename unknown>:0

Using Unity 5.4.1f1 and the latest Firebase Unity packages

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

Stewart Miles

unread,
Nov 18, 2016, 2:31:43 PM11/18/16
to fireba...@googlegroups.com
This is definitely a result of the Android resources not being included in the application.  If the following file does not exist:

Assets/Plugins/Android/Firebase/res/values/google-services.xml

The application configuration hasn't been generated by google-services.json.

Check your error log, I'm guessing that if you're building on Windows you're running into the same issue as 
and

Is this what you're running into?

Cheers,
Stewart

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Bilel Mnasser

unread,
Jan 26, 2017, 1:16:27 PM1/26/17
to Firebase Google Group

In one word : 

Luka Maške

unread,
Feb 22, 2017, 10:41:04 AM2/22/17
to Firebase Google Group
I had similar issue when I installed Firebase 1.1.2, and when Stripping level was not disabled I got this crash, but that wasn't the case in one of the previous versions I had before. So I guess that's a bug?

02-22 16:02:37.691: I/Unity(3576): NullReferenceException: Object reference not set to an instance of an object
02-22 16:02:37.691: I/Unity(3576):   at Firebase.Internal.InstallRootCerts.InstallDefaultCRLs (System.String resource_name, System.String directory) [0x00000] in <filename unknown>:0 
02-22 16:02:37.691: I/Unity(3576):   at Firebase.Internal.InstallRootCerts.Process (Firebase.FirebaseApp app) [0x00000] in <filename unknown>:0 
02-22 16:02:37.691: I/Unity(3576):   at Firebase.FirebaseApp.CreateAndTrack (Firebase.CreateDelegate createDelegate) [0x00000] in <filename unknown>:0 
02-22 16:02:37.691: I/Unity(3576):   at Firebase.FirebaseApp.Create () [0x00000] in <filename unknown>:0 
02-22 16:02:37.691: I/Unity(3576):   at Firebase.FirebaseApp.get_DefaultInstance () [0x00000] in <filename unknown>:0 
02-22 16:02:37.691: I/Unity(3576):   at Firebase.Analytics.FirebaseAnalytics..cctor () [0x00000] in <filename unknown>:0 
02-22 16:02:37.691: I/Unity(3576): Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Firebase.Analytics.FirebaseAnalytics
02-22 16:02:37.691: I/Unity(3576):   at Titan.Managers.GameManager.Awake () [0x00000] in <filename unknown>:0 



On Thursday, 26 January 2017 19:16:27 UTC+1, Bilel Mnasser wrote:

In one word : 

Stewart Miles

unread,
Feb 22, 2017, 12:24:57 PM2/22/17
to fireba...@googlegroups.com
Yep, this is a stripping issue.  We have a fix internally, keep an eye on our release page for updates.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.

Luka Maške

unread,
Feb 22, 2017, 12:56:43 PM2/22/17
to Firebase Google Group
Thanks Stewart for the confirmation! I'll wait for the update :)


On Wednesday, 22 February 2017 18:24:57 UTC+1, Stewart Miles wrote:
Yep, this is a stripping issue.  We have a fix internally, keep an eye on our release page for updates.
On Wed, Feb 22, 2017 at 7:05 AM, Luka Maške <luka....@gmail.com> wrote:
I had similar issue when I installed Firebase 1.1.2, and when Stripping level was not disabled I got this crash, but that wasn't the case in one of the previous versions I had before. So I guess that's a bug?

02-22 16:02:37.691: I/Unity(3576): NullReferenceException: Object reference not set to an instance of an object
02-22 16:02:37.691: I/Unity(3576):   at Firebase.Internal.InstallRootCerts.InstallDefaultCRLs (System.String resource_name, System.String directory) [0x00000] in <filename unknown>:0 
02-22 16:02:37.691: I/Unity(3576):   at Firebase.Internal.InstallRootCerts.Process (Firebase.FirebaseApp app) [0x00000] in <filename unknown>:0 
02-22 16:02:37.691: I/Unity(3576):   at Firebase.FirebaseApp.CreateAndTrack (Firebase.CreateDelegate createDelegate) [0x00000] in <filename unknown>:0 
02-22 16:02:37.691: I/Unity(3576):   at Firebase.FirebaseApp.Create () [0x00000] in <filename unknown>:0 
02-22 16:02:37.691: I/Unity(3576):   at Firebase.FirebaseApp.get_DefaultInstance () [0x00000] in <filename unknown>:0 
02-22 16:02:37.691: I/Unity(3576):   at Firebase.Analytics.FirebaseAnalytics..cctor () [0x00000] in <filename unknown>:0 
02-22 16:02:37.691: I/Unity(3576): Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Firebase.Analytics.FirebaseAnalytics
02-22 16:02:37.691: I/Unity(3576):   at Titan.Managers.GameManager.Awake () [0x00000] in <filename unknown>:0 



On Thursday, 26 January 2017 19:16:27 UTC+1, Bilel Mnasser wrote:

In one word : 

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Jeremy Glazman

unread,
Feb 23, 2017, 9:43:15 AM2/23/17
to Firebase Google Group
We are experiencing this same issue.  I'm trying workarounds for now so we can update our app on the Play store.  Looking forward to the update.
Reply all
Reply to author
Forward
0 new messages