Upgrading firebase unity sdk from 1.1.0 to 5.4.4

4,311 views
Skip to first unread message

Sanket Kale

unread,
Jan 26, 2019, 3:01:34 PM1/26/19
to Firebase Google Group
Hello,

I recently upgraded firebase unity SDK in my unity project (had version 1.1.0 earlier... Yes I know, once I got it working, I just didn't want to touch it, so...). Nevermind, now the project is in production since nearly 2 years in both Android and iOS. But after this time while I was working on optimizing code of sending and receiving notifications, I felt like let's start with upgrading the firebase unity SDK version first. Now when I saw the latest version it was 5.4.3 (back in Dec 2018), and I said to myself, Shit! I quickly backed up the project and with shivering hands, I started upgrading the SDK. 

I followed below steps to upgrade the firebase unity SDK to version 5.4.3:

1) Backup project
2) Delete all firebase related folders
3) Delete all firebase related .aar and .jar files from Assets > Plugins > Android folder
4) Delete all firebase related .a files from Assets > Plugins > iOS folder
5) Delete files google-services.xml and GoogleService-Info.plist
6) Download latest firebase unity SDK
7) Import from dotnet 3.x > Analytics, DynamicLinks, and Messaging one by one
8) Download latest google-services.xml and GoogleService-Info.plist from firebase console and import in project
9) Run Play services resolver > Version Handler > Update
10) Run Play services resolver > Android Resolver > Force Resolve (in an android project on windows)
11) Run Play services resolver > iOS Resolver > Install Cocapods (in iOS project on mac)
12) Build and run

Now since more than a month, I am entangled in build and runtime issues after following the above steps. I am not able to build my iOS project, and I am not able to run my android project. Adding to the nightmare, I have google sign-in plugin too, and it shares the Play game services with firebase, after the war with firebase related issues, the next one is waiting just over the hill.

Anyways, below is the error that I got while running the unity android project: 

