红屏死机

A simple screen that is shown when your app gets crashed instead of the normal crash dialog.

它和Flutter中的非常相似。

Red-Screen-Of-Death

安装

RedScreenOfDeath通过JCenter分发。将依赖项添加到您的build.gradle文件中。

还有一个no-op库实现,您可以使用它来方便地将其从您的发布构建中剥离。

在您的build.gradle

repositories {
  jcenter()
}

dependencies {
    debugImplementation 'com.melegy.redscreenofdeath:red-screen-of-death:0.1.2'
    releaseImplementation 'com.melegy.redscreenofdeath:red-screen-of-death-no-op:0.1.2'
}

在您的Application类中

  • Kotlin
class MyApp : Application() {  
    override fun onCreate() {  
        super.onCreate()  
        RedScreenOfDeath.init(this)  
    }  
}
  • Java
public class MyApp extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        RedScreenOfDeath.init(this);
    }
}

这样您就完成了!

免责声明

这应该只在您的调试构建中使用,因为如果您有任何其他库拥有自己的UncaughtExceptionHandler实现,它将不起作用。Red Screen of Death不会将异常传播到其他异常处理程序,因为我们不希望显示“App已停止”对话框。

GitHub

https://github.com/mlegy/red-screen-of-death