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

fix: AbstractMethodError when getting Lifecycle #2228

Merged
merged 9 commits into from
Sep 6, 2022

Conversation

bitsandfoxes
Copy link
Contributor

📜 Description

This came up through Unity. In some cases, Unity projects resolve their own external dependencies via adding and including arr files. This seems to lead to issues during runtime when the AppLifecycleIntegration tries to add its observer and results in an AbstractMethodError.

💡 Motivation and Context

To deal with the AbstractMethodError gracefully, we can catch the error instead and bail before we create the watcher.

2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime FATAL EXCEPTION: main
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime Process: studio.banditos.banditos5, PID: 30530
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime java.lang.AbstractMethodError: abstract method "void androidx.lifecycle.DefaultLifecycleObserver.onCreate(androidx.lifecycle.LifecycleOwner)"
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at androidx.lifecycle.FullLifecycleObserverAdapter.onStateChanged(FullLifecycleObserverAdapter.java:36)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:196)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at io.sentry.android.core.AppLifecycleIntegration.addObserver(AppLifecycleIntegration.java:92)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at io.sentry.android.core.AppLifecycleIntegration.register(AppLifecycleIntegration.java:60)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at io.sentry.Sentry.init(Sentry.java:189)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at io.sentry.Sentry.init(Sentry.java:118)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:87)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:56)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at io.sentry.android.core.SentryInitProvider.onCreate(SentryInitProvider.java:27)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at android.content.ContentProvider.attachInfo(ContentProvider.java:2429)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at android.content.ContentProvider.attachInfo(ContentProvider.java:2399)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at io.sentry.android.core.SentryInitProvider.attachInfo(SentryInitProvider.java:44)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at android.app.ActivityThread.installProvider(ActivityThread.java:8210)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at android.app.ActivityThread.installContentProviders(ActivityThread.java:7746)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7566)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at android.app.ActivityThread.access$1500(ActivityThread.java:301)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2177)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at android.os.Handler.dispatchMessage(Handler.java:106)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at android.os.Looper.loop(Looper.java:246)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at android.app.ActivityThread.main(ActivityThread.java:8653)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at java.lang.reflect.Method.invoke(Native Method)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
2022/08/22 15:26:47.122 30530 30530 Error AndroidRuntime 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

💚 How did you test it?

📝 Checklist

  • I reviewed the submitted code
  • I added tests to verify the changes
  • I updated the docs if needed
  • No breaking changes

🔮 Next steps

@marandaneto
Copy link
Contributor

@bitsandfoxes revert the sentry-native changes.

Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rever the submodule changes

@codecov-commenter
Copy link

Codecov Report

Base: 80.62% // Head: 80.62% // No change to project coverage 👍

Coverage data is based on head (7987e12) compared to base (0d55590).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #2228   +/-   ##
=========================================
  Coverage     80.62%   80.62%           
  Complexity     3357     3357           
=========================================
  Files           240      240           
  Lines         12335    12335           
  Branches       1638     1638           
=========================================
  Hits           9945     9945           
  Misses         1783     1783           
  Partials        607      607           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@philipphofmann
Copy link
Member

@bitsandfoxes, I think we discussed yesterday in a call that we don't need this change because the root cause is some weird transient dependency handling of Unity. If the same error happens on Android, we want the SDK to crash instead of failing silently to let the user know something is wrong with the dependencies. Furthermore, we concluded that this error is an edge case on Android. Should we close this?

@marandaneto
Copy link
Contributor

@bitsandfoxes, I think we discussed yesterday in a call that we don't need this change because the root cause is some weird transient dependency handling of Unity. If the same error happens on Android, we want the SDK to crash instead of failing silently to let the user know something is wrong with the dependencies. Furthermore, we concluded that this error is an edge case on Android. Should we close this?

I think this quick workaround makes sense so that the SDK won't install AppLifecycleIntegration but everything else should work, it's the 2nd time this issue comes up, so apparently, it was not a one-off.

@philipphofmann
Copy link
Member

I think this quick workaround makes sense so that the SDK won't install AppLifecycleIntegration but everything else should work, it's the 2nd time this issue comes up, so apparently, it was not a one-off.

Fine with me as long as we don't silently fail. Logging the error should be enough.

@bitsandfoxes bitsandfoxes merged commit ebcad65 into main Sep 6, 2022
@bitsandfoxes bitsandfoxes deleted the fix/trycatch-getlifecycle branch September 6, 2022 11:28
vaind pushed a commit that referenced this pull request Sep 7, 2022
* wrapped getLifeCycle in a try-catch

* removed newline

* Format code

* Updated CHANGELOG.md

* wrapping L92 and added comment

* Format code

Co-authored-by: Sentry Github Bot <[email protected]>
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

Successfully merging this pull request may close these issues.

6 participants