WindySha / Xpatch

This is a tool to repackage apk file, then the apk can load any xposed modules installed in the device. It is another way to hook an app without root device.
Apache License 2.0
2.54k stars 388 forks source link

一些问题。。。 #60

Closed naloder closed 4 years ago

naloder commented 4 years ago

是否可以分离一下classloader,改善对64位应用的兼容性(64位应用在打包使用插件功能时候会导致闪退)

闪退导致的关键log(?) 07-13 15:07:16.500 W/art (14614): Incompatible structural change detected: Structural change of android.support.v7.widget.RecyclerView$d is hazardous (/data/user/0/tv.danmaku.bili/app_xposed_plugin_dex/base.dex at compile time, /data/app/tv.danmaku.bili-1/oat/arm64/base.odex at runtime): Virtual method count off: 3 vs 1 07-13 15:07:16.500 W/art (14614): Landroid/support/v7/widget/RecyclerView$d; (Compile time): 07-13 15:07:16.500 W/art (14614): Static fields: 07-13 15:07:16.500 W/art (14614): Instance fields: 07-13 15:07:16.500 W/art (14614): Landroid/support/v7/widget/RecyclerView$e; a 07-13 15:07:16.501 W/art (14614): Z b 07-13 15:07:16.501 W/art (14614): Direct methods: 07-13 15:07:16.501 W/art (14614): ()V 07-13 15:07:16.501 W/art (14614): Virtual methods: 07-13 15:07:16.501 W/art (14614): a()I 07-13 15:07:16.501 W/art (14614): a(Landroid/view/ViewGroup;I)Landroid/support/v7/widget/RecyclerView$x; 07-13 15:07:16.501 W/art (14614): a(Landroid/support/v7/widget/RecyclerView$x;I)V 07-13 15:07:16.501 W/art (14614): Landroid/support/v7/widget/RecyclerView$d; (Runtime): 07-13 15:07:16.501 W/art (14614): Static fields: 07-13 15:07:16.501 W/art (14614): Instance fields: 07-13 15:07:16.501 W/art (14614): Direct methods: 07-13 15:07:16.501 W/art (14614): Virtual methods: 07-13 15:07:16.501 W/art (14614): onGetChildDrawingOrder(II)I 07-13 15:07:16.501 W/art (14614):

yujincheng08 commented 4 years ago

目前把模块打包到应用里面之后,如果应用和模块有相同的依赖,并且依赖版本不一致时候,就会报这个Incompatible structural change detected(混淆之后出现类名字冲突也有可能)。不知道是不是因为模块和应用共用一个classloader而导致的冲突。

WindySha commented 4 years ago

加载插件的classloader是这个:

        ClassLoader mcl = new DexClassLoader(moduleApkPath, moduleOdexDir, moduleLibPath, appClassLoader);

会优先使用宿主app的classloader来加载插件中的类,加载不到才用插件的classloader。 假如插件用的类很多,而且跟宿主版本不一致,会出一些问题。 不光是classloader, context, AssetManager, Resource等等都会出些问题。 不过,处理这些问题,并不需要更改宿主的加载整个框架。只用在自己的插件里使用一些特殊手段做兼容即可。 至于,怎么做,那就说来话长了,自行琢磨吧。