テンセントの崩壊の収集Buglyの統合

6576 ワード

オフィシャルサービス
bugly.qq.com

appidとappkeyの申請
     ...

ガイドパッケージ、
      jcenter,maven
buildscript {
    ....
    repositories {
        jcenter()
    }
}
module :
android {
    ...
    defaultConfig {
        ...
        //bugly ndk   ,    x86     
        ndk {
            abiFilters 'armeabi' , 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
        }
    }
}
    //bugly 
    compile 'com.tencent.bugly:crashreport:2.2.0'
    //buglyndk
    compile 'com.tencent.bugly:nativecrashreport:2.2.0'

権限の構成
    
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.READ_LOGS" />

初期化
2.2.0            
    <application>
        <meta-data
            android:name="BUGLY_APPID"
            android:value="appId" />
        
        <meta-data
            android:name="BUGLY_APP_VERSION"
            android:value="1.6.0" />
        
        <meta-data
            android:name="BUGLY_APP_CHANNEL"
            android:value="xiaomi" />
        
        <meta-data
            android:name="BUGLY_ENABLE_DEBUG"
            android:value="true" />
    application>
public class MyApp  extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        //   bugly
        //  ,     
        CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(this);
        strategy.setCrashHandleCallback(new CrashReport.CrashHandleCallback() {
            public Map onCrashHandleStart(int crashType, String errorType,
                                                          String errorMessage, String errorStack) {
                LinkedHashMap map = new LinkedHashMap();
                map.put("  key", "  value");
                return map;
            }

            @Override
            public byte[] onCrashHandleStart2GetExtraDatas(int crashType, String errorType,
                                                           String errorMessage, String errorStack) {
                try {

                    return "Extra data.".getBytes("UTF-8");
                } catch (Exception e) {
                    return null;
                }
            }

        });
        //     ,     CrashReport.initCrashReport(this);
        CrashReport.initCrashReport(getApplicationContext(),strategy);
        //    
        CrashReport.testJavaCrash();
    }