SpiderMan
SpiderMan能爲您做的事:
- 在Android手機上顯示閃退崩潰信息,直接分享給相關開發人員!
- 再也不用擔心測試妹妹給你重現怎樣操作才能觸發閃退崩潰的尷尬!
- 再也不用擔心產品給你說哪兒哪兒會閃退崩潰,但是又不能場景還原的無奈!
- 再也不用擔心某些國產Rom禁止異常log輸出!
- 再也不用擔心開發工具異常log信息輸出時靈時不靈!
引入依賴
從1.1.4版本開始全面遷移到androidx,如不想遷移到androidx請繼續使用1.1.3版本。
def spider_man = "1.1.5"
def spider_man_no_op = "1.1.4"
方式一
debugImplementation "com.simple:spiderman:$spider_man"
releaseImplementation "com.simple:spiderman-no-op:$spider_man_no_op"
方式二
implementation "com.simple:spiderman:$spider_man"
上面方式一debug環境有奔潰信息提示,release環境則沒有,方式二都有,但是記得添加混淆。
初始化
放到Application的onCreate()初始化中,因爲static了傳入的context,並且放在其他Library初始化的前面。
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
//放在其他庫初始化前
SpiderMan.init(this);
}
}
直接顯示錯誤頁面
調用SpiderMan.show(Throwable e)方法
try {
String text = null;
text.toUpperCase();
} catch (Exception e) {
SpiderMan.show(e);
}
衝突
androidx
項目已經依賴了androidx.appcompat:appcompat包,如果產生衝突請使用下面的方式依賴。
debugImplementation("com.simple:spiderman:$spider_man") {
exclude group: "androidx.appcompat"
}
releaseImplementation("com.simple:spiderman-no-op:$spider_man") {
exclude group: "androidx.appcompat"
}
support
項目已經依賴了com.android.support:appcompat-v7包,如果產生衝突請使用下面的方式依賴。
debugImplementation("com.simple:spiderman:$spider_man") {
exclude group: "com.android.support"
}
releaseImplementation("com.simple:spiderman-no-op:$spider_man") {
exclude group: "com.android.support"
}
混淆
-keep class com.simple.spiderman.** { *; }
-keepnames class com.simple.spiderman.** { *; }
-keep public class * extends android.app.Activity
-keep class * implements Android.os.Parcelable {
public static final Android.os.Parcelable$Creator *;
}
# support
-keep public class * extends android.support.annotation.** { *; }
-keep public class * extends android.support.v4.content.FileProvider
# androidx
-keep public class * extends androidx.annotation.** { *; }
-keep public class * extends androidx.core.content.FileProvider
自定義界面樣式
SpiderMan.init(this)
.setTheme(R.style.SpiderManTheme_Dark);
SpiderMan內置了兩種主題樣式light和dark。
所有自定義屬性定義在attrs.xml中
- smToolbar:toolbar的背景色
- smToolbarText:toolb title的顏色
- smToolbarShareText:分享文字按鈕的顏色
- smContentBackground:toolb下方內容的背景色
- smIdentText:標籤名字的顏色
- smDescText:標籤描述的顏色
具體可以參考app中的用法。
版本迭代
1.1.5 增加cpu-abi,versionCode,versionName輸出
1.1.4 切換到androidx
1.1.3 change minSdkVersion to 14
1.1.2 解決FileProvider file_path重名bug(bug來源LuckSiege/PictureSelector)
1.1.1 新增直接顯示錯誤頁面的方法SpiderMan.show(Throwable e),優化錯誤類型
1.1.0 增加自定義界面主題和國際化
1.0.9 增加appcompat包衝突解決方案
1.0.8 發現很多小夥伴不會代理異常收集,所以刪除了異常回調
1.0.7 刪除spiderman-no-op never-crash,優化報錯類型顯示
1.0.6 增加spiderman-no-op
1.0.5 奔潰文本分享美化排版
1.0.4 崩潰輸出改爲error級別
1.0.3 增加 拷貝/分享 崩潰文字/圖片信息
1.0.2 重構,新增設備信息
1.0.1 去除 allowBackup,label
1.0.0 首次上傳