Skip to content
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

Android builds crashing when firebase is also present #90

Open
gsteinkirch-bytro opened this issue Mar 21, 2024 · 2 comments
Open

Android builds crashing when firebase is also present #90

gsteinkirch-bytro opened this issue Mar 21, 2024 · 2 comments

Comments

@gsteinkirch-bytro
Copy link

gsteinkirch-bytro commented Mar 21, 2024

Hey! I'm using Firebase for push notifications on my unity project, and after adding the Didomi SDK the Android build started crashing, after some investigation we figured out it was because of the lack of android:theme="@style/UnityThemeSelector" in the manifest.

The manifest file was automatically generated by firebase and the activity tag looks like this:
<activity android:name="com.google.firebase.MessagingUnityPlayerActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">

The fix was to manually change it to be:
<activity android:name="com.google.firebase.MessagingUnityPlayerActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@style/UnityThemeSelector">

The post-processor in the Didomi package has this method:

private static void UpdateThemeAppCompatInAndroidManifestFile(string path)
    {
        var unityAndroidmManifestFile = $@"src{PostProcessorSettings.FilePathSeperator}main{PostProcessorSettings.FilePathSeperator}AndroidManifest.xml";
        var unityAndroidmManifestFileAbsolutePath = Path.Combine(path, unityAndroidmManifestFile);

        var lines = File.ReadAllLines(unityAndroidmManifestFileAbsolutePath);
        var builder = new StringBuilder();

        var oldValue = @"android:theme=""@style/UnityThemeSelector""";
        var newValue = @"android:theme=""@style/DidomiTheme""";
        foreach (var line in lines)
        {
            if (line.Contains(oldValue))
            {
                builder.AppendLine(line.Replace(oldValue, newValue));
            }
            else
            {
                builder.AppendLine(line);
            }
        }

        File.WriteAllText(unityAndroidmManifestFileAbsolutePath, builder.ToString());
    }

But in cases like mine, where the entry for "@style/UnityThemeSelector" is not there, it simply won't do anything

@pmerlet-at-didomi
Copy link
Contributor

Hello @gsteinkirch-bytro, thanks for your feedback and thanks for providing the workaround. We will try to find a long-term solution for this issue in a future release.

@pmerlet-at-didomi
Copy link
Contributor

@gsteinkirch-bytro With the latest version https://github.com/didomi/unity/releases/tag/2.2.0 , the style is not modified anymore, so your workaround should not be necessary. Can you confirm if it fixes your issue? Thanks!

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

No branches or pull requests

2 participants