NeverCrashforAndroid一个全局捕获Crash的库。信NeverCrash,永不Crash。
Gif展示引入Maven:<dependency><groupId>com.king.thread</groupId><artifactId>nevercrash</artifactId><version>1.0.0</version><type>pom</type></dependency>Gradle:compile'com.king.thread:nevercrash:1.0.0'Lvy:<dependencyorg='com.king.thread'name='nevercrash'rev='1.0.0'><artifactname='$AID'ext='pom'></artifact></dependency>如果Gradle出现compile失败的情况,可以在Project的build.gradle里面添加如下:(也可以使用上面的GitPack来complie)
allprojects{repositories{maven{url'https://dl.bintray.com/jenly/maven'}}}示例核心代码(大道至简)
NeverCrash.init(CrashHandler);代码示例
publicclassAppextendsApplication{@OverridepublicvoidonCreate(){super.onCreate();NeverCrash.init(newNeverCrash.CrashHandler(){@OverridepublicvoiduncaughtException(Threadt,Throwablee){Log.d("Jenly",Log.getStackTraceString(e));//e.printStackTrace();showToast(e.getMessage());}});}privatevoidshowToast(finalStringtext){newHandler(Looper.getMainLooper()).post(newRunnable(){@Overridepublicvoidrun(){Toast.makeText(getApplicationContext(),text,Toast.LENGTH_SHORT).show();}});}}
评论