Xposed学习(1)_new_project

新建空的android项目,没有Activity

目录结构如下:

upload successful

修改build.gradle文件

upload successful

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
26
27
28
29
30
31
32
33
34
35
36
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.michael.xposed_1"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

# 下面这三行是新加的
repositories {
jcenter();
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
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'
# 下面这两行是新加的
compileOnly 'de.robv.android.xposed:api:82'
compileOnly 'de.robv.android.xposed:api:82:sources'
}

修改AndroidManifest.xml

upload successful

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
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.michael.xposed_1">

<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" > <!--以前这里是application的闭合,要修改一下,在meta-data之后再闭合application-->

<!--增加三个meta-data-->
<meta-data
android:name="xposedmodule"
android:value="true" />

<meta-data
android:name="xposedminversion"
android:value="82" />

<meta-data
android:name="xposeddescription"
android:value="Xposed Hook Demo 1" />
</application> <!--闭合application-->
</manifest>

Build APK

这个时候就可以build apk了,但是我这出了个问题。因为之前配置了gradle的代理,所以还需要将代理删除。

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
26
27
28
29
30
31
32
33
34
35
36
37
# michael @ m0nst3r in ~ [17:04:56] 
$ cd .gradle

# michael @ m0nst3r in ~/.gradle [17:04:59]
$ ll
total 8
drwxr-xr-x 11 michael staff 352B Oct 30 11:16 caches
drwxr-xr-x 7 michael staff 224B Oct 30 11:16 daemon
-rw-r--r-- 1 michael staff 863B Dec 4 16:55 gradle.properties
drwxr-xr-x 5 michael staff 160B Oct 30 10:55 native
drwxr-xr-x 2 michael staff 64B Aug 22 18:48 workers
drwxr-xr-x 3 michael staff 96B Aug 22 18:29 wrapper

# michael @ m0nst3r in ~/.gradle [17:05:00]
$ pwd
/Users/michael/.gradle

# michael @ m0nst3r in ~/.gradle [17:05:03]
$ cat gradle.properties
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Tue Dec 04 16:22:40 CST 2018
# systemProp.http.proxyHost=127.0.0.1
# systemProp.https.proxyPort=1080
# systemProp.https.proxyHost=127.0.0.1
# systemProp.http.proxyPort=1080

查看安装的模块是否正确

Build APK之后,用adb install 安装到手机

1
2
3
4
5
# michael @ m0nst3r in ~/study/xposed/xposed_1/app/build/outputs/apk/debug [16:56:42] 
$ adb install app-debug.apk
app-debug.apk: 1 file pushed. 2.0 MB/s (1540691 bytes in 0.722s)
pkg: /data/local/tmp/app-debug.apk
Success

如果已经安装在手机中的xposed installer能够成功识别我们刚刚编译的这个项目,就说明没有问题。下面就可以写代码了。
upload successful