Skip to content

Native crashes for Android do not work #398

Closed

Description

@RiederAlex

Environment

How do you use Sentry?
Sentry SaaS

Which SDK and version?
6.0

Unity Version:
2020.3.18f1 & 2019.4.32f1

Devices:
Nokia 8 with Android 9
Huawei AGS2-W09 with Android 8

Steps to Reproduce

I've followed the steps outlined at https://docs.sentry.io/platforms/unity/
I've added the package and copied more or less what happens inside the sample provided to get a native crash in C++.
However, once the application crashed on the device I get the following error on the next start: logcat.txt, which I just assumed happens because it is trying to upload the dump.

The documentation did not mention any special build steps/requirements to support native crashes for Android (https://docs.sentry.io/platforms/unity/native-support/), so I was under the impression that it should just work.

Activity

  1. bitsandfoxes commented on Nov 2, 2021

    @bitsandfoxes
    Contributor

    Hey @RiederAlex. Sorry to hear you're running into this issue because you are right, it should just work.
    So the app starts without any issue after building? Can you capture any non-native issues
    Are you using a custom Gradle template by any chance?

  2. RiederAlex commented on Nov 2, 2021

    @RiederAlex
    ContributorAuthor

    Yes, the application starts without any other issues.
    Non-native issues (exceptions/errors) show up on the dashboard.
    No, there is no custom Gradle template - I've tried this with a new empty Unity project based on the 3D template (so also no Play Services resolver ect ect which could interfere with the gradle build).

    I could try to initialize the SDK with Debug = true, but I guess the problem is that some dependencies are missing, as the build.gradle file only includes:
    dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation(name: 'sentry-android-core-release', ext:'aar') implementation(name: 'sentry-android-ndk-release', ext:'aar') }

  3. bruno-garcia commented on Nov 2, 2021

    @bruno-garcia
    Member

    Thank you so much for the detailed issue description and logs.

    ~It looks like the error is bubbling through all the way, does the app launch? ~

    The Android SDK has AndroidX dependencies as optional and should handle the errors internally and downgrade any features that are added through AndroidX. So something we need to investigate.

    Seems like this is just a 'warning' in a way, there are other such errors for other types, for example:

    2021/11/02 11:02:26.863 14010 14039 Info zygote64   at boolean com.unity3d.player.UnityPlayer.nativeRender() ((null):-2)
    2021/11/02 11:02:26.863 14010 14039 Info zygote64   at boolean com.unity3d.player.UnityPlayer.access$300(com.unity3d.player.UnityPlayer) ((null):-1)
    2021/11/02 11:02:26.863 14010 14039 Info zygote64   at boolean com.unity3d.player.UnityPlayer$e$1.handleMessage(android.os.Message) ((null):-1)
    2021/11/02 11:02:26.863 14010 14039 Info zygote64   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:104)
    2021/11/02 11:02:26.863 14010 14039 Info zygote64   at void android.os.Looper.loop() (Looper.java:166)
    2021/11/02 11:02:26.863 14010 14039 Info zygote64   at void com.unity3d.player.UnityPlayer$e.run() ((null):-1)
    
    

    So this shouldn't be a reason why the event isnt' sent:

    2021/11/02 11:02:26.621 14010 14010 Info zygote64 Rejecting re-init on previously-failed class java.lang.Class<io.sentry.android.core.LifecycleWatcher>: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/lifecycle/DefaultLifecycleObserver;
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void io.sentry.android.core.AndroidOptionsInitializer.installDefaultIntegrations(android.content.Context, io.sentry.SentryOptions, io.sentry.android.core.IBuildInfoProvider, io.sentry.android.core.LoadClass, io.sentry.android.core.ActivityFramesTracker) (AndroidOptionsInitializer.java:149)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void io.sentry.android.core.AndroidOptionsInitializer.init(io.sentry.android.core.SentryAndroidOptions, android.content.Context, io.sentry.ILogger, io.sentry.android.core.IBuildInfoProvider, io.sentry.android.core.LoadClass) (AndroidOptionsInitializer.java:110)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void io.sentry.android.core.AndroidOptionsInitializer.init(io.sentry.android.core.SentryAndroidOptions, android.content.Context, io.sentry.ILogger, io.sentry.android.core.IBuildInfoProvider) (AndroidOptionsInitializer.java:75)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void io.sentry.android.core.AndroidOptionsInitializer.init(io.sentry.android.core.SentryAndroidOptions, android.content.Context, io.sentry.ILogger) (AndroidOptionsInitializer.java:59)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void io.sentry.android.core.SentryAndroid.lambda$init$1(android.content.Context, io.sentry.ILogger, io.sentry.Sentry$OptionsConfiguration, io.sentry.android.core.SentryAndroidOptions) (SentryAndroid.java:74)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void io.sentry.android.core.-$$Lambda$SentryAndroid$g99QaqNwcEFxja-3CMUNWZ36_g4.configure(io.sentry.SentryOptions) (lambda:-1)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void io.sentry.Sentry.init(io.sentry.OptionsContainer, io.sentry.Sentry$OptionsConfiguration, boolean) (Sentry.java:116)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void io.sentry.android.core.SentryAndroid.init(android.content.Context, io.sentry.ILogger, io.sentry.Sentry$OptionsConfiguration) (SentryAndroid.java:71)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void io.sentry.android.core.SentryAndroid.init(android.content.Context, io.sentry.ILogger) (SentryAndroid.java:40)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at boolean io.sentry.android.core.SentryInitProvider.onCreate() (SentryInitProvider.java:27)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void android.content.ContentProvider.attachInfo(android.content.Context, android.content.pm.ProviderInfo, boolean) (ContentProvider.java:1921)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void android.content.ContentProvider.attachInfo(android.content.Context, android.content.pm.ProviderInfo) (ContentProvider.java:1896)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void io.sentry.android.core.SentryInitProvider.attachInfo(android.content.Context, android.content.pm.ProviderInfo) (SentryInitProvider.java:44)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at android.app.ContentProviderHolder android.app.ActivityThread.installProvider(android.content.Context, android.app.ContentProviderHolder, android.content.pm.ProviderInfo, boolean, boolean, boolean) (ActivityThread.java:7212)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void android.app.ActivityThread.installContentProviders(android.content.Context, java.util.List) (ActivityThread.java:6699)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void android.app.ActivityThread.handleBindApplication(android.app.ActivityThread$AppBindData) (ActivityThread.java:6600)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void android.app.ActivityThread.-wrap2(android.app.ActivityThread, android.app.ActivityThread$AppBindData) (ActivityThread.java:-1)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:2066)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:108)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void android.os.Looper.loop() (Looper.java:166)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:7529)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:245)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64   at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:921)
    2021/11/02 11:02:26.621 14010 14010 Info zygote64 Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.lifecycle.DefaultLifecycleObserver" on path: DexPathList[[zip file "/data/app/com.zeppelinstudio.unitytemplate-7o6RoXZ9BqaEg26YQN7xsQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.zeppelinstudio.unitytemplate-7o6RoXZ9BqaEg26YQN7xsQ==/lib/arm64, /data/app/
    
  4. bruno-garcia commented on Nov 2, 2021

    @bruno-garcia
    Member

    Possibly we need a change similar to the AndroidX.Core done here: getsentry/sentry-java#1718
    @marandaneto thoughts?

  5. bruno-garcia commented on Nov 2, 2021

    @bruno-garcia
    Member

    @RiederAlex There are no logs from the Sentry SDK in the logcat output. This is the default behavior (so there's no overhead of the SDK logging in your player builds). But could you please enable it so we can see the native SDK logs?

    In the Debug setting in Sentry Window you can select Only In Editor. So that logging happens also in the player builds.

  6. marandaneto commented on Nov 2, 2021

    @marandaneto
    Contributor
  7. RiederAlex commented on Nov 2, 2021

    @RiederAlex
    ContributorAuthor

    Here is the complete logcat output of 2 runs where "Advanced -> Enable Debug Output -> Only in Editor" was set to false.

    There is one run where I produced the crash and one where I started up the application afterwards once again (not sure how/when sentry is supposed to upload the crash dumps, so just did that for good measure).

    Logs where I've left the verbosity level on warning:
    crash run warning.txt
    next run warning.txt

    Interestingly enough setting the verbosity level to "debug" (Advanced -> Verbosity Level) produced less logs and did not show the missing class exception, so there might be something funky going on there as well.
    crash run debug.txt
    next run debug.txt

    Just to make sure I understand the feature of sentry correctly - I would expect these crash dumps to show up in my dashboard, but all I see are the other errors triggered for testing purposes via C# exceptions:
    capture

  8. marandaneto commented on Nov 3, 2021

    @marandaneto
    Contributor

    @RiederAlex I see in the logs:

    Rejecting re-init on previously-failed class java.lang.Class<com.unity3d.player.AssetPackManagerWrapper$b>: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/play/core/assetpacks/AssetPackStateUpdateListener;

    is that by any chance missing on your project? could that be the reason for crashing? that's not from our SDK.

    Sentry Unity SDK + Sentry Android SDK seems to be doing its job, see:

    sentry-native crash has been captured

  9. RiederAlex commented on Nov 4, 2021

    @RiederAlex
    ContributorAuthor

    @marandaneto these errors come from unity directly and happen on any project, it has nothing to do with sentry or the problem at hand from my experience.

    I did some more testing and played around with the sample that is provided in this repository. I've started from it but used the released 0.0.6 version of the SDK instead of building my own + replaced the sentry url.

    With Unity 2019.4.31f1 native crashes on Android work correctly - I can see them in the dashboard
    crash 2019.txt
    after crash 2019.txt

    With Unity 2020.3.18f1 native crashes on Android do not work correctly - I cannot see them on the dashboard.
    crash 2020.txt
    after crash 2020.txt

    From the logs I failed to understand what exactly is going on - it seems like in both instances something is sent, but I'm not sure how to further debug it on my side without your support.

  10. marandaneto commented on Nov 4, 2021

    @marandaneto
    Contributor

    @RiederAlex I don't see the log Envelope sent successfully on after crash 2020 and this is serialization time that depends on Gson, does Unity 2020 ships Google Gson and which version?

  11. bruno-garcia commented on Nov 4, 2021

    @bruno-garcia
    Member

    I could be wrong but seems like it brings Gson 2.8.0. IIRC that causes conflict with Sentry Android, is that correct @marandaneto ?

    If that's the case, we really need to bring in sentry-android v6 which drops support to Gson.

  12. marandaneto commented on Nov 4, 2021

    @marandaneto
    Contributor

    Min is 2.7 so it should not be a problem if Gson is available at runtime as 2.8, but better confirming that

  13. marandaneto commented on Nov 11, 2021

    @marandaneto
    Contributor

    We've managed to reproduce it and have a fix coming out soon, sorry for the inconvenience, and thanks for reporting and helping us out.

  14. RiederAlex commented on Nov 11, 2021

    @RiederAlex
    ContributorAuthor

    Thank you very much!
    I will retest with my unity project once the related PR bubbles up to this repository.

  15. RiederAlex commented on Nov 16, 2021

    @RiederAlex
    ContributorAuthor

    Can confirm 0.6.1 works now on Android for 2020.3.18f1 and my non-test project.

  16. bitsandfoxes commented on Nov 16, 2021

    @bitsandfoxes
    Contributor

    That's great news! Thanks for letting us know!
    Just a heads-up, there's been a mix-up and the 0.6.1 release is missing the .framework for Sentry to work on iOS. 0.6.2 resolves this new issue. Apologies for the inconvenience.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugsomething isn't working as it should

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions