[Android Apps and Games] crazyfury:
Hello,

I added a class instance check for this exception into the smali code in the errorReport() Method.

For me it stops crashing (I'm still on Android 7/Lineage 14.1)

java.lang.ClassCastException: org.chromium.base.JavaExceptionReporter cannot be cast to de.stohelit.ReportExceptionHandler
de.stohelit.audiobookplayer.MainPlayer.errorReport (MainPlayer.java:1434)
de.stohelit.audiobookplayer.MainPlayer$2$1.run(Mai nPlayer.java:225)
android.os.Handler.handleCallback(Handler.java:808 )
android.os.Handler.dispatchMessage(Handler.java:10 1)
android.os.Looper.loop(Looper.java:166)
android.app.ActivityThread.main(ActivityThread.jav a:7523)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.Zygote$MethodAndArgsCaller .run(Zygote.java:245)
com.android.internal.os.ZygoteInit.main(ZygoteInit .java:921)

Here is the relevant java code. My changes are marked bold.

public void errorReport() {
[B]
boolean isInstance = true;
Object obj = Thread.getDefaultUncaughtExceptionHandler();
if (!(obj instanceof de.stohelit.ReportExceptionHandler))
{
isInstance = false;
String msg = obj.getClass().toString();
Log.d("wrongInstance", msg);
}[/B]

if ([B]isInstance &&[/B] ((ReportExceptionHandler)Thread.getDefaultUncaughtExceptionHandler()).errorReportExists()) {
AlertDialog alertDialog = (new AlertDialog.Builder((Context)this)).create();
alertDialog.setTitle(2131231281);
alertDialog.setMessage(getString(2131231282));
alertDialog.setCancelable(false);
alertDialog.setButton(getString(2131231279), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface param1DialogInterface, int param1Int) {
((de.stohelit.MainPlayer)Thread.getDefaultUncaughtExceptionHandler()).mailErrorReport(MainPlayer.this.getString(2131230720));
}
});
alertDialog.setButton2(getString(2131231280), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface param1DialogInterface, int param1Int) {
MainPlayer.this.deleteFile("stack.trace");
}
});
alertDialog.show();
}
}

If you want to try you can use this patch for the smali code.

diff --git a/de.stohelit.audiobookplayer/smali/de/stohelit/audiobookplayer/MainPlayer.smali b/de.stohelit.audiobookplayer/smali/de/stohelit/audiobookplayer/MainPlayer.smali
index 3eb1a3e..dc097ea 100644
--- a/de.stohelit.audiobookplayer/smali/de/stohelit/audiobookplayer/MainPlayer.smali
+++ b/de.stohelit.audiobookplayer/smali/de/stohelit/audiobookplayer/MainPlayer.smali
@@ -3828,85 +3828,125 @@
.end method

.method public errorReport()V
- .locals 4
+ .locals 6
+ .annotation build Landroid/annotation/SuppressLint;
+ value = {
+ "ResourceType"
+ }
+ .end annotation

.prologue
- .line 1434
+ .line 65
+ const/4 v1, 0x1
+
+ .line 66
+ .local v1, "isInstance":Z
invoke-static {}, Ljava/lang/Thread;->getDefaultUncaughtExceptionHandler()Ljava/lang/Thread$UncaughtExceptionHandler;

- move-result-object v1
+ move-result-object v3

- check-cast v1, Lde/stohelit/ReportExceptionHandler;
+ .line 67
+ .local v3, "obj":Ljava/lang/Thread$UncaughtExceptionHandler;
+ instance-of v4, v3, Lde/stohelit/ReportExceptionHandler;

- .line 1435
- .local v1, "reh":Lde/stohelit/ReportExceptionHandler;
- invoke-virtual {v1}, Lde/stohelit/ReportExceptionHandler;->errorReportExists()Z
+ if-nez v4, :cond_0

- move-result v2
+ .line 69
+ const/4 v1, 0x0

- if-eqz v2, :cond_0
+ .line 70
+ invoke-virtual {v3}, Ljava/lang/Object;->getClass()Ljava/lang/Class;
+
+ move-result-object v4
+
+ invoke-virtual {v4}, Ljava/lang/Class;->toString()Ljava/lang/String;
+
+ move-result-object v2
+
+ .line 71
+ .local v2, "msg":Ljava/lang/String;
+ const-string/jumbo v4, "MortPlayer Audio Books -> wrongInstance"
+
+ invoke-static {v4, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I
+
+ .line 74
+ .end local v2 # "msg":Ljava/lang/String;
+ :cond_0
+ if-eqz v1, :cond_1
+
+ invoke-static {}, Ljava/lang/Thread;->getDefaultUncaughtExceptionHandler()Ljava/lang/Thread$UncaughtExceptionHandler;

- .line 1436
- new-instance v2, Landroid/app/AlertDialog$Builder;
+ move-result-object v4
+
+ check-cast v4, Lde/stohelit/ReportExceptionHandler;
+
+ invoke-virtual {v4}, Lde/stohelit/ReportExceptionHandler;->errorReportExists()Z
+
+ move-result v4
+
+ if-eqz v4, :cond_1
+
+ .line 75
+ new-instance v4, Landroid/app/AlertDialog$Builder;

- invoke-direct {v2, p0}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;)V
+ invoke-direct {v4, p0}, Landroid/app/AlertDialog$Builder;-><init>(Landroid/content/Context;)V

- invoke-virtual {v2}, Landroid/app/AlertDialog$Builder;->create()Landroid/app/AlertDialog;
+ invoke-virtual {v4}, Landroid/app/AlertDialog$Builder;->create()Landroid/app/AlertDialog;

move-result-object v0

- .line 1437
- .local v0, "message":Landroid/app/AlertDialog;
- const v2, 0x7f080231
+ .line 76
+ .local v0, "alertDialog":Landroid/app/AlertDialog;
+ const v4, 0x7f080231

- invoke-virtual {v0, v2}, Landroid/app/AlertDialog;->setTitle(I)V
+ invoke-virtual {v0, v4}, Landroid/app/AlertDialog;->setTitle(I)V

- .line 1438
- const v2, 0x7f080232
+ .line 77
+ const v4, 0x7f080232

- invoke-virtual {p0, v2}, Lde/stohelit/audiobookplayer/MainPlayer;->getString(I)Ljava/lang/String;
+ invoke-virtual {p0, v4}, Lde/stohelit/audiobookplayer/MainPlayer;->getString(I)Ljava/lang/String;

- move-result-object v2
+ move-result-object v4

- invoke-virtual {v0, v2}, Landroid/app/AlertDialog;->setMessage(Ljava/lang/CharSequence;)V
+ invoke-virtual {v0, v4}, Landroid/app/AlertDialog;->setMessage(Ljava/lang/CharSequence;)V

- .line 1439
- const/4 v2, 0x0
+ .line 78
+ const/4 v4, 0x0

- invoke-virtual {v0, v2}, Landroid/app/AlertDialog;->setCancelable(Z)V
+ invoke-virtual {v0, v4}, Landroid/app/AlertDialog;->setCancelable(Z)V

- .line 1440
- const v2, 0x7f08022f
+ .line 79
+ const v4, 0x7f08022f

- invoke-virtual {p0, v2}, Lde/stohelit/audiobookplayer/MainPlayer;->getString(I)Ljava/lang/String;
+ invoke-virtual {p0, v4}, Lde/stohelit/audiobookplayer/MainPlayer;->getString(I)Ljava/lang/String;

- move-result-object v2
+ move-result-object v4

- new-instance v3, Lde/stohelit/audiobookplayer/MainPlayer$39;
+ new-instance v5, Lde/stohelit/audiobookplayer/MainPlayer$39;

- invoke-direct {v3, p0}, Lde/stohelit/audiobookplayer/MainPlayer$39;-><init>(Lde/stohelit/audiobookplayer/MainPlayer;)V
+ invoke-direct {v5, p0}, Lde/stohelit/audiobookplayer/MainPlayer$39;-><init>(Lde/stohelit/audiobookplayer/MainPlayer;)V

- invoke-virtual {v0, v2, v3}, Landroid/app/AlertDialog;->setButton(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)V
+ invoke-virtual {v0, v4, v5}, Landroid/app/AlertDialog;->setButton(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)V

- .line 1446
- const v2, 0x7f080230
+ .line 84
+ const v4, 0x7f080230

- invoke-virtual {p0, v2}, Lde/stohelit/audiobookplayer/MainPlayer;->getString(I)Ljava/lang/String;
+ invoke-virtual {p0, v4}, Lde/stohelit/audiobookplayer/MainPlayer;->getString(I)Ljava/lang/String;

- move-result-object v2
+ move-result-object v4

- new-instance v3, Lde/stohelit/audiobookplayer/MainPlayer$40;
+ new-instance v5, Lde/stohelit/audiobookplayer/MainPlayer$40;

- invoke-direct {v3, p0}, Lde/stohelit/audiobookplayer/MainPlayer$40;-><init>(Lde/stohelit/audiobookplayer/MainPlayer;)V
+ invoke-direct {v5, p0}, Lde/stohelit/audiobookplayer/MainPlayer$40;-><init>(Lde/stohelit/audiobookplayer/MainPlayer;)V

- invoke-virtual {v0, v2, v3}, Landroid/app/AlertDialog;->setButton2(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)V
+ invoke-virtual {v0, v4, v5}, Landroid/app/AlertDialog;->setButton2(Ljava/lang/CharSequence;Landroid/content/DialogInterface$OnClickListener;)V

- .line 1452
+ .line 89
invoke-virtual {v0}, Landroid/app/AlertDialog;->show()V

- .line 1454
- .end local v0 # "message":Landroid/app/AlertDialog;
- :cond_0
+ .line 91
+ .end local v0 # "alertDialog":Landroid/app/AlertDialog;
+ :cond_1
return-void
.end method