Skip to content

[Bug] Unity 6 - Firebase Messaging Theme.AppCompat - Crash #1229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
firesightstudios opened this issue Apr 11, 2025 · 6 comments
Open

[Bug] Unity 6 - Firebase Messaging Theme.AppCompat - Crash #1229

firesightstudios opened this issue Apr 11, 2025 · 6 comments

Comments

@firesightstudios
Copy link

Description

Crash at app launch. You need to use a Theme.AppCompat theme (or descendant) with this activity.

Android version 8.0.0 - Knox API 25
Unity 6 - 37f1
Firebase Messaging sdk only

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="mypackage" android:versionCode="1" android:versionName="1.0">
  <application android:label="@string/app_name" android:icon="@drawable/app_icon">
    <!-- The MessagingUnityPlayerActivity is a class that extends
         UnityPlayerActivity to work around a known issue when receiving
         notification data payloads in the background. -->
    <activity android:name="com.google.firebase.MessagingUnityPlayerActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>
    <service android:name="com.google.firebase.messaging.MessageForwardingService" android:permission="android.permission.BIND_JOB_SERVICE" android:exported="true"></service>
  </application>
</manifest>

Reproducing the issue

No response

Firebase Unity SDK Version

12.7.0

Unity editor version

Unity 6 - 37f1

Installation Method

.unitypackage

Problematic Firebase Component(s)

Messaging

Other Firebase Component(s) in use

No response

Additional SDKs you are using

{
  "dependencies": {
    "com.unity.2d.sprite": "1.0.0",
    "com.unity.device-simulator.devices": "1.0.0",
    "com.unity.ext.nunit": "2.0.5",
    "com.unity.feature.2d": "2.0.1",
    "com.unity.ide.rider": "3.0.35",
    "com.unity.inputsystem": "1.12.0",
    "com.unity.multiplayer.center": "1.0.0",
    "com.unity.multiplayer.playmode": "1.3.3",
    "com.unity.netcode.gameobjects": "2.2.0",
    "com.unity.nuget.newtonsoft-json": "3.2.1",
    "com.unity.purchasing": "4.12.2",
    "com.unity.render-pipelines.universal": "17.0.3",
    "com.unity.services.authentication": "3.4.1",
    "com.unity.services.core": "1.14.0",
    "com.unity.services.friends": "1.1.0",
    "com.unity.services.multiplayer": "1.1.2",
    "com.unity.services.wire": "1.2.8",
    "com.unity.sysroot": "2.0.10",
    "com.unity.sysroot.linux-x86_64": "2.0.9",
    "com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.10",
    "com.unity.ugui": "2.0.0",
    "com.unity.ui": "2.0.0",
    "com.unity.ui.builder": "2.0.0",
    "com.unity.modules.accessibility": "1.0.0",
    "com.unity.modules.ai": "1.0.0",
    "com.unity.modules.androidjni": "1.0.0",
    "com.unity.modules.animation": "1.0.0",
    "com.unity.modules.assetbundle": "1.0.0",
    "com.unity.modules.audio": "1.0.0",
    "com.unity.modules.cloth": "1.0.0",
    "com.unity.modules.director": "1.0.0",
    "com.unity.modules.imageconversion": "1.0.0",
    "com.unity.modules.imgui": "1.0.0",
    "com.unity.modules.jsonserialize": "1.0.0",
    "com.unity.modules.particlesystem": "1.0.0",
    "com.unity.modules.physics": "1.0.0",
    "com.unity.modules.physics2d": "1.0.0",
    "com.unity.modules.screencapture": "1.0.0",
    "com.unity.modules.subsystems": "1.0.0",
    "com.unity.modules.terrain": "1.0.0",
    "com.unity.modules.terrainphysics": "1.0.0",
    "com.unity.modules.tilemap": "1.0.0",
    "com.unity.modules.ui": "1.0.0",
    "com.unity.modules.uielements": "1.0.0",
    "com.unity.modules.uielementsnative": "1.0.0",
    "com.unity.modules.umbra": "1.0.0",
    "com.unity.modules.unityanalytics": "1.0.0",
    "com.unity.modules.unitywebrequest": "1.0.0",
    "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
    "com.unity.modules.unitywebrequestaudio": "1.0.0",
    "com.unity.modules.unitywebrequesttexture": "1.0.0",
    "com.unity.modules.unitywebrequestwww": "1.0.0",
    "com.unity.modules.vehicles": "1.0.0",
    "com.unity.modules.video": "1.0.0",
    "com.unity.modules.vr": "1.0.0",
    "com.unity.modules.wind": "1.0.0",
    "com.unity.modules.xr": "1.0.0"
  }
}

