Channel/Android/gtgame/debug/libs/library-debug-gtgame.aarBinary files differ
Channel/Android/gtgame/deps.gradle
@@ -3,3 +3,7 @@ implementation "com.android.billingclient:billing:2.0.3" implementation 'com.facebook.android:facebook-login:[5,6)' } dependencies { implementation 'com.appsflyer:af-android-sdk:5.0.0' implementation 'com.android.installreferrer:installreferrer:2.1' } Channel/Android/gtgame/release/libs/library-release-gtgame.aarBinary files differ
SdkProject/build.gradle
@@ -8,7 +8,7 @@ dependencies { classpath "com.android.tools.build:gradle:4.1.1" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files // in the individual module deps.gradle files } } SdkProject/channel/GTGame/java/com/secondworld/sdk/MySdkMgr.java
@@ -3,6 +3,7 @@ import android.app.Activity; import android.widget.Toast; import com.appsflyer.AFInAppEventType; import com.cy.yyjia.sdk.center.SdkManager; import com.cy.yyjia.sdk.listener.ChangePasswordListener; import com.cy.yyjia.sdk.listener.ExitGameListener; SdkProject/channel/GTGame/java/com/secondworld/sdk/command/CmdPayFinished.java
@@ -12,6 +12,5 @@ @Override public void process(JSONObject json) throws Exception { } } SdkProject/channel/gtgame/config.properties
@@ -1 +1 @@ PLUGINS= PLUGINS=appsflyer SdkProject/library/build.gradle
@@ -25,6 +25,7 @@ //插件脚本 plugins.each { applyGradle("${rootPath}/plugins/${it}/build") applyGradle("${rootPath}/plugins/${it}/deps") } //渠道需要覆盖主目录的java文件 @@ -112,12 +113,6 @@ outputFileName = "library-${buildType.name}-${CHANNEL_NAME}.aar" } } //拷贝渠道的第三方依赖库脚本 task copyDepsGradle(type: Copy) { from "${channelPath}/" include "deps.gradle" into "${outPutPath}\\${CHANNEL_NAME}\\" } //拷贝清单文件 task copyDebugManifest(type: Copy) { @@ -140,18 +135,47 @@ into "${outPutPath}\\${CHANNEL_NAME}\\debug\\libs\\" } //执行打包任务以及拷贝到外部 task assembleAndCopySdk(type: Copy) { delete "${outPutPath}\\${CHANNEL_NAME}" dependsOn 'assembleMerger' // dependsOn copyManifest dependsOn copyDebugSdk dependsOn copyDepsGradle task copyReleaseSdk(type: Copy) { from "build/outputs/aar/" include "library-release-${CHANNEL_NAME}.aar" into "${outPutPath}\\${CHANNEL_NAME}\\release\\libs\\" } task deleteSdk() { delete "${outPutPath}\\${CHANNEL_NAME}" } //执行打包任务以及拷贝到外部 task assembleAndCopySdk() { dependsOn 'assembleMerger' dependsOn deleteSdk dependsOn copyDebugSdk dependsOn copyReleaseSdk tasks.findByName('deleteSdk').mustRunAfter 'assembleMerger' tasks.findByName('copyDebugSdk').mustRunAfter 'deleteSdk' tasks.findByName('copyReleaseSdk').mustRunAfter 'deleteSdk' //导出所有外部引用 String content = "" def deps = file("${channelPath}\\deps.gradle") deps.eachLine { line -> if (line != null) content += line + "\n" } plugins.each { deps = file("${rootPath}/plugins/${it}/deps.gradle") deps.eachLine { line -> if (line != null) content += line + "\n" } } def dir = new File("${outPutPath}\\${CHANNEL_NAME}") def libraries = new File("${outPutPath}\\${CHANNEL_NAME}\\deps.gradle") dir.mkdir() if (!libraries.exists()) libraries.createNewFile() libraries.text = content } dependencies { @@ -163,7 +187,7 @@ // implementation 'com.github.pqpo:Log4a:1.4.2@aar' implementation fileTree(dir:"../channel/${CHANNEL_NAME}/libs/", include: ['*.jar']) implementation fileTree(dir: "../channel/${CHANNEL_NAME}/libs/", include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'], exclude: ['unity-classes.jar']) compileOnly files('libs/unity-classes.jar') } SdkProject/library/src/main/java/com/secondworld/sdk/utils/CodeA2U.java
@@ -53,4 +53,6 @@ public static final int PlatformPayFail = 19; public static final int PlatformPayCancel = 20; public static final int PlatformRegisterOk = 21; } SdkProject/library/src/main/java/com/secondworld/sdk/utils/CodeU2A.java
@@ -73,4 +73,10 @@ int RoleLevelUp = 108; int TencentLogin = 109; /** * 插件 */ public static final int AFTrackEvent=1000; //appsflyer统计游戏事件 } SdkProject/library/src/main/java/com/secondworld/sdk/utils/Util.java
@@ -2,8 +2,15 @@ import android.text.TextUtils; import org.json.JSONObject; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; public class Util { SdkProject/plugins/appsflyer/AndroidManifest.xml
New file @@ -0,0 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.secondworld.sdk"> <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" /> <!-- Optional : --> <!-- <uses-permission android:name="android.permission.READ_PHONE_STATE" />--> </manifest> SdkProject/plugins/appsflyer/deps.gradle
New file @@ -0,0 +1,4 @@ dependencies { implementation 'com.appsflyer:af-android-sdk:5.0.0' implementation 'com.android.installreferrer:installreferrer:2.1' } SdkProject/plugins/appsflyer/java/com/secondworld/sdk/AppsFlyerUtil.java
New file @@ -0,0 +1,55 @@ package com.secondworld.sdk; import com.appsflyer.AppsFlyerConversionListener; import com.appsflyer.AppsFlyerLib; import com.secondworld.sdk.utils.LogUtil; import java.util.HashMap; import java.util.Map; public class AppsFlyerUtil { private static final String AF_DEV_KEY = "qrdZGj123456789"; public static void init() { AppsFlyerConversionListener conversionListener = new AppsFlyerConversionListener() { @Override public void onConversionDataSuccess(Map<String, Object> conversionData) { for (String attrName : conversionData.keySet()) { LogUtil.debug("AppsFlyerMgr", "attribute: " + attrName + " = " + conversionData.get(attrName)); } } @Override public void onConversionDataFail(String errorMessage) { LogUtil.debug("AppsFlyerMgr", "error getting conversion data: " + errorMessage); } @Override public void onAppOpenAttribution(Map<String, String> conversionData) { for (String attrName : conversionData.keySet()) { LogUtil.debug("AppsFlyerMgr", "attribute: " + attrName + " = " + conversionData.get(attrName)); } } @Override public void onAttributionFailure(String errorMessage) { LogUtil.debug("AppsFlyerMgr", "error onAttributionFailure : " + errorMessage); } }; AppsFlyerLib.getInstance().init(AF_DEV_KEY, conversionListener, GameApp.I); AppsFlyerLib.getInstance().startTracking(GameApp.I); } //统计事件 public static void trackEvent(String eventName, Map<String, Object> eventValues) { if (eventValues == null) eventValues = new HashMap<>(); AppsFlyerLib.getInstance().trackEvent(GameApp.I, eventName, eventValues); } } SdkProject/plugins/appsflyer/java/com/secondworld/sdk/command/CmdAFTrackEvent.java
New file @@ -0,0 +1,33 @@ package com.secondworld.sdk.command; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import com.secondworld.sdk.AppsFlyerUtil; import com.secondworld.sdk.utils.CodeU2A; import org.json.JSONObject; import java.util.Map; public class CmdAFTrackEvent implements ICommand { @Override public int getCode() { return CodeU2A.AFTrackEvent; } @Override public void process(JSONObject json) throws Exception { String eventName = json.getString("eventName"); if(json.has("eventValues")){ JSONObject values = json.getJSONObject("eventValues"); GsonBuilder gb = new GsonBuilder(); Gson g = gb.create(); Map<String, Object> map = g.fromJson(values.toString(), new TypeToken<Map<String, Object>>() {}.getType()); AppsFlyerUtil.trackEvent(eventName, map); }else { AppsFlyerUtil.trackEvent(eventName, null); } } }