Tencent / Shadow

零反射全动态Android插件框架
BSD 3-Clause "New" or "Revised" License
7.43k stars 1.3k forks source link

插件引入appsflyer Sdk 报错 #1236

Closed luosu1025769919 closed 5 months ago

luosu1025769919 commented 1 year ago

当我在插件中添加 implementation 'com.appsflyer:af-android-sdk:6.9.2' 并且在MainActivity 对AppsFlyerLib 进行初始化时,
AppsFlyerLib.getInstance().init("XXX", conversionListener, getApplicationContext()); AppsFlyerLib.getInstance().setDebugLog(true); AppsFlyerLib.getInstance().start(MainActivity.this);

代码开始报错: FATAL EXCEPTION: pool-4-thread-1 Process: com.tencent.shadow.sample.host:plugin, PID: 8728 java.lang.NoSuchFieldError: No instance field valueOf of type Landroid/app/Application; in class Lcom/appsflyer/internal/AFa1tSDK; or its superclasses (declaration of 'com.appsflyer.internal.AFa1tSDK' appears in /data/user/0/com.tencent.shadow.sample.host/files/ShadowPluginManager/UnpackedPlugin/sample-manager/e83f661ce1e3562cedab9c10f3deda7d/plugin-debug.zip/plugin-app-plugin-debug.apk) at com.appsflyer.internal.AFa1mSDK.AFKeystoreWrapper(:2058) at java.lang.reflect.Method.invoke(Native Method) at com.appsflyer.internal.AFc1uSDK.AFKeystoreWrapper(:142) at com.appsflyer.internal.AFd1uSDK.AFInAppEventType(:65) at com.appsflyer.internal.AFc1aSDK.valueOf(:113) at com.appsflyer.internal.AFc1mSDK$3.run(:109) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) at java.lang.Thread.run(Thread.java:1012)

luosu1025769919 commented 1 year ago

我是用的是maven目录下里提供的plugin-project plugin-host 来测试的,AppsFlyer打点sdk引入后初始化就报错了

shifujun commented 1 year ago

插件中的Application类型会被修改为ShadowApplication类型。所有class中的类型都会被修改,但so或者反射用的字符串中的不会被修改。动态加载的dex显然也不会被插件工程修改。所以这些场景无法支持。