feat:集成firebase-analytics、Crashlytics(升级kotlin版本到1.8.22)
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
"project_id":"736430079244645870",
|
||||
"app_id":"102953045",
|
||||
"api_key":"DAEDAN1bqknzqRuvualUo98vO7U9uXBJtBZ0rNQHgSo03bXgkl98tD4sytVBCBB1Y7ha0NcY++dSp9JLsws9BzDN+/fS3v8J9We3nA==",
|
||||
"package_name":"cn.nnbc123.voice"
|
||||
"package_name":"cn.nn.voice"
|
||||
},
|
||||
"oauth_client":{
|
||||
"client_id":"102953045",
|
||||
@@ -41,7 +41,7 @@
|
||||
},
|
||||
"app_info":{
|
||||
"app_id":"102953045",
|
||||
"package_name":"cn.nnbc123.voice"
|
||||
"package_name":"cn.nn.voice"
|
||||
},
|
||||
"service":{
|
||||
"analytics":{
|
||||
@@ -75,12 +75,12 @@
|
||||
"configuration_version":"3.0",
|
||||
"appInfos":[
|
||||
{
|
||||
"package_name":"cn.nnbc123.voice",
|
||||
"package_name":"cn.nn.voice",
|
||||
"client":{
|
||||
"app_id":"102953045"
|
||||
},
|
||||
"app_info":{
|
||||
"package_name":"cn.nnbc123.voice",
|
||||
"package_name":"cn.nn.voice",
|
||||
"app_id":"102953045"
|
||||
},
|
||||
"oauth_client":{
|
||||
|
@@ -1,16 +1,16 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'com.huawei.agconnect'
|
||||
apply from: '../mob.gradle'
|
||||
apply plugin: 'android-junk-code'
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
apply plugin: 'com.google.firebase.crashlytics'
|
||||
|
||||
android {
|
||||
compileSdkVersion COMPILE_SDK_VERSION.toInteger()
|
||||
|
||||
defaultConfig {
|
||||
applicationId "cn.nnbc123.voice"
|
||||
applicationId "cn.nn.voice"
|
||||
minSdkVersion MIN_SDK_VERSION.toInteger()
|
||||
targetSdkVersion TARGET_SDK_VERSION.toInteger()
|
||||
versionCode Integer.valueOf(version_code)
|
||||
@@ -153,6 +153,7 @@ android {
|
||||
shrinkResources true
|
||||
signingConfig signingConfigs.v2
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
manifestPlaceholders = [CRASHLYTICS_COLLECTION_ENABLED: "true"]
|
||||
}
|
||||
|
||||
debug {
|
||||
@@ -165,6 +166,10 @@ android {
|
||||
shrinkResources false
|
||||
signingConfig signingConfigs.v2
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
firebaseCrashlytics {
|
||||
mappingFileUploadEnabled false
|
||||
}
|
||||
manifestPlaceholders = [CRASHLYTICS_COLLECTION_ENABLED: "false"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,41 +190,13 @@ android {
|
||||
abiFilters 'armeabi-v7a', 'arm64-v8a'
|
||||
}
|
||||
}
|
||||
google {
|
||||
}
|
||||
mlq {
|
||||
ndk {
|
||||
abiFilters 'x86'
|
||||
}
|
||||
}
|
||||
yingyongbao {
|
||||
ndk {
|
||||
abiFilters 'armeabi-v7a'
|
||||
}
|
||||
}
|
||||
vivo {
|
||||
ndk {
|
||||
abiFilters 'arm64-v8a'
|
||||
}
|
||||
}
|
||||
oppo {
|
||||
ndk {
|
||||
abiFilters 'arm64-v8a'
|
||||
}
|
||||
}
|
||||
xiaomi {
|
||||
ndk {
|
||||
abiFilters 'arm64-v8a'
|
||||
}
|
||||
}
|
||||
huawei {
|
||||
ndk {
|
||||
abiFilters 'arm64-v8a'
|
||||
}
|
||||
}
|
||||
kuaishou_01 {
|
||||
ndk {
|
||||
abiFilters 'armeabi-v7a', 'arm64-v8a'
|
||||
}
|
||||
}
|
||||
}
|
||||
productFlavors.all { flavor ->
|
||||
flavor.manifestPlaceholders = [
|
||||
|
39
app/google-services.json
Normal file
39
app/google-services.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "1111",
|
||||
"project_id": "-",
|
||||
"storage_bucket": "-.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1::android:",
|
||||
"android_client_info": {
|
||||
"package_name": "cn.nn.voice"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "-.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "-4"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "-.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
2
app/proguard-rules.pro
vendored
2
app/proguard-rules.pro
vendored
@@ -461,3 +461,5 @@
|
||||
-keep class androidx.recyclerview.widget.** { *; }
|
||||
-keep class androidx.viewpager2.widget.** { *; }
|
||||
-keep class io.agora.**{*;}
|
||||
-keepattributes SourceFile,LineNumberTable # Keep file names and line numbers.
|
||||
-keep public class * extends java.lang.Exception # Optional: Keep custom exceptions.
|
@@ -87,6 +87,9 @@
|
||||
android:theme="@style/MyMaterialTheme"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:replace="android:name,android:allowBackup">
|
||||
<meta-data
|
||||
android:name="firebase_crashlytics_collection_enabled"
|
||||
android:value="${CRASHLYTICS_COLLECTION_ENABLED}" />
|
||||
<!-- 多渠道 -->
|
||||
<meta-data
|
||||
android:name="CHANNEL"
|
||||
|
@@ -122,6 +122,9 @@ class PrivilegeCardEngine(
|
||||
loopQueue()
|
||||
}
|
||||
}
|
||||
else ->{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,7 @@ import android.content.ContextWrapper
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.widget.ImageView
|
||||
import androidx.annotation.Dimension
|
||||
import androidx.annotation.Dimension.DP
|
||||
import androidx.annotation.Dimension.Companion.DP
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.6.21'
|
||||
ext.kotlin_version = '1.8.22'
|
||||
|
||||
println "\n\n\n"
|
||||
println '当前选择版本 Version Name:'+ version_name
|
||||
@@ -28,6 +28,8 @@ buildscript {
|
||||
// classpath 'com.tencent.vasdolly:plugin:3.0.3'
|
||||
classpath "com.mob.sdk:MobSDK:2018.0319.1724"
|
||||
classpath "com.github.qq549631030:android-junk-code:1.0.7"
|
||||
classpath 'com.google.gms:google-services:4.3.15'
|
||||
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.5'
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -100,6 +100,10 @@ dependencies {
|
||||
|
||||
api 'com.alipay.sdk:alipaysdk-android:+@aar'
|
||||
|
||||
//fireBase
|
||||
implementation platform('com.google.firebase:firebase-bom:32.3.1')
|
||||
implementation 'com.google.firebase:firebase-crashlytics-ktx'
|
||||
implementation 'com.google.firebase:firebase-analytics-ktx'
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@@ -1,4 +1,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.nnbc123.core" >
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
</manifest>
|
||||
|
@@ -0,0 +1,54 @@
|
||||
package com.nnbc123.core.statistic
|
||||
|
||||
import android.os.Bundle
|
||||
import com.google.firebase.analytics.FirebaseAnalytics
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import com.nnbc123.core.auth.AuthModel
|
||||
import com.nnbc123.library.utils.AppMetaDataUtil
|
||||
import com.nnbc123.library.utils.config.BasicConfig
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/1/12 10:53
|
||||
* Desc:
|
||||
**/
|
||||
class FirebaseStatistic {
|
||||
|
||||
private var firebaseAnalytics: FirebaseAnalytics? = null
|
||||
|
||||
init {
|
||||
firebaseAnalytics = FirebaseAnalytics.getInstance(BasicConfig.INSTANCE.appContext)
|
||||
resetUserInfo()
|
||||
}
|
||||
|
||||
private fun resetUserInfo() {
|
||||
val uid = AuthModel.get().currentUid
|
||||
val uidStr = uid.toString()
|
||||
val params = Bundle()
|
||||
params.putLong("uid", uid)
|
||||
params.putString("channel", AppMetaDataUtil.getChannelID())
|
||||
firebaseAnalytics?.setUserId(uidStr)
|
||||
firebaseAnalytics?.setDefaultEventParameters(params)
|
||||
val firebaseCrashlytics = FirebaseCrashlytics.getInstance()
|
||||
firebaseCrashlytics.setUserId(uidStr)
|
||||
firebaseCrashlytics.setCustomKey("channel", AppMetaDataUtil.getChannelID())
|
||||
}
|
||||
|
||||
fun onLoginEvent() {
|
||||
resetUserInfo()
|
||||
}
|
||||
|
||||
fun onLogoutEvent() {
|
||||
resetUserInfo()
|
||||
}
|
||||
|
||||
fun logEvent(eventId: String, params: Map<String, String>?) {
|
||||
var bundle: Bundle? = null
|
||||
if (params != null) {
|
||||
bundle = Bundle()
|
||||
params.forEach {
|
||||
bundle.putString(it.key, it.value)
|
||||
}
|
||||
}
|
||||
firebaseAnalytics?.logEvent(eventId, bundle)
|
||||
}
|
||||
}
|
@@ -5,7 +5,12 @@ import android.content.Context;
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.nnbc123.library.utils.config.BasicConfig;
|
||||
import com.nnbc123.core.auth.event.LoginEvent;
|
||||
import com.nnbc123.core.auth.event.LogoutEvent;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -17,15 +22,14 @@ import java.util.Map;
|
||||
*/
|
||||
@Keep
|
||||
public class StatisticManager {
|
||||
private static final String TAG = "erban_log";
|
||||
|
||||
private volatile static StatisticManager mInstance;
|
||||
|
||||
private final StatisticModel mStatisticModel;
|
||||
|
||||
private FirebaseStatistic firebaseStatistic;
|
||||
|
||||
private StatisticManager() {
|
||||
mStatisticModel = new StatisticModel();
|
||||
firebaseStatistic = new FirebaseStatistic();
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
public static StatisticManager Instance() {
|
||||
@@ -39,13 +43,21 @@ public class StatisticManager {
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLoginEvent(LoginEvent event) {
|
||||
firebaseStatistic.onLoginEvent();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLogoutEvent(LogoutEvent event) {
|
||||
firebaseStatistic.onLogoutEvent();
|
||||
}
|
||||
|
||||
/*********************************************统计方法 begin *********************************************/
|
||||
public void onPause(Context context) {
|
||||
mStatisticModel.onPause(context);
|
||||
}
|
||||
|
||||
public void onResume(Context context) {
|
||||
mStatisticModel.onResume(context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +67,6 @@ public class StatisticManager {
|
||||
* @param pageName 页面名称
|
||||
*/
|
||||
public void onPageStart(Context context, String pageName) {
|
||||
mStatisticModel.onPageStart(context, pageName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,37 +76,32 @@ public class StatisticManager {
|
||||
* @param pageName 页面名称
|
||||
*/
|
||||
public void onPageEnd(Context context, String pageName) {
|
||||
mStatisticModel.onPageEnd(context, pageName);
|
||||
}
|
||||
|
||||
|
||||
public void onEvent(String eventId) {
|
||||
LogUtil.e(eventId);
|
||||
mStatisticModel.onEvent(BasicConfig.INSTANCE.getAppContext(), eventId, null, null);
|
||||
firebaseStatistic.logEvent(eventId, null);
|
||||
}
|
||||
|
||||
public void onEvent(String eventId, String eventLabel) {
|
||||
LogUtil.e(eventId);
|
||||
mStatisticModel.onEvent(BasicConfig.INSTANCE.getAppContext(), eventId, eventLabel, null);
|
||||
firebaseStatistic.logEvent(eventId, null);
|
||||
}
|
||||
|
||||
public void onEvent(String eventId, String eventLabel, Map<String, String> arguments) {
|
||||
LogUtil.e(eventId);
|
||||
mStatisticModel.onEvent(BasicConfig.INSTANCE.getAppContext(), eventId, eventLabel, arguments);
|
||||
firebaseStatistic.logEvent(eventId, arguments);
|
||||
}
|
||||
|
||||
public void onEvent(Context context, String eventId, String eventLabel, Map<String, String> arguments) {
|
||||
mStatisticModel.onEvent(context, eventId, eventLabel, arguments);
|
||||
firebaseStatistic.logEvent(eventId, arguments);
|
||||
}
|
||||
|
||||
public void onEventStart(Context context, String eventId, String eventLabel) {
|
||||
mStatisticModel.onEventStart(context, eventId, eventLabel);
|
||||
}
|
||||
|
||||
public void onEventEnd(Context context, String eventId, String eventLabel, Map<String, String> arguments) {
|
||||
mStatisticModel.onEventEnd(context, eventId, eventLabel, arguments);
|
||||
}
|
||||
|
||||
|
||||
/*********************************************统计方法 end *********************************************/
|
||||
|
||||
}
|
||||
|
@@ -1,66 +0,0 @@
|
||||
package com.nnbc123.core.statistic;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p> </p>
|
||||
*
|
||||
* @author jiahui
|
||||
* @date 2018/1/4
|
||||
*/
|
||||
@Keep
|
||||
public class StatisticModel {
|
||||
|
||||
void onEventEnd(Context context, String eventId, String eventLabel, Map<String, String> arguments) {
|
||||
MobclickAgent.onPageEnd(eventId);
|
||||
}
|
||||
|
||||
void onEventStart(Context context, String eventId, String eventLabel) {
|
||||
MobclickAgent.onPageStart(eventId);
|
||||
}
|
||||
|
||||
void onEvent(Context context, String eventId, String eventLabel, Map<String, String> arguments) {
|
||||
if (arguments != null) {
|
||||
MobclickAgent.onEvent(context, eventId, arguments);
|
||||
} else if (!TextUtils.isEmpty(eventLabel)) {
|
||||
MobclickAgent.onEvent(context, eventId, eventLabel);
|
||||
} else {
|
||||
MobclickAgent.onEvent(context, eventId);
|
||||
}
|
||||
}
|
||||
|
||||
void onResume(Context context) {
|
||||
MobclickAgent.onResume(context);
|
||||
}
|
||||
|
||||
void onPause(Context context) {
|
||||
MobclickAgent.onPause(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义页面api
|
||||
*
|
||||
* @param context
|
||||
* @param pageName 页面名称
|
||||
*/
|
||||
void onPageStart(Context context, String pageName) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义页面api
|
||||
*
|
||||
* @param context
|
||||
* @param pageName 页面名称
|
||||
*/
|
||||
void onPageEnd(Context context, String pageName) {
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -167,6 +167,10 @@ class ExoPlayer : StyledPlayerView, IPlayer, LifecycleEventObserver {
|
||||
Lifecycle.Event.ON_DESTROY -> {
|
||||
onCleared()
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user