近些日子,受到高人指點(diǎn)熄浓,突然想入坑學(xué)習(xí)學(xué)習(xí) Xposed 于是乎在網(wǎng)上搜集一些入門例子 其中遇到了些小問題 記錄下來 可能幫助同樣遇到此問題的你
https://www.52pojie.cn/thread-690818-1-1.html
http://www.freebuf.com/articles/web/156944.html
http://www.reibang.com/p/8fbf9e88eb54 (@WrBug)
https://www.52pojie.cn/thread-533120-1-1.html
深受啟發(fā)省撑,于是乎想自己按照教程來寫寫。同時(shí)感謝以上幾位大佬的教程
首先我安裝了比較新的XposedInstaller_3.1.5.apk
安裝成功后如下圖
接下來開始敲代碼了 美滋滋(皮一下很開心) 上一張整個(gè)工程的圖
以下是Test和Tutorial的代碼
package com.zed.xposed.demo;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
/**
* Created by zed on 2018/4/11.
*/
public class Test implements IXposedHookLoadPackage {
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
XposedBridge.log("Loaded Test app: " + lpparam.packageName);
}
}
因?yàn)槲以趯W(xué)習(xí)kotlin 所以后面應(yīng)該會有兩個(gè)版本代碼
package com.zed.xposed.demo
/**
* Created by zed on 2018/4/11.
*/
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
open class Tutorial : IXposedHookLoadPackage {
override fun handleLoadPackage(lpparam: LoadPackageParam?) {
XposedBridge.log("Loaded app: " + lpparam?.packageName);
}
}
新建xposed_init的文本文檔 里面只用聲明下你的兩個(gè)類文件 包名+類名
com.zed.xposed.demo.Tutorial
com.zed.xposed.demo.Test
最后是清單文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zed.xposed.demo">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="xposedmodule"
android:value="true" />
<meta-data
android:name="xposeddescription"
android:value="Hook log test" />
<meta-data
android:name="xposedminversion"
android:value="82" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
build.gradle配置
dependencies {
compile 'de.robv.android.xposed:api:82'
compile 'de.robv.android.xposed:api:82:sources'
}
一切都在美好的方向了 build一下安裝 重啟后 打開了之后
?肥败?趾浅? What Fuck (me is 逗比)
Android Studio (Gradle-based)
The Xposed Framework API is published on Bintray/jCenter: https://bintray.com/rovo89/de.robv.android.xposed/api
That makes it easy to reference it by simply adding a Gradle dependency in your app/build.gradle
:
repositories {
jcenter();
}
dependencies {
provided 'de.robv.android.xposed:api:82'
}
It is very important that you use provided
instead of compile
! The latter would include the API classes in your APK, which can cause issues especially on Android 4.x. Using provided
just makes the API classes usable from your module, but there will only be references to them in the APK. The actual implementation will be provided when the user installs the Xposed Framework.
In most cases, the repositories
block already exists, and there are usually some dependencies already. In that case, you just need to add the provided
line to the existing dependencies
block.
There is also documentation available for the API (see below). Unfortunately, I didn't find any good way to enable automatic download of the API sources, except using both of these lines:
provided 'de.robv.android.xposed:api:82'
provided 'de.robv.android.xposed:api:82:sources'
The way Gradle caches the files, Android Studio will set up the second jar as source for the first one automatically. Better recommendations are welcome!
Please make sure to disable Instant Run (File -> Settings -> Build, Execution, Deployment -> Instant Run
), otherwise your classes aren't included directly in the APK, but loaded via a stub application which Xposed can't handle.
趕緊把手捂住臉 偷偷修改下app/build.gradle下的依賴引用
還有個(gè)錯(cuò)誤情況就是 你只引用了
compile 'de.robv.android.xposed:api:82'
也會出現(xiàn)一個(gè)錯(cuò)誤 日志內(nèi)容如下
04-11 22:36:23.839 I/Xposed ( 3386): -----------------
04-11 22:36:23.839 I/Xposed ( 3386): Starting Xposed version 89, compiled for SDK 21
04-11 22:36:23.839 I/Xposed ( 3386): Device: Custom Phone - 5.0.0 - API 21 - 768x1280 (unknown), Android version 5.0 (SDK 21)
04-11 22:36:23.839 I/Xposed ( 3386): ROM: vbox86p-userdebug 5.0 LRX21M 17 test-keys
04-11 22:36:23.839 I/Xposed ( 3386): Build fingerprint: generic/vbox86p/vbox86p:5.0/LRX21M/17:userdebug/test-keys
04-11 22:36:23.839 I/Xposed ( 3386): Platform: x86, 32-bit binary, system server: yes
04-11 22:36:23.839 I/Xposed ( 3386): SELinux enabled: no, enforcing: no
04-11 22:36:26.060 I/Xposed ( 3386): -----------------
04-11 22:36:26.060 I/Xposed ( 3386): Added Xposed (/system/framework/XposedBridge.jar) to CLASSPATH
04-11 22:36:26.084 I/Xposed ( 3386): Detected ART runtime
04-11 22:36:26.089 I/Xposed ( 3386): Found Xposed class 'de/robv/android/xposed/XposedBridge', now initializing
04-11 22:36:26.158 I/Xposed ( 3386): Loading modules from /data/app/com.zed.xposed.demo-1/base.apk
04-11 22:36:26.158 E/Xposed ( 3386): Cannot load module:
04-11 22:36:26.158 E/Xposed ( 3386): The Xposed API classes are compiled into the module's APK.
04-11 22:36:26.158 E/Xposed ( 3386): This may cause strange issues and must be fixed by the module developer.
04-11 22:36:26.158 E/Xposed ( 3386): For details, see: http://api.xposed.info/using.html
說了那么多廢話了 總結(jié)一下就是 如果你沒有正常出現(xiàn)以下界面愕提,請多多注意是不是你的依賴jar沒有配置好 不要急
以上是一個(gè)入門級 新手的入坑記錄