Xposed 模組開發一 環境搭建
阿新 • • 發佈:2021-07-12
參考官方文件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 {
provided 'de.robv.android.xposed:api:82'
provided 'de.robv.android.xposed:api:82:sources'
}
- 新建一個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勾選,重啟模擬器 - 檢視效果