firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
824 stars 428 forks source link

Unable to find /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation #136

Closed superbybot closed 6 years ago

superbybot commented 6 years ago

I'm trying to build the analytics sample using firebase SDK 4.4.2 and I get an error in the log with message:

"Unable to find /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation"

any ideas whats wrong with it? The only thing I've changed in the unity project is adding google-analytics in the AnalyticsDependencies.xml.

extra-google-m2repository Thanks in advance for the help! Regards, Byron
enghoff commented 6 years ago

@pronaypeddiraju actually the issue was present in 5.5.0 and was the reason for the reason for upgrade to 5.5.1, but the upgrade did not resolve the issue. I am still struggling to resolve this issue, if there are any logs or otherwise I can provide to help troubleshoot the issue, I'd be happy to provide this.

enghoff commented 6 years ago

Just adding a log of the failing Firebase initialisation -

07-05 00:48:59.824 27036-27062/? E/Unity: Unable to find /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
07-05 00:48:59.882 27036-27062/? I/firebase: Firebase App initializing app com.jmm.couplegame (default 1).
07-05 00:48:59.888 27036-27062/? I/Unity: Firebase App initializing app com.jmm.couplegame (default 1).

    (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
07-05 00:48:59.893 27036-27062/? W/System.err: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.jmm.couplegame. Make sure to call FirebaseApp.initializeApp(Context) first.
        at com.google.firebase.FirebaseApp.getInstance(SourceFile:218)
        at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
        at com.unity3d.player.UnityPlayer.c(Unknown Source)
        at com.unity3d.player.UnityPlayer$e$2.queueIdle(Unknown Source)
        at android.os.MessageQueue.next(MessageQueue.java:392)
        at android.os.Looper.loop(Looper.java:136)
        at com.unity3d.player.UnityPlayer$e.run(Unknown Source)
07-05 00:48:59.894 27036-27062/? E/firebase: new_app
07-05 00:48:59.894 27036-27062/? E/Unity: new_app

    (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
07-05 00:48:59.894 27036-27062/? E/firebase: Failed to initialize the default Firebase App.
07-05 00:48:59.967 27036-27062/? E/Unity: InitializationException:  Firebase app creation failed.
      at Firebase.FirebaseApp.CreateAndTrack (Firebase.CreateDelegate createDelegate, Firebase.FirebaseApp existingProxy) [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 CoupleGame.FirebaseController.Start () [0x00000] in <filename unknown>:0 

    (Filename:  Line: -1)
enghoff commented 6 years ago

Update: the root cause turned out to be a clash between Firebase and another 3rd-party plugin, which both registered a provider in the AndroidManifest with android:authorities defined as the bundle id. The 3rd-party plugin was assigned a different handle, which resolved the initialisation failure.

EvilNeru commented 6 years ago

We just barely started getting this on our project bring Android development to a halt. Host OS (OSX, Windows, Linux): Windows 10 Unity version: 2017.1.2p3 .NET version (3.5 or 4.6): to the following image Target platform: Android @enghoff Is there anymore insight that you can add to how you solved this and what plugin in particular it was?

enghoff commented 6 years ago

just changed the android:authorities definition for the 3rd party component to ensure the definition was unique and not clashing with Firebase

Crashthatch commented 6 years ago

+1 I am also seeing this issue.

Windows 10, Unity 2018.1.3f1, building using gradle (through Unity), app running on Android Samsung Galaxy S8, running my app (not the quickstart) after adding Firebase-Analytics 5.1.1.

Relevant part of adb logcat:

07-13 00:01:51.936 21000 21130 I chatty  : uid=10426(u0_a426) keypoint.lift identical 2 lines
07-13 00:01:52.040 21000 21130 I native  : distribute.cc:92 No keypoints to prune.
07-13 00:01:52.139 21000 21130 I native  : distribute.cc:92 No keypoints to prune.
07-13 00:01:52.163 21000 21019 E Unity   : Unable to find /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
07-13 00:01:52.184 21000 21019 W zygote  : Skipping duplicate class check due to unrecognized classloader
07-13 00:01:52.209 21000 21019 W zygote  : Skipping duplicate class check due to unrecognized classloader
07-13 00:01:52.218 21000 21019 I firebase: Firebase App initializing app com.arrowsd.horizonexplorer (default 1).
07-13 00:01:52.223 21000 21019 I Unity   : Firebase App initializing app com.arrowsd.horizonexplorer (default 1).
07-13 00:01:52.223 21000 21019 I Unity   :
07-13 00:01:52.223 21000 21019 I Unity   : (Filename: ./Runtime/Export/Debug.bindings.h Line: 43)
07-13 00:01:52.223 21000 21019 I Unity   :
07-13 00:01:52.238 21000 21130 I native  : distribute.cc:92 No keypoints to prune.
07-13 00:01:52.242 21000 21019 W System.err: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.arrowsd.horizonexplorer. Make sure to call FirebaseApp.initializeApp(Context) first.
07-13 00:01:52.245 21000 21019 W System.err:    at com.google.firebase.FirebaseApp.getInstance(Unknown Source:56)
07-13 00:01:52.245 21000 21019 W System.err:    at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
07-13 00:01:52.245 21000 21019 W System.err:    at com.unity3d.player.UnityPlayer.c(Unknown Source:0)
07-13 00:01:52.245 21000 21019 W System.err:    at com.unity3d.player.UnityPlayer$e$2.queueIdle(Unknown Source:72)
07-13 00:01:52.245 21000 21019 W System.err:    at android.os.MessageQueue.next(MessageQueue.java:394)
07-13 00:01:52.245 21000 21019 W System.err:    at android.os.Looper.loop(Looper.java:142)
07-13 00:01:52.245 21000 21019 W System.err:    at com.unity3d.player.UnityPlayer$e.run(Unknown Source:32)
07-13 00:01:52.245 21000 21019 E firebase: new_app
07-13 00:01:52.246 21000 21019 E Unity   : new_app
07-13 00:01:52.246 21000 21019 E Unity   :
07-13 00:01:52.246 21000 21019 E Unity   : (Filename: ./Runtime/Export/Debug.bindings.h Line: 43)
07-13 00:01:52.246 21000 21019 E Unity   :
07-13 00:01:52.246 21000 21019 E firebase: Failed to initialize the default Firebase App.
07-13 00:01:52.268 21000 21019 E Unity   : InitializationException:  Firebase app creation failed.
07-13 00:01:52.268 21000 21019 E Unity   :   at Firebase.FirebaseApp.CreateAndTrack (Firebase.CreateDelegate createDelegate, Firebase.FirebaseApp existingProxy) [0x00000] in <filename unknown>:0
07-13 00:01:52.268 21000 21019 E Unity   :   at Firebase.FirebaseApp.Create () [0x00000] in <filename unknown>:0
07-13 00:01:52.268 21000 21019 E Unity   :   at Firebase.FirebaseApp.get_DefaultInstance () [0x00000] in <filename unknown>:0
07-13 00:01:52.268 21000 21019 E Unity   :   at Firebase.Analytics.FirebaseAnalytics..cctor () [0x00000] in <filename unknown>:0
07-13 00:01:52.268 21000 21019 E Unity   : Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Firebase.Analytics.FirebaseAnalytics
07-13 00:01:52.268 21000 21019 E Unity   :   at CustomAnalytics.sendFirebaseCustomEvent (System.String eventName, IDictionary`2 parameters) [0x00000] in <filename unknown>:0
07-13 00:01:52.268 21000 21019 E Unity   :   at CustomAnalytics.Update () [0x00000] in <filename unknown>:0
07-13 00:01:52.268 21000 21019 E Unity   :
07-13 00:01:52.268 21000 21019 E Unity   : (Filename:  Line: -1)
07-13 00:01:52.268 21000 21019 E Unity   :

Other installed plugins:

find ./Assets -regex ".*\.[aj]ar"

./Assets/GoogleARCore/SDK/Plugins/arcore_client.aar
./Assets/GoogleARCore/SDK/Plugins/google_ar_optional.aar
./Assets/GoogleARCore/SDK/Plugins/google_ar_required.aar
./Assets/GoogleARCore/SDK/Plugins/unityandroidpermissions.aar
./Assets/GoogleARCore/SDK/Plugins/unitygar.aar
./Assets/Mapbox/Core/Plugins/Android/mapbox-android-core-0.2.0.aar
./Assets/Mapbox/Core/Plugins/Android/mapbox-android-telemetry-3-1-4.aar
./Assets/Mapbox/Core/Plugins/Android/okhttp-3.8.0.jar
./Assets/Mapbox/Core/Plugins/Android/okio-1.13.0.jar
./Assets/Mapbox/Core/Plugins/Android/UniAndroidPermission/UniAndroidPermission_v1_2.jar
./Assets/Plugins/Android/android.arch.core.common-1.1.1.jar
./Assets/Plugins/Android/android.arch.core.runtime-1.1.1.aar
./Assets/Plugins/Android/android.arch.lifecycle.common-1.1.1.jar
./Assets/Plugins/Android/android.arch.lifecycle.extensions-1.1.1.aar
./Assets/Plugins/Android/android.arch.lifecycle.livedata-1.1.1.aar
./Assets/Plugins/Android/android.arch.lifecycle.livedata-core-1.1.1.aar
./Assets/Plugins/Android/android.arch.lifecycle.runtime-1.1.1.aar
./Assets/Plugins/Android/android.arch.lifecycle.viewmodel-1.1.1.aar
./Assets/Plugins/Android/ARCorePixelFix.jar
./Assets/Plugins/Android/com.android.support.animated-vector-drawable-26.1.0.aar
./Assets/Plugins/Android/com.android.support.appcompat-v7-26.1.0.aar
./Assets/Plugins/Android/com.android.support.support-annotations-26.1.0.jar
./Assets/Plugins/Android/com.android.support.support-compat-26.1.0.aar
./Assets/Plugins/Android/com.android.support.support-core-ui-26.1.0.aar
./Assets/Plugins/Android/com.android.support.support-core-utils-26.1.0.aar
./Assets/Plugins/Android/com.android.support.support-fragment-26.1.0.aar
./Assets/Plugins/Android/com.android.support.support-media-compat-26.1.0.aar
./Assets/Plugins/Android/com.android.support.support-v4-26.1.0.aar
./Assets/Plugins/Android/com.android.support.support-vector-drawable-26.1.0.aar
./Assets/Plugins/Android/com.google.android.gms.play-services-ads-identifier-15.0.1.aar
./Assets/Plugins/Android/com.google.android.gms.play-services-base-15.0.1.aar
./Assets/Plugins/Android/com.google.android.gms.play-services-basement-15.0.1.aar
./Assets/Plugins/Android/com.google.android.gms.play-services-measurement-base-16.0.0.aar
./Assets/Plugins/Android/com.google.android.gms.play-services-stats-15.0.1.aar
./Assets/Plugins/Android/com.google.android.gms.play-services-tasks-15.0.1.aar
./Assets/Plugins/Android/com.google.code.gson.gson-2.8.2.jar
./Assets/Plugins/Android/com.google.firebase.firebase-analytics-16.0.1.aar
./Assets/Plugins/Android/com.google.firebase.firebase-analytics-impl-16.1.1.aar
./Assets/Plugins/Android/com.google.firebase.firebase-analytics-unity-5.1.1.aar
./Assets/Plugins/Android/com.google.firebase.firebase-app-unity-5.1.1.aar
./Assets/Plugins/Android/com.google.firebase.firebase-common-16.0.0.aar
./Assets/Plugins/Android/com.google.firebase.firebase-core-16.0.1.aar
./Assets/Plugins/Android/com.google.firebase.firebase-iid-16.2.0.aar
./Assets/Plugins/Android/com.google.firebase.firebase-iid-interop-16.0.0.aar
./Assets/Plugins/Android/com.google.firebase.firebase-measurement-connector-17.0.0.aar
./Assets/Plugins/Android/com.google.firebase.firebase-measurement-connector-impl-16.0.1.aar

The Failed to initialize the default Firebase App. / InitializationException: Firebase app creation failed. message repeats every time I try to log a custom event.

Also happens with firebase analytics 4.5.2.

I tried upgrading my Android SDK, but it did not help.

Ran the same apk on a Pixel device through Firebase Test Lab, and I see the same thing. Full trace: https://gist.github.com/Crashthatch/2dd569ce435ab0648aa1fc022cc6e206

When I remove firebase from my project, the CoreFoundation message goes away.

I'm out of things to try. I have no idea why Firebase on Android would be looking for an iOS CoreFoundation package. Without access to the firebase source the ball's pretty much in your court...

stewartmiles commented 6 years ago

@Crashthatch have you reproduced this with one of our sample applications?

If you reproduce it with a sample and share it via our support channel we can take a look at what's going on.

Crashthatch commented 6 years ago

I tried to reproduce this with the sample application, and I do get the Unable to find /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation error appearing in logcat, but it seems to function and I am able to send events etc. to Firebase without any problems, leading me to believe it's a red-herring.

If you want to reproduce anyway (to try to remove this confusing error message to avoid future confusion?), you can use this fork: https://github.com/Crashthatch/quickstart-unity (see commit log to see the exact steps I followed). Open and build & run in Unity 2018.1.3f1 (or use built apk in the git repo). Run adb logcat | grep CoreFoundation after running the app on a phone (I used my Samsung Galaxy S8) to see the "error" message. Commit https://github.com/Crashthatch/quickstart-unity/commit/cadfe18a3094a4c0e71a991ecb05d011d7321aa5 (before google-services.json was added or I made any code modifications) also shows the message, before complaining about not being able to find google-services.json / App ID.

The actual problem in my app (stack traces from a few lines below in the logcat above), Default FirebaseApp is not initialized in this process & Failed to initialize the default Firebase App actually seem to happen when I add a dependency on android.arch.lifecycle:extensions:1.1.1 (adding other dependencies is fine). I'll open a separate issue for that.

enghoff commented 6 years ago

Just fyi, I also still see the Unable to find /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation error after the core initialisation issue was resolved; this does not appear to be a critical error

stewartmiles commented 6 years ago

@enghoff & @Crashthatch the CoreFoundation error message is actually intentional. We detect whether we need to apply a workaround for a Unity networking bug on OSX by searching for the presence of this non-existent framework. The error pops up as the pinvoke we use fails, we catch the exception and apply the workaround if it's required. The only reason this code is still in our code base is due to our use of Unity's .NET networking stack in the real-time database, so we've removed the code path in upcoming mobile builds. Once we've finished migration of the RT DB to our native desktop implementation this code will disappear entirely.

Crashthatch commented 6 years ago

Great! Perhaps make it an INFO, or change it to something that looks less like an error (CoreFoundation not found, no need for workaround) or log another message afterwards saying it's benign, if it's going to be a long time before that happens? Although maybe this thread will pop up when future people search and they won't waste as much time as I did.

If the change is imminent, then no need. :)

stewartmiles commented 6 years ago

@Crashthatch the error is thrown by the mono framework so we can't change the log level unfortunately.

mykidocoder commented 6 years ago

Please mention that it's important to KEEP ALL THE IMPORTED FOLDERS UNTOUCHED, by moving any of them will fail in endless ways.. so hardcoded..