Quickstart-unity: AdMob SDK crashes Unity App on Android

Created on 12 Jan 2019  路  9Comments  路  Source: firebase/quickstart-unity

Hi,

I have simply added the Firebase SDK to my Unity project as explained by the Firebase tutorial. The app crashed immediately on start when I ran it on actual Android device. I was surprised that a simple integration like this failed so quickly just by adding initialization code to start().

I've read the whole thread at https://github.com/firebase/quickstart-unity/issues/229 but I couldn't figure out how to solve this issue. I've checked the adb logs and all I could see was the following line:
Activity pause timeout for ActivityRecord{1c23c2a2 u0 com.mycompany.mygame/com.google.firebase.MessagingUnityPlayerActivity t162 f}

Even though I've removed the Firebase initialization code from start(), the problem persisted. So, I've decided to remove Firebase from my assets folder. The app started to work normally.

My build settings are as follows:
Firebase Unity SDK: 5.4.3
Unity Version: 2018.3.0f2
Script Runtime Version: .NET 4.x Equivalent.
Script Backend: Mono
Api Compatibility Level: .Net 4.x
Minimum Api Level: Android 5.1 Level 22

P.S: I've also tried to force Android resolver, but this did not seem to be related to my problem at all since adb logs don't show anything related to dependency errors.

While I was writing this issue to Github, I've decided to give Firebase SDK one more chance. It really did not make sense to me why importing a package would crash my app. So I've tried it again and I can safely confirm that crashes.

I hope you can solve this issue and would love to help if you need anything from my side.
Best.

question

All 9 comments

Today, I have migrated my Unity game from my Mac to a new Windows computer because I thought a clean installation might make a difference. However, the game failed to start once again when I added the Firebase SDK. I have deployed to two different Android devices and it crashed on both.
I have also tested this with IL2CPP and it failed.

Hi @xtrecoolx

Thanks for bringing this issue to us. Based on your description, it sounds like some Android package or library is being included that is giving it a problem, though it's obviously a bit annoying that the adb logs don't have any info on it.

Which of the Firebase unitypackages are you importing when you see this? And have you been able to reproduce this behavior with a project that only includes the Firebase packages, like one of the quickstarts here? Sometimes there is some problem occurring between plugins.

Hi,

I am only adding the FirebaseAnalytics unity package to my project. My project contains AdmobUnity package and no other package.

Today, I have created a new blank project and added the FirebaseAnalytics package once again. There is no single line of code. I've deployed the app to my Android and the app ran without crashing. Then I've added the AdmobUnity package. And voila! It crashed. Okay so it is probably a resolver issue (conflicting libraries). This is very easy to reproduce since all you have to do is to create a blank project and add FirebaseAnalytics and Admob.

P.S: To help you further, I've decided to switch from .NET 4.0 to .NET 3.5 on this blank project. And the app crashed once again.

Please assist me since I have to ship my game soon and still need to integrate firebase to it.

I've solved the problem. This turns out to be an issue related to Admob, not Firebase. I forgot to add the tag to AndroidManifest.xml. After adding the meta-data app did not crash. It's funny that Admob worked without this just fine when there was no Firebase package.

Ah great. Yeah, Android development can be a bit tricky like that, it's possible that the AndroidManifest from Firebase was exposing some bug on the AdMob side. Thanks for letting us know what the issue was.

I've solved the problem. This turns out to be an issue related to Admob, not Firebase. I forgot to add the tag to AndroidManifest.xml. After adding the meta-data app did not crash. It's funny that Admob worked without this just fine when there was no Firebase package.
I am face the same issue can you help me which tag you added on which AndroidManifest.xml

@xtrecoolx What tag do you added and where?

I've solved the problem. This turns out to be an issue related to Admob, not Firebase. I forgot to add the tag to AndroidManifest.xml. After adding the meta-data app did not crash. It's funny that Admob worked without this just fine when there was no Firebase package.

Hi, the same question, what tag?

This one helped me:

\

Add this to AndroidManifest.xml in Plugins/Android folder, before tag and put your AppId for Android.

Was this page helpful?
0 / 5 - 0 ratings