E/Unity: DllNotFoundException: FirebaseCppApp-5.4.3
      at (wrapper managed-to-native) Firebase.DynamicLinks.FirebaseDynamicLinksPINVOKE/SWIGExceptionHelper:SWIGRegisterExceptionCallbacks_FirebaseDynamicLinks (Firebase.DynamicLinks.FirebaseDynamicLinksPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.DynamicLinks.FirebaseDynamicLinksPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.DynamicLinks.FirebaseDynamicLinksPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.DynamicLinks.FirebaseDynamicLinksPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.DynamicLinks.FirebaseDynamicLinksPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.DynamicLinks.FirebaseDynamicLinksPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.DynamicLinks.FirebaseDynamicLinksPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.DynamicLinks.FirebaseDynamicLinksPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.DynamicLinks.FirebaseDynamicLinksPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.DynamicLinks.FirebaseDy
  
2019-01-26 17:04:20.218 9585-9646/? E/Unity: DllNotFoundException: FirebaseCppApp-5.4.3
      at (wrapper managed-to-native) Firebase.Messaging.FirebaseMessagingPINVOKE/SWIGExceptionHelper:SWIGRegisterExceptionCallbacks_FirebaseMessaging (Firebase.Messaging.FirebaseMessagingPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.Messaging.FirebaseMessagingPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.Messaging.FirebaseMessagingPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.Messaging.FirebaseMessagingPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.Messaging.FirebaseMessagingPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.Messaging.FirebaseMessagingPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.Messaging.FirebaseMessagingPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.Messaging.FirebaseMessagingPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.Messaging.FirebaseMessagingPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.Messaging.FirebaseMessagingPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.Mess

-------------------------------------------------------------------------------------

Now I even tried skipping steps 2, 3, 4 and 5 and tested it, but got same errors. For android I am using custom mainTemplate.gradle and custom AndroidManifest.xml in the Assets > Plugins > Android project. I had added it for firebase only following steps mentioned in an earlier version of the link here -> https://firebase.google.com/docs/unity/setup 

Now In a moment of epiphany, I just thought about deleting my custom AndroidManifest.xml and mainTemplate.gradle from Assets > Plugins > Android folder and to my joy it started working. Now initially the AndroidManifest.xml and the custom mainTemplate.gradle was set up for firebase only but now I guess these files are not required. Anyways, the Android build of the app is working fine now. I only got it working after deleting the files.

Now following the same steps in my unity project's iOS build, I am still stuck at a compile-time issue since nearly a month. Building the project for iOS throws following error at the end:

iOS framework addition failed due to a CocoaPods installation failure. This will will likely result in a non-functional Xcode project.

After the failure, "pod repo update" was executed and succeeded. "pod install" was then attempted again, and still failed. This may be due to a broken CocoaPods installation. See: https://guides.cocoapods.org/using/troubleshooting.html for potential solutions.

pod install output:

Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "GoogleAppMeasurement":
  In Podfile:
    Firebase/Analytics (= 5.15.0) was resolved to 5.15.0, which depends on
      Firebase/Core (= 5.15.0) was resolved to 5.15.0, which depends on
        FirebaseAnalytics (= 5.4.0) was resolved to 5.4.0, which depends on
          GoogleAppMeasurement (= 5.4.0)

    GoogleAppMeasurement (= 5.3.0)

CocoaPods could not find compatible versions for pod "GoogleUtilities/MethodSwizzler":
  In Podfile:
    GoogleAppMeasurement (= 5.3.0) was resolved to 5.3.0, which depends on
      GoogleUtilities/MethodSwizzler (~> 5.2)

    GoogleUtilities/MethodSwizzler (= 5.3.0)

pod repo update output:

Updating spec repo `master`
  $ /usr/bin/git -C /Users/tdpl/.cocoapods/repos/master fetch origin --progress
  $ /usr/bin/git -C /Users/tdpl/.cocoapods/repos/master rev-parse --abbrev-ref HEAD
  master
  $ /usr/bin/git -C /Users/tdpl/.cocoapods/repos/master reset --hard origin/master
  HEAD is now at ac596d9f610 [Add] FitDataProtocol 0.31.0

CocoaPods 1.6.0.rc.1 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.

-------------------------------------------------------------------------------------

I have tried updating the firebase unity SDK to 5.4.4, and again I am able to build and run the Android project but I am getting the same build time issues in the iOS project. My project settings have not changed, nor has the code (I mean before and after the firebase upgrade). Right now both the Android and iOS projects are using unity version 2018.2.14f1 and firebase unity SDK 5.4.4.

Questions:
1) Are my steps of upgrading the firebase unity SDK valid? If there is a better and safer way of doing it, please let me know.
2) Am I looking at any trouble if I delete the custom AndroidManifest.xml from Assets > Plugins > Android created as soon as I import the firebase unity SDK?
3) How to solve the build time issue mentioned above? I have tried changing the minimum target version to 11.0, but could not solve it.

Firebase community, please help! Thanks in advance.

Regards,
Sanket Kale.

Jon Simantov

unread,
Jan 29, 2019, 4:08:44 PM1/29/19
to Firebase Google Group
Hi,

It looks like your steps of updating the SDK are valid. The issue you are seeing on iOS with GoogleAppMeasurement *should* no longer be there in 5.4.4, as we no longer have a hard version requirement for the GoogleAppMeasurement Cocoapod. When you updated from 5.4.3 to 5.4.4 did you also clear out all of the old files?

Let's make sure your configuration is valid. Could you please try downloading the quickstart project from https://github.com/firebase/quickstart-unity, install Firebase Unity 5.4.4 in it, and let me know if that works on iOS?

Also, you can try updating your Cocoapods version (although not to one of the --pre versions). Try just "sudo gem install cocoapods" to make sure you have the current version (for example I am using 1.5.3).

I'll look into the AndroidManifest question and get back to you.

Thanks,

Jon

Jon Simantov

unread,
Jan 29, 2019, 4:36:22 PM1/29/19
to Firebase Google Group
Following up about the manifest. If you are using Firebase Messaging and have a custom AndroidManifest, you'll need to follow the instructions here to ensure that Messaging is initialized properly: https://firebase.google.com/docs/cloud-messaging/unity/client#initialize

As long as you add that to your own manifest, you don't need to use the one we provide.

Jon

Sanket Kale

unread,
Jan 31, 2019, 10:19:00 AM1/31/19
to Firebase Google Group
Hi Jon,

