在寫APP應用的時候經常會遇到某個Activity出問題而導緻APP崩潰,而Android Studio 自帶的 logcat 并沒有搜集到異常資訊,特别是對于那種 “啟動崩” 的異常, 很難馬上捕捉到, 丢失也是經常的。當開發過程中, 如果有沒有處理的異常導緻 crash, 使用了 CrashWoodpecker 以後, 便會起一個新的美觀頁面, 以很友好的方式即時展示異常資訊。這對于檢視錯誤資訊有很大幫助。
現在介紹怎麼使用:
1.配置build.gradle
compileSdkVersion
buildToolsVersion "21.1.2"
targetSdkVersion
2.引用CrashWoodpecker庫
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
debugCompile 'me.drakeet.library:crashwoodpecker:0.9.7'
releaseCompile 'me.drakeet.library:crashwoodpecker-do-nothing:0.9.7'
}
3.建立一個Application類
public class AppTest extends Application {
@Override
public void onCreate() {
super.onCreate();
CrashWoodpecker.fly().to(this);
}
}
4.在Manifest.xml配置Application類
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:name=".AppTest"
android:theme="@style/AppTheme" >