Xposed 入坑篇

近些日子,受到高人指點(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
安裝成功后如下圖

device-2018-04-12-101001.png

接下來開始敲代碼了 美滋滋(皮一下很開心) 上一張整個(gè)工程的圖

QQ截圖20180412102021.png

以下是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一下安裝 重啟后 打開了之后

QQ截圖20180412102953.png

?肥败?趾浅? 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沒有配置好 不要急


QQ截圖20180412104010.png

以上是一個(gè)入門級 新手的入坑記錄

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市潮孽,隨后出現(xiàn)的幾起案子揪荣,更是在濱河造成了極大的恐慌,老刑警劉巖往史,帶你破解...
    沈念sama閱讀 211,817評論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件仗颈,死亡現(xiàn)場離奇詭異,居然都是意外死亡椎例,警方通過查閱死者的電腦和手機(jī)挨决,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,329評論 3 385
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來订歪,“玉大人脖祈,你說我怎么就攤上這事∷⒔” “怎么了盖高?”我有些...
    開封第一講書人閱讀 157,354評論 0 348
  • 文/不壞的土叔 我叫張陵,是天一觀的道長眼虱。 經(jīng)常有香客問我喻奥,道長,這世上最難降的妖魔是什么捏悬? 我笑而不...
    開封第一講書人閱讀 56,498評論 1 284
  • 正文 為了忘掉前任撞蚕,我火速辦了婚禮,結(jié)果婚禮上过牙,老公的妹妹穿的比我還像新娘甥厦。我一直安慰自己,他們只是感情好寇钉,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,600評論 6 386
  • 文/花漫 我一把揭開白布刀疙。 她就那樣靜靜地躺著,像睡著了一般扫倡。 火紅的嫁衣襯著肌膚如雪谦秧。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,829評論 1 290
  • 那天镊辕,我揣著相機(jī)與錄音,去河邊找鬼蚁袭。 笑死征懈,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的揩悄。 我是一名探鬼主播卖哎,決...
    沈念sama閱讀 38,979評論 3 408
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼亏娜!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起它掂,我...
    開封第一講書人閱讀 37,722評論 0 266
  • 序言:老撾萬榮一對情侶失蹤虐秋,失蹤者是張志新(化名)和其女友劉穎垃沦,沒想到半個(gè)月后肢簿,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,189評論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡桩引,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,519評論 2 327
  • 正文 我和宋清朗相戀三年阐污,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了笛辟。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片序苏。...
    茶點(diǎn)故事閱讀 38,654評論 1 340
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡忱详,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出监透,到底是詐尸還是另有隱情航唆,我是刑警寧澤,帶...
    沈念sama閱讀 34,329評論 4 330
  • 正文 年R本政府宣布退腥,位于F島的核電站再榄,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏嗅蔬。R本人自食惡果不足惜窝革,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,940評論 3 313
  • 文/蒙蒙 一虐译、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧侮攀,春花似錦厢拭、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,762評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽寨闹。三九已至,卻和暖如春沈善,著一層夾襖步出監(jiān)牢的瞬間椭蹄,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,993評論 1 266
  • 我被黑心中介騙來泰國打工罩润, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留哨啃,地道東北人写妥。 一個(gè)月前我還...
    沈念sama閱讀 46,382評論 2 360
  • 正文 我出身青樓珍特,卻偏偏與公主長得像,于是被迫代替她去往敵國和親扎筒。 傳聞我的和親對象是個(gè)殘疾皇子嗜桌,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,543評論 2 349

推薦閱讀更多精彩內(nèi)容