参考官方文档Development tutorial · rovo89/XposedBridge Wiki (github.com)
环境准备
雷电模拟器已经装好Xposed框架
编写模块
- 新建一个空白Android项目
- 配置AndroidManifest.xml
<application>
标签下配置<meta-data android:name="xposedmodule" android:value="true"/> <meta-data android:name="xposeddescription" android:value="xposeddescription"/> <meta-data android:name="xposedminversion" android:value="53"/>
- 配置
app/build.gradle
文件
在相应标签下添加
注:repositories { jcenter(); } dependencies { compileOnly ‘de.robv.android.xposed:api:82‘ compileOnly ‘de.robv.android.xposed:api:82:sources‘ }
compileOnly
已经替代provided
- 新建一个hook类
package com.example.hooktest1; import de.robv.android.xposed.IXposedHookLoadPackage; import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.callbacks.XC_LoadPackage; public class MyHook implements IXposedHookLoadPackage { @Override public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam) throws Throwable { XposedBridge.log("Loaded MMMyapp: " + loadPackageParam.packageName); } }
- 配置
assets/xposed_init
文件
在app/src/main
下新建assets
文件夹,内创建xposed_init
文件
内填入hook类(每行一个)
示例com.example.hooktest1.MyHook
- 生成APK
Build -> Build Bundle(s)/APK(s) -> Build APK(s) 来生成apk - 安装入模拟器
Xposed勾选,重启模拟器 - 查看效果