Targeted Platform(s)

Android

Unity editor platform

Windows

Scripting Runtime

IL2CPP

Release Distribution Type

Pre-built SDK from https://firebase.google.com/download/unity

Relevant Log Output

java.lang.RuntimeException: Unable to start activity ComponentInfo{mypackage/com.google.firebase.MessagingUnityPlayerActivity}:
        java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6944)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
        Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
        at androidx.appcompat.app.h.e0(SourceFile:1)
        at androidx.appcompat.app.h.k0(SourceFile:1)
        at androidx.appcompat.app.h.J(SourceFile:1)
        at androidx.appcompat.app.d.setContentView(SourceFile:2)
        at com.google.androidgamesdk.GameActivity.onCreateSurfaceView(Unknown Source:28)
        at com.unity3d.player.UnityPlayerGameActivity.onCreateSurfaceView(Unknown Source:0)
        at com.google.androidgamesdk.GameActivity.onCreate(Unknown Source:0)
        at com.unity3d.player.UnityPlayerGameActivity.onCreate(Unknown Source:0)
        at com.google.firebase.MessagingUnityPlayerActivity.onCreate(Unknown Source:10)
        at android.app.Activity.performCreate(Activity.java:7183)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) 
        at android.os.Handler.dispatchMessage(Handler.java:105) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6944) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

If using CocoaPods for Apple platforms, the project's Podfile.lock

Expand Podfile.lock snippet
👀 Replace this line with the contents of your Podfile.lock!
@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@firesightstudios
Copy link
Author

firesightstudios commented Apr 11, 2025

Just for clarification. That is the auto generated manifest file.

I tried quite a bit of themes and finally found one that would let me build.

I added this theme to the unity activity entry

android:theme="@android:style/Theme.DeviceDefault.Light.NoActionBar"

The app builds and loads so far with no issues.

@rulutieh
Copy link

Unity6 32f1 - 12.8.0 firebase messaging has same issue.

@hoangnvtdnb
Copy link

hoangnvtdnb commented Apr 14, 2025

Unity 6 38f1 - 12.7.0 also has the same problem (firebase messages). I tried adjusting android:theme but it doesn't seem to work.

@argzdev
Copy link

argzdev commented Apr 14, 2025

Hey folks, thanks for bringing this up to our attention. I was able to reproduce the same behavior. I'll let our engineers know and check this out.

@armedwaffles
Copy link

armedwaffles commented Apr 22, 2025

Had the same problem!

Here is how I fixed it.

Updated the AndroidManifest.xml with the following
(Located in Assets -> Plugins - > Android)

Added "android:theme="@style/BaseUnityGameActivityTheme" in the Unity activity entry

Note that this needs to in between "android:name" and "android:configChanges"

As an example:

Before it was:

<activity
android:name="com.google.firebase.MessagingUnityPlayerActivity"

android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">

After I added the change

<activity
android:name="com.google.firebase.MessagingUnityPlayerActivity" android:theme="@style/BaseUnityGameActivityTheme" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">

You can read more about folks having issues with Unity 6 game crashes here and how they updated the AndroidManifest and some background on why this was an issue:
https://discussions.unity.com/t/unity-6-android-game-crashes-on-android-9-device/1538784/15

If this helped you, give me an emoji :)

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

No branches or pull requests

6 participants