Commit 7251408d authored by mengcuiguang's avatar mengcuiguang

接入引用sdk

parent dcbc382b
......@@ -10,8 +10,8 @@ android {
applicationId "com.duben.happyplayletu"
minSdkVersion rootProject.ext.androidMinSdkVersion
targetSdkVersion rootProject.ext.androidTargetSdkVersion
versionCode 724
versionName "7.2.4"
versionCode 725
versionName "7.2.5"
flavorDimensions "default"
// dex突破65535的限制
......@@ -223,16 +223,19 @@ dependencies {
// 穿山甲聚合 接入【穿山甲、快手】
implementation "com.pangle.cn:mediation-sdk:6.4.1.5"
// 穿山甲Applog 上报组件(必须)
implementation 'com.bytedance.applog:RangersAppLog-Lite-cn:6.16.3'
// 穿山甲商业化转化组件(必须)
implementation 'com.bytedance.ads:AppConvert:1.3.0.5'
// // 穿山甲Applog 上报组件(必须)
// implementation 'com.bytedance.applog:RangersAppLog-Lite-cn:6.16.3'
// // 穿山甲商业化转化组件(必须)
// implementation 'com.bytedance.ads:AppConvert:1.3.0.5'
//埋点开发工具,DevTools是 Debug 环境下辅助开发者或测试人员进行应用内埋点验证和 SDK 接入问题排查的组件。请使用 debug 依赖,建议仅在 debug 下做调试
// debugImplementation 'com.bytedance.applog:RangersAppLog-DevTools:3.3.4'
// 腾讯播放器
implementation "com.tencent.liteav:LiteAVSDK_Player:11.3.0.13176"
// 引力引擎
implementation "cn.gravity.android:GravityEngineSDK:${LATEST_VERSION}"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
......
......@@ -11,7 +11,7 @@ import com.downloader.PRDownloader;
import com.downloader.PRDownloaderConfig;
import com.duben.happyplayletu.ad.TTAdManagerHolder;
import com.duben.happyplayletu.common.Constant;
import com.duben.happyplayletu.manager.CsjAppLogManager;
import com.duben.happyplayletu.manager.GravityEngineManager;
import com.duben.happyplayletu.manager.TXCSDKService;
import com.duben.happyplayletu.manager.TalkingDataManager;
import com.duben.happyplayletu.net.LoanService;
......@@ -82,7 +82,8 @@ public class MintsApplication extends MultiDexApplication {
TXCSDKService.init(this);
CsjAppLogManager.INSTANCE.init(this);
// CsjAppLogManager.INSTANCE.init(this);
GravityEngineManager.INSTANCE.initGravityEngine(this);
TalkingDataManager.INSTANCE.init(this);
......
package com.duben.happyplayletu.manager
import android.app.Application
import android.text.TextUtils
import cn.gravity.android.GEConfig
import cn.gravity.android.GravityEngineSDK
import cn.gravity.android.GravityEngineSDK.AutoTrackEventType
import cn.gravity.android.InitializeCallback
import com.bytedance.hume.readapk.HumeSDK
import com.duben.happyplayletu.MintsApplication
import com.duben.happyplayletu.utils.DeviceUuidFactory
import com.duben.happyplayletu.utils.LogUtil
import com.duben.happyplayletu.utils.MateUtils.getAppMetaData
import com.duben.library.utils.json.JsonUtil
import org.json.JSONObject
/**
* 描述:引力引擎SDK
* 作者:孟崔广
*/
object GravityEngineManager {
private const val ACCESS_TOKEN = "T9ycxLEd4outVfGnr2cmpFhpuizklKqA"
private const val ENABLE_SYNC_ATTRIBUTION = false
/**
* 初始化
*
* ACCESS_TOKEN : 项目通行证,同启动 SDK 时保持一致
USER_CLIENT_ID : 用户唯一 ID(例如 UID 或者设备 ID)
USER_CLIENT_NAME : 用户昵称
CHANNEL : 用户初始化渠道(例如 xiaomi、huawei 等)
ENABLE_SYNC_ATTRIBUTION : 是否开启同步获取归因信息,具体请参考同步归因
*/
fun initGravityEngine(application: Application) {
try {
// 在主线程中配置并启动SDK
val config: GEConfig = GEConfig.getInstance(application, ACCESS_TOKEN)
// 保存此实例,后续调用方法均需要用到
val gravityEngineSDKInstance = GravityEngineSDK.setupAndStart(config)
gravityEngineSDKInstance.initialize(
ACCESS_TOKEN,
DeviceUuidFactory().deviceUuid.toString(),
DeviceUuidFactory().deviceUuid.toString(),
createChannel(),
object : InitializeCallback {
override fun onFailed(errorMsg: String, initializeBody: JSONObject?) {
LogUtil.d("mcg --> gravityEngineSDKInstance onFailed=" + errorMsg)
}
override fun onSuccess(responseJson: JSONObject?, initializeBody: JSONObject?) {
//responseJson=={"nameValuePairs":{"token":"b10c4ce9-b40b-3f89-b442-237fe82e5efd"}}
LogUtil.d(
"mcg --> gravityEngineSDKInstance onSuccess=" + JsonUtil.toJson(
responseJson
)
)
enableAutoTrack(gravityEngineSDKInstance)
}
},
ENABLE_SYNC_ATTRIBUTION
)
} catch (e: Exception) {
e.printStackTrace()
}
}
/**
* 开启自动采集
*/
fun enableAutoTrack(gravityEngineSDKInstance: GravityEngineSDK) {
val typeList: MutableList<AutoTrackEventType> = ArrayList()
typeList.add(AutoTrackEventType.APP_INSTALL)
typeList.add(AutoTrackEventType.APP_END)
typeList.add(AutoTrackEventType.APP_CRASH)
typeList.add(AutoTrackEventType.APP_VIEW_SCREEN)
typeList.add(AutoTrackEventType.APP_CLICK)
gravityEngineSDKInstance.enableAutoTrack(typeList)
}
private fun createChannel(): String {
var channel = getAppMetaData(MintsApplication.getContext(), "CHANNEL_NAME")
try {
// 穿山甲分包渠道
val ttChannel = HumeSDK.getChannel(MintsApplication.getContext())
if (!TextUtils.isEmpty(ttChannel)) {
// 此处方式不能修改,已和后端约定
channel = channel + "_" + ttChannel
}
} catch (e: Exception) {
e.printStackTrace()
}
return channel
}
}
\ No newline at end of file
......@@ -17,6 +17,13 @@ buildscript {
url "https://artifact.bytedance.com/repository/pangle"
}
// 引力引擎 SDK
maven {
url 'https://nexus.gravity-engine.com/repository/maven-releases/'
}
maven {
url 'https://nexus.gravity-engine.com/repository/maven-snapshots/'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.1'
......@@ -40,6 +47,15 @@ allprojects {
maven {
url "https://artifact.bytedance.com/repository/pangle"
}
// 引力引擎 SDK
maven {
url 'https://nexus.gravity-engine.com/repository/maven-releases/'
}
maven {
url 'https://nexus.gravity-engine.com/repository/maven-snapshots/'
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment