最新Android-Studio搭建Xposed-Hook环境

简介: 最新Android-Studio搭建Xposed-Hook环境,有坑,请注意

新建AS工程

导入XposedBrigeApi.jar

XposeAPI
官方帮助文档


Alt text

右键Add As Library...
Build -> Edit Libraries and Dependencies...
一定要改成compile olny 不是 Provided

Alt text

新建assets/xposed_init


Alt text

写入你的包名.类名
com.geek.deelmind.xposehook.Hook

新建Hook类


Alt text

Hook类源码
Xpose []
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.geek.deelmind.xposehook;

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;

public class Hook implements IXposedHookLoadPackage {
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
if (!lpparam.packageName.equals("com.example.administrator.test"))
return;

findAndHookMethod("com.example.administrator.test.MainActivity", lpparam.classLoader, "DeeLMind", new XC_MethodHook() {
@Override
protected void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {

}

protected void beforeHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
param.setResult ("Dragon");
}
});
}
}

修改build.gradle


Alt text

最重要一步


Alt text


Alt text


一定要取消打勾,不然直接点击运行是失败的,只能build后手动安装,为了方便才做修改
一定要取消打勾,不然直接点击运行是失败的,只能build后手动安装,为了方便才做修改
一定要取消打勾,不然直接点击运行是失败的,只能build后手动安装,为了方便才做修改

切记,切记

源码下载

xpose模块
工程源码

×

谢谢支持

扫码支持
扫码打赏

打开支付宝扫一扫,即可进行扫码打赏哦

文章目录
  1. 1. 新建AS工程
  2. 2. 导入XposedBrigeApi.jar
  3. 3. 新建assets/xposed_init
  4. 4. 新建Hook类
  5. 5. 修改build.gradle
  6. 6. 最重要一步
  7. 7. 源码下载
,