1. 程式人生 > 其它 >Xposed 模組開發一 環境搭建

Xposed 模組開發一 環境搭建

參考官方文件Development tutorial · rovo89/XposedBridge Wiki (github.com)

環境準備

雷電模擬器已經裝好Xposed框架

編寫模組

  1. 新建一個空白Android專案
  2. 配置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"/>
  1. 配置app/build.gradle檔案
    在相應標籤下新增
repositories {
  jcenter();
}
dependencies {
    provided 'de.robv.android.xposed:api:82'
    provided 'de.robv.android.xposed:api:82:sources'
}
  1. 新建一個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);
    }
}

  1. 配置assets/xposed_init檔案
    app/src/main下新建assets資料夾,內建立xposed_init檔案
    內填入hook類(每行一個)
    示例
com.example.hooktest1.MyHook
  1. 生成APK
    Build -> Build Bundle(s)/APK(s) -> Build APK(s) 來生成apk
  2. 安裝入模擬器
    Xposed勾選,重啟模擬器
  3. 檢視效果