本文章仅分享在游戏打包中遇到的问题与解决方法
错误分析
先上错误日志
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/bun/miitmdid/interfaces/IIdentifierListener;
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2562)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6161)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:892)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.bun.miitmdid.interfaces.IIdentifierListener" on path: DexPathList[[zip file "/data/app/com.test.game-1/base.apk"],nativeLibraryDirectories=[/data/appcom.test.game-1/lib/arm, /system/fake-libs, /data/app/com.test.game-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2562)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6161)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:892)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)
日志中能看出是无法找到com.bun.miitmdid.interfaces.IIdentifierListener类,我们看一下APK内com.bun里面文件
渠道包.png
APK中确实不包含这个类甚至是interfaces包,我们打开游戏包看一看
测试母包.png
基本能推断游戏母包的bun文件被渠道文件覆盖了,我们要做的仅仅是把两个版本的文件添加到进去然后再打包既可完成。
但是这样依旧会出错
合并方案
由于27版本的oaid与25版本的oaid中com.bun.miitmdid.core.MdidSdkHelper是同时存在的,覆盖后会导致27或者25版本无法正常初始化导致错误抛出,所以我们把core里面的MdidSdkHelper移动到自己新建的cores文件夹中,然后全局查找smali文件内容替换路径,这样打包便能正常初始化25与27版本的oaid。
网友评论