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
[Bug] Crash plugin doesn't play nice with Application class init logic #195
Comments
I just ran into the same Problem. The Code that causes the application to crash lives in one of my dagger (using Hilt) modules. |
Correct, Hyperion launches its crash activity in a separate You can work around this issue by initializing your dependencies in that same process. Here's how you can do it using class HyperionCrashProcessWorkaround : ContentProvider() {
private companion object {
var isCreated = false
// Workaround for ContentProvider being created twice:
// https://issuetracker.google.com/issues/37045392
fun ifFirstOnCreate(action: () -> Unit) {
if (isCreated) return
action()
isCreated = true
}
}
override fun onCreate(): Boolean {
ifFirstOnCreate {
initializeFirebase()
}
return false
}
private fun initializeFirebase() {
FirebaseApp.initializeApp(checkNotNull(context))
}
// Default overrides to satisfy ContentProvider's API.
override fun query(uri: Uri, projection: Array<out String>?, selection: String?, selectionArgs: Array<out String>?, sortOrder: String?): Cursor? = null
override fun insert(uri: Uri, values: ContentValues?): Uri? = null
override fun update(uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array<out String>?) = 0
override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?) = 0
override fun getType(uri: Uri): String? = null
} Add the provider <application>
<provider
android:name=".HyperionCrashProcessWorkaround"
android:authorities="${applicationId}.HyperionCrashProcessWorkaround"
android:exported="false"
android:process=":crash"
android:syncable="false"/>
</application> Note the Hyperion-Android/hyperion-crash/src/main/AndroidManifest.xml Lines 1 to 13 in 8bb1e83
Keep in mind that both of these can (and probably should) be defined only in |
Crash plugin seems to try to create its own application process when a crash is detected, this triggers all of my application class init logic to run, such as firebase then crashes the crash plugin :D
Not sure if there's a straight forward solution but interested to hear your thoughts
The text was updated successfully, but these errors were encountered: