Not using Unity Analytics, but it crashes my game on Android

Hello, everybody,

I am working on an already quite complex project, where I am deploying to Android and iOS. I am offering a Demo version of the game for Google Instant Play. This version should be as lightweight as possible, because Google’s max size for these kind of apps is around 15 MB.

I am using Firebase Analytics, and not Unity Analytics.

Now, for my Demo version, I am completely excluding Firebase (doing so with an Editor script). So far so good, until I build and test the game on Android. It crashes right after the splashscreen fades away.

After debugging it with Logcat, I find these lines:

2020-04-08 19:54:43.369 8775-8803/com.company.name E/Unity: Unable to find type [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.Analytics.AnalyticsSessionInfo
    (Filename: ./Runtime/Scripting/CommonScriptingClasses.cpp Line: 126)
2020-04-08 19:54:43.370 8775-8803/com.company.name E/Unity: Unable to find method CallIdentityTokenChanged in [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.Analytics.AnalyticsSessionInfo
    (Filename: ./Runtime/Scripting/CommonScriptingClasses.cpp Line: 143)
2020-04-08 19:54:43.371 8775-8803/com.company.name E/Unity: Unable to find method CallSessionStateChanged in [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.Analytics.AnalyticsSessionInfo
    (Filename: ./Runtime/Scripting/CommonScriptingClasses.cpp Line: 143)
2020-04-08 19:54:43.371 8775-8803/com.company.name E/Unity: Unable to find type [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.Analytics.AnalyticsSessionState
    (Filename: ./Runtime/Scripting/CommonScriptingClasses.cpp Line: 126)
2020-04-08 19:54:43.372 8775-8803/com.company.name E/Unity: Unable to find type [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.Analytics.ContinuousEvent
    (Filename: ./Runtime/Scripting/CommonScriptingClasses.cpp Line: 126)
2020-04-08 19:54:43.373 8775-8803/com.company.name E/Unity: Unable to find method RemoteConfigSettingsUpdated in [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.RemoteConfigSettings
    (Filename: ./Runtime/Scripting/CommonScriptingClasses.cpp Line: 143)
2020-04-08 19:54:43.374 8775-8803/com.company.name E/Unity: Unable to find type [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.RemoteConfigSettingsHelper/Tag
    (Filename: ./Runtime/Scripting/CommonScriptingClasses.cpp Line: 126)
2020-04-08 19:54:43.374 8775-8803/com.company.name E/Unity: Unable to find method RemoteSettingsBeforeFetchFromServer in [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.RemoteSettings
    (Filename: ./Runtime/Scripting/CommonScriptingClasses.cpp Line: 143)
2020-04-08 19:54:43.375 8775-8803/com.company.name E/Unity: Unable to find method RemoteSettingsUpdateCompleted in [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.RemoteSettings
    (Filename: ./Runtime/Scripting/CommonScriptingClasses.cpp Line: 143)
2020-04-08 19:54:43.376 8775-8803/com.company.name E/Unity: Unable to find method RemoteSettingsUpdated in [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.RemoteSettings
    (Filename: ./Runtime/Scripting/CommonScriptingClasses.cpp Line: 143)

Seeing Unity Analytics all over the place really confused me, because I am not using this package (I have even disabled it from the Package Manager). So, next step was testing another build with Unity Analytics enabled. IT WORKED.

For some reason, this bug appeared after I removed Firebase, and not before. Might Firebase use Unity Analytics?

Also important to mention, this problem doesn’t happen if I don’t enable Strip Engine Code. However, I aim to have this enabled.

I am wondering if this might be a bug from Unity. Could someone assist me?

I am including as an attachment, the complete crash log from Android Studio’s Logcat.

Some more info:

  • Unity 2019.3.3f1
  • IL2CPP
  • Firebase modules: Analytics, Crashlytics & Functions (6.13.0)

5688658–593809–unity-analytics-bug.txt (18.8 KB)

Can you please confirm steps to reproduce, without Firebase? You can confirm if an app is using Unity Analytics by using Charles Proxy https://support.unity3d.com/hc/en-us/articles/115002917683-Using-Charles-Proxy-with-Unity

1 Like

After some testing, I think I know what the problem is.

I have Unity Plus, and I am disabling the Unity Logo Splashscreen as well as signing in to link my project with Unity Services (so I can use my seat).

So, let’s review the test cases I performed (all of these exclude Firebase from the project completely):

  • No Unity Analytics: my game crashes (described before).
  • With Unity Analytics or Code Stripping disabled: game works.
  • Sign off of Unity Services and remove Unity Analytics: game works, but Unity’s splashscreen is added.

I also used the tool Charles to monitor this assertions, they match accordingly.

Now, I have a question for you: is this a bug or it is meant to behave like that?

By the way, I have Analytics turned off in the Services configuration.

I personally am not aware of this behavior. Please provide the Charles captures for analysis, and please provide steps to reproduce on a new project. A project without Analytics doesn’t crash for me, for example.

Ok, I was able to reproduce this on a new project. Here is the link to its source, with a built APK already in there: https://github.com/sdegetaus/unity-no-analytics-test

In the repo, I include the session for the crash I get from running that APK.

Steps to reproduce on a new project:

  • Remove Unity Analytics from the Package Manager.

  • Link your project to the Unity Services.

  • Enable Strip Engine and set it to the highest.

  • Don’t know if these might affect but I mention them anyway:

  • IL2CPP

  • .NET Standard 2.0

  • Compiler Config Master

  • Both ARMv7 & ARM64

There is no need to remove Unity Analytics from the Package Manager. You enable/disable Analytics in the Services window. Please try your test without doing so.

In that case, as I said, the game doesn’t crash. But I am trying to remove all the unused Unity Built-in packages from my project, and I don’t see why Unity Analytics should be the exception (so far I have been able to remove most of them).

Thanks for the help!

Understood, as you originally stated, sorry about that. We are following up.

Can you elaborate what you mean by “Remove Analytics from Package Manager”. On a brand new project, it’s not installed. It’s in the list of available packages however when I choose to view “All Packages”. You have to explicitly install it.

It looks like it may be caused by Crash Reporting, it looks like you have it turned on https://github.com/sdegetaus/unity-no-analytics-test/blob/master/ProjectSettings/UnityConnectSettings.asset

Setting the adequate options to 0 instead of 1 solved this! Thanks for your support :slight_smile:

Just one more question, in my Services window everything is set to OFF. Where are these options, like CrashReporting, AdsInitOnStartup, etc, located (like an Editor Window)?

Btw, some settings from the UnityConnectSettings.asset get enabled by just “previewing” them. For example, if I click on Ads (without setting it to ON), CrashReporting gets automatically set to 1 :confused:

Yes, this is something you will want to keep watch for at this time. You can edit the file directly, it gets updated when you Save the project.

1 Like

Ok, thanks a lot for your help!
I am deleting the repo soon.

1 Like

Hey!
Faced the same problem.
The steps for reproduction are the same. The app crashes right after the loading screen. The following fields are exposed in UnityConnectSettings.asset:

UnityAnalyticsSettings:
    m_Enabled: 0
    m_TestMode: 0
    m_InitializeOnStartup: 0

Unity 2021.1.15f1
How to solve the problem?

Analytics is not enabled as you can see. You can always check in Package Manager if you have the Analytics package installed.

I don’t have any installed Analytics package. This is all my dependencies.

{
  "dependencies": {
    "com.unity.ads": "3.7.3",
    "com.unity.ide.rider": "3.0.7",
    "com.unity.mobile.android-logcat": "1.2.2",
    "com.unity.mobile.notifications": "1.4.1",
    "com.unity.test-framework": "1.1.27",
    "com.unity.ugui": "1.0.0",
    "com.unity.modules.androidjni": "1.0.0",
    "com.unity.modules.animation": "1.0.0",
    "com.unity.modules.imgui": "1.0.0",
    "com.unity.modules.jsonserialize": "1.0.0",
    "com.unity.modules.ui": "1.0.0",
    "com.unity.modules.unitywebrequest": "1.0.0"
  }
}

Why do you believe the crash reports are related to Analytics? Did you see the previous post that mentioned removing Crash Reporting?

Because I see it in the crash logs

2021.07.20 18:57:24.450 Unity Unable to find type [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.Analytics.AnalyticsSessionInfo
2021.07.20 18:57:24.453 Unity Unable to find method CallIdentityTokenChanged in [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.Analytics.AnalyticsSessionInfo
2021.07.20 18:57:24.454 Unity Unable to find method CallSessionStateChanged in [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.Analytics.AnalyticsSessionInfo
2021.07.20 18:57:24.455 Unity Unable to find type [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.Analytics.AnalyticsSessionState
2021.07.20 18:57:24.456 Unity Unable to find type [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.Analytics.ContinuousEvent
2021.07.20 18:57:24.457 Unity Unable to find method RemoteConfigSettingsUpdated in [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.RemoteConfigSettings
2021.07.20 18:57:24.458 Unity Unable to find type [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.RemoteConfigSettingsHelper/Tag
2021.07.20 18:57:24.458 Unity Unable to find method RemoteSettingsBeforeFetchFromServer in [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.RemoteSettings
2021.07.20 18:57:24.459 Unity Unable to find method RemoteSettingsUpdateCompleted in [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.RemoteSettings
2021.07.20 18:57:24.459 Unity Unable to find method RemoteSettingsUpdated in [UnityEngine.UnityAnalyticsModule.dll]UnityEngine.RemoteSettings

Please see this previous post https://discussions.unity.com/t/784652/10

I do not fully understand what CrashReporting is about. If we are talking about CrashReportingSettings in UnityConnectSettings.asset, then I have it turned off.
Here is the full text from UnityConnectSettings.asset (replaced advertising IDs with 0000):

%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!310 &1
UnityConnectSettings:
  m_ObjectHideFlags: 0
  serializedVersion: 1
  m_Enabled: 1
  m_TestMode: 0
  m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events
  m_EventUrl: https://cdp.cloud.unity3d.com/v1/events
  m_ConfigUrl: https://config.uca.cloud.unity3d.com
  m_DashboardUrl: https://dashboard.unity3d.com
  m_TestInitMode: 0
  CrashReportingSettings:
    m_EventUrl: https://perf-events.cloud.unity3d.com
    m_Enabled: 0
    m_LogBufferSize: 10
    m_CaptureEditorExceptions: 1
  UnityPurchasingSettings:
    m_Enabled: 0
    m_TestMode: 0
  UnityAnalyticsSettings:
    m_Enabled: 0
    m_TestMode: 0
    m_InitializeOnStartup: 0
  UnityAdsSettings:
    m_Enabled: 1
    m_InitializeOnStartup: 1
    m_TestMode: 0
    m_IosGameId:
    m_AndroidGameId: 0000
    m_GameIds:
      AndroidPlayer: 0000
      iPhonePlayer: 0000
    m_GameId: 0000
  PerformanceReportingSettings:
    m_Enabled: 0