Thanks for validating my steps for updating the SDK. Now yes, I had deleted all the files related to firebase before adding the latest version. But I am using a separate asset for letting my app users sign in or sign up using google email id via Google Login iOS & Android from Locomotive. Now my project is more than 2 years old and I have been using this asset with Firebase 1.1 since late 2016. 

From observation, I was also able to integrate Firebase 4.3 with the latest version of the Google login asset. But since 5.4.3, I have started to face build time issues. Now I have checked with the Firebase backend team and they have verified this compatibility issue and have suggested me to try Firebase Authentication instead of a separate asset.

I guess, the GoogleAppMeasurement dependancy is being referenced by the Google login asset and causing the compatibility issue. Again, I am not sure, I have provided a demo project with both the assets integrated to the firebase support team and I am waiting for an official reason from them.

P.S. - I have tried to the quickstart example and I am able to build it without any issues. I have tried updating the pods quite a number of times along with 'sudo gem install cocoapods' and still had the same issue.

Once I have anything concrete, I will share it here in this thread.

Regards,
Sanket Kale.

Sanket Kale

unread,
Jan 31, 2019, 10:21:30 AM1/31/19
to Firebase Google Group
Hi Jon,

Thanks for getting back.
I had an AndroidManifest file prior to upgrading to Firebase 5.4.3. It was added for the changes mentioned at the same link you provided just to ensure instead of UnityPlayerActivity, MessagingUnityPlayerActivity is initialized. Now we did not have any custom entry point to override UnityPlayerActivity, but back in version 1.1, it said it was mandatory to keep a custom AndroidManifest as a part of the setup.

Now as we are not having any other custom entry point, it seems it is not mandatory to put a custom manifest according to this line 'If you are not using a custom entry point this replacement happens automatically and you should not have to take any additional action.'

Anyways, Thanks for the confirming it.

Regards,
Sanket Kale.

Sanket Kale

unread,
Feb 17, 2019, 8:53:38 PM2/17/19
to Firebase Google Group
Ok, now to answer my own questions:

1) Are my steps of upgrading the firebase unity SDK valid? If there is a better and safer way of doing it, please let me know.
The steps I followed are just fine, one just needs to be careful while resolving google dependencies if your project includes other assets apart from firebase which use them. 

2) Am I looking at any trouble if I delete the custom AndroidManifest.xml from Assets > Plugins > Android created as soon as I import the firebase unity SDK?
Firebase needs the manifest as mentioned in the firebase docs. I was unable to build with the manifest as I had edited the file and added android:name="android.support.multidex.MultiDexApplication" android:hardwareAccelerated="true", which was probably causing the crash. It was not present in the default manifest imported with firebase SDK but was present in earlier version of my project with firebase SDK 1.1 and hence I added it in the newly imported manifest too. But with the latest version, it's not needed.

3) How to solve the build time issue mentioned above? I have tried changing the minimum target version to 11.0, but could not solve it.
The build time issue was due to conflicting dependencies between firebase and a google login asset from Locomotive I was using in my project. Just FYI, the Google login asset is this. The latest firebase unity SDK used the latest version of all the pods but the google login asset used Google/SignIn which used older versions of other Google dependencies, as correctly mentioned the build error itself. Google/SignIn is deprecated if you go and check on the cocoapods site. 

Now after days of debugging, I finally managed to solve this by just changing Google/SignIn pod to GoogleSignIn (without the forward slash) in an editor script that added the dependencies for the asset at the build time and voila, everything started to work.

So, on an ending note, if anybody is using firebase with other assets which are using Google dependencies, be careful with the versions. Mostly the developer which provides an asset with google dependencies provides a way to let play service resolver learn about its requirement and resolve the required dependencies for them. For some brief pointers, there are XML files available in firebase folder with name '*Dependencies.xml' which specifies which dependencies it needs. For my google login asset, there was an editor script which added pods and required android dependencies along with suitable versions. According to your requirement and the asset version, you might have to tweak the versions to resolve the dependencies yourself, as I did.

Hope this helps.

Regards,
Sanket Kale.
Reply all
Reply to author
Forward
0 new messages