Xposed project environment construction

table of Contents

1. Development environment

AndroidStudio 3.5.3 

 Android SDK

Xposed

Two, create a project

Create android development basic project

Add reference

Declare Xposed Module

Write hook code

Declare the entry of the class

Three, compile and test

Compile and package into apk

Installation test


1. Development environment

  • Windows10 system
  • AndroidStudio 3.5.3
  • Android SDK
  • Xposed

AndroidStudio 3.5.3 

Download and install Android Studio, https://developer.android.com/studio

 Android SDK

Download and install Android SDK , if it is already installed, skip this step, https://www.androiddevtools.cn/

Just choose the latest version. Note that there are exe and zip files for downloading. The exe is an installation program. You need to double-click to install it after downloading. It is recommended to download the zip package, after downloading, directly unzip it to the path where you want to install Android . The decompressed file directory is as follows

Then double-click " SDK Manager.exe" to start SDK Manager , as shown in the figure:

Here you need to append the " \platform-tools" and " \tools" paths to the system environment variable Path , as follows:

Variable name: ANDROID_SDK_HOME
Variable value: D:\software\Android\android-sdk_r24.4.1-windows\android-sdk-windows
 

After the Path variable of the system , append

% ANDROID_SDK_HOME%\ platform-tools
% ANDROID_SDK_HOME%\ tools

As shown

Open cmd to see if the installation is successful

 

Xposed

https://forum.xda-developers.com/showthread.php?t=3034811

Start the night god simulator (same for mobile phones)

Drag the xpose installer apk into the simulator

Open the xposed installation framework

Two, create a project

Create android development basic project

Add reference

Add the following two quotes in Module 's build.gradle , and pay attention to modify the  implementation fileTree ( dir :'libs', include: ['*.jar']) to  compileOnly fileTree ( dir :'libs', include: [ '*.jar']) .

The reason is that there is already the JAR package content in Xposed , and it will conflict if it is packaged again, which will cause handleLoadPackage to have no callback .

dependencies {

   compileOnly 'de.robv.android.xposed:api:82'

   compileOnly 'de.robv.android.xposed:api:82:sources'



    compileOnly fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.android.support:appcompat-v7:28.0.0'

    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    testImplementation 'junit:junit:4.12'

    androidTestImplementation 'com.android.support.test:runner:1.0.2'

    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

}

Declare Xposed Module

After creating Xposed project, still in need AndroidMenafest.xml document which declared Xposed module, the application to add three inside the meta-data tags (xposedmodule, xposeddescription, xposedminversion).

xposedmodule: means as a module of Xposed
xposeddescription: indicates the description of this module, which will be displayed under the program name after installation
xposedminversion: the minimum version number of the jar package
<meta-data
    android:name="xposedmodule"
    android:value="true"/>
<meta-data
    android:name="xposeddescription"
    android:value="pdd demo"/>
<meta-data
    android:name="xposedminversion"
    android:value="53"/>

Write hook code

Declare the entry of the class

After creating our hook class, we need to be loaded into the class XposedInstaller , that is the position we have to declare the class, you need to xposed_init in a statement.

First create the assets file:

Then in the assets file, create a new file named " xposed_init " (select text as the file type ), and note that there is no suffix.

Then write the full class name of the entry class just created in xposed_init , here is  com.example.pddtest111.hook 

Three, compile and test

Compile and package into apk

After successful compilation, an apk will appear in the following directory

Installation test

Drag the generated apk into the simulation to install

Open xposed , add it to the xposed module (check), then restart the emulator

Start the related application, you can test

Guess you like

Origin blog.csdn.net/someby/article/details/108454212