新增firebase-crashlytics
This commit is contained in:
parent
ab6e578336
commit
6b7fd4d53e
@ -1,6 +1,7 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'img-optimizer'
|
apply plugin: 'img-optimizer'
|
||||||
apply plugin: 'com.google.gms.google-services'
|
apply plugin: 'com.google.gms.google-services'
|
||||||
|
apply plugin: 'com.google.firebase.crashlytics'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
dexOptions {
|
dexOptions {
|
||||||
@ -217,6 +218,10 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
||||||
|
|
||||||
|
implementation platform('com.google.firebase:firebase-bom:30.5.0')
|
||||||
|
implementation 'com.google.firebase:firebase-crashlytics'
|
||||||
|
|
||||||
//直播
|
//直播
|
||||||
api project(':main')
|
api project(':main')
|
||||||
//短视频
|
//短视频
|
||||||
|
@ -6,9 +6,11 @@ import android.app.Activity;
|
|||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.http.HttpResponseCache;
|
import android.net.http.HttpResponseCache;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Process;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@ -23,6 +25,9 @@ import com.alibaba.android.arouter.launcher.ARouter;
|
|||||||
import com.blankj.utilcode.util.Utils;
|
import com.blankj.utilcode.util.Utils;
|
||||||
import com.facebook.appevents.AppEventsLogger;
|
import com.facebook.appevents.AppEventsLogger;
|
||||||
import com.fm.openinstall.OpenInstall;
|
import com.fm.openinstall.OpenInstall;
|
||||||
|
import com.google.firebase.FirebaseApp;
|
||||||
|
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||||
|
import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
||||||
import com.tencent.imsdk.v2.V2TIMGroupMemberInfo;
|
import com.tencent.imsdk.v2.V2TIMGroupMemberInfo;
|
||||||
import com.tencent.imsdk.v2.V2TIMManager;
|
import com.tencent.imsdk.v2.V2TIMManager;
|
||||||
import com.tencent.imsdk.v2.V2TIMSimpleMsgListener;
|
import com.tencent.imsdk.v2.V2TIMSimpleMsgListener;
|
||||||
@ -53,6 +58,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import io.rong.imkit.config.RongConfigCenter;
|
import io.rong.imkit.config.RongConfigCenter;
|
||||||
@ -124,9 +130,11 @@ public class AppContext extends CommonAppContext {
|
|||||||
super.onCreate();
|
super.onCreate();
|
||||||
//注册全局异常捕获
|
//注册全局异常捕获
|
||||||
registerError();
|
registerError();
|
||||||
|
registerFirebaseCrash();
|
||||||
sInstance = this;
|
sInstance = this;
|
||||||
L.setDeBug(BuildConfig.DEBUG);
|
L.setDeBug(BuildConfig.DEBUG);
|
||||||
AppEventsLogger.activateApp(this);
|
AppEventsLogger.activateApp(this);
|
||||||
|
FirebaseAnalytics.getInstance(this);
|
||||||
|
|
||||||
File httpCacheDir = new File(getCacheDir(), "https");
|
File httpCacheDir = new File(getCacheDir(), "https");
|
||||||
try {
|
try {
|
||||||
@ -302,8 +310,9 @@ public class AppContext extends CommonAppContext {
|
|||||||
activity.get().finish();
|
activity.get().finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Process.killProcess(Process.myPid());
|
/* Process.killProcess(Process.myPid());
|
||||||
System.exit(0);
|
System.exit(0);*/
|
||||||
|
new Handler(Looper.getMainLooper()).postDelayed(()->{throw new RuntimeException(e);},100);
|
||||||
})
|
})
|
||||||
.setUncaughtCrashHandler((t, e) -> {
|
.setUncaughtCrashHandler((t, e) -> {
|
||||||
Log.e("ApplicationError", "子线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息
|
Log.e("ApplicationError", "子线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息
|
||||||
@ -311,4 +320,15 @@ public class AppContext extends CommonAppContext {
|
|||||||
})
|
})
|
||||||
.register(this);
|
.register(this);
|
||||||
}
|
}
|
||||||
|
public void registerFirebaseCrash(){
|
||||||
|
FirebaseAnalytics.getInstance(this);
|
||||||
|
FirebaseApp.initializeApp(this);
|
||||||
|
FirebaseCrashlytics.getInstance().setUserId(CommonAppConfig.getInstance().getUid());
|
||||||
|
FirebaseCrashlytics.getInstance().setCustomKey("uid",CommonAppConfig.getInstance().getUid());
|
||||||
|
FirebaseCrashlytics.getInstance().setCustomKey("userData",SpUtil.getInstance().getStringValue(SpUtil.USER_INFO));
|
||||||
|
FirebaseCrashlytics.getInstance().setCustomKey("isGoogle",CommonAppConfig.IS_GOOGLE_PLAY);
|
||||||
|
FirebaseCrashlytics.getInstance().setCustomKey("PhoneName", Build.BRAND);
|
||||||
|
FirebaseCrashlytics.getInstance().setCustomKey("Phone", Build.MODEL);
|
||||||
|
FirebaseCrashlytics.getInstance().setCustomKey("CPU", Arrays.toString(Build.SUPPORTED_ABIS));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,11 +102,11 @@ public class NeverCrashUtils {
|
|||||||
Toast.makeText(application, "发生闪退", Toast.LENGTH_SHORT).show();
|
Toast.makeText(application, "发生闪退", Toast.LENGTH_SHORT).show();
|
||||||
FileUtil.saveStringToFile(new File(application.getDir("files", Context.MODE_PRIVATE).getAbsolutePath()),throwableToString(e),"error.log");
|
FileUtil.saveStringToFile(new File(application.getDir("files", Context.MODE_PRIVATE).getAbsolutePath()),throwableToString(e),"error.log");
|
||||||
getMainCrashHandler().mainException(Looper.getMainLooper().getThread(), e);
|
getMainCrashHandler().mainException(Looper.getMainLooper().getThread(), e);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
/*
|
||||||
//子线程异常拦截
|
//子线程异常拦截
|
||||||
Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
|
Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
|
||||||
if (isDebugMode()) {
|
if (isDebugMode()) {
|
||||||
@ -118,7 +118,7 @@ public class NeverCrashUtils {
|
|||||||
getMainCrashHandler().mainException(Looper.getMainLooper().getThread(), e);
|
getMainCrashHandler().mainException(Looper.getMainLooper().getThread(), e);
|
||||||
getUncaughtCrashHandler().uncaughtException(t, e);
|
getUncaughtCrashHandler().uncaughtException(t, e);
|
||||||
|
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface MainCrashHandler {
|
public interface MainCrashHandler {
|
||||||
|
@ -21,6 +21,7 @@ buildscript {
|
|||||||
classpath 'com.chenenyu:img-optimizer:1.3.0'
|
classpath 'com.chenenyu:img-optimizer:1.3.0'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20"
|
||||||
classpath 'com.google.gms:google-services:4.3.3'
|
classpath 'com.google.gms:google-services:4.3.3'
|
||||||
|
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user