From 2db28d8aab241e45a71d37434ec3be21243f89ee Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Thu, 21 Sep 2023 04:26:20 +0800 Subject: [PATCH] docs: update some functions --- .../hook/type/android/ComponentTypeFactory.md | 2 +- .../hook/type/android/GraphicsTypeFactory.md | 2 +- .../hook/type/android/ViewTypeFactory.md | 2 +- .../hook/type/java/VariableTypeFactory.md | 2 +- .../en/api/special-features/host-inject.md | 12 +- docs-source/src/en/guide/example.md | 4 +- docs-source/src/en/guide/home.md | 2 +- docs-source/src/en/guide/quick-start.md | 167 +++++++++++++++--- .../hook/type/android/ComponentTypeFactory.md | 2 +- .../hook/type/android/GraphicsTypeFactory.md | 2 +- .../hook/type/android/ViewTypeFactory.md | 2 +- .../hook/type/java/VariableTypeFactory.md | 2 +- .../zh-cn/api/special-features/host-inject.md | 12 +- docs-source/src/zh-cn/guide/example.md | 4 +- docs-source/src/zh-cn/guide/home.md | 2 +- docs-source/src/zh-cn/guide/quick-start.md | 148 ++++++++++++++-- 16 files changed, 306 insertions(+), 61 deletions(-) diff --git a/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.md b/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.md index 414af3d9..2b36dfc4 100644 --- a/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.md +++ b/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.md @@ -20,4 +20,4 @@ You can use the **Chrome Translation Plugin** to translate entire pages for refe > 这是一个预置反射类型的常量类,主要为 `Android` 相关组件的 `Class` 内容,跟随版本更新会逐一进行增加。 -详情可 [点击这里](https://github.com/fankes/YukiHookAPI/blob/master/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.kt) 进行查看。 \ No newline at end of file +详情可 [点击这里](https://github.com/fankes/YukiHookAPI/blob/master/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.kt) 进行查看。 \ No newline at end of file diff --git a/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.md b/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.md index eb11edc0..a5e1bc10 100644 --- a/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.md +++ b/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.md @@ -20,4 +20,4 @@ You can use the **Chrome Translation Plugin** to translate entire pages for refe > 这是一个预置反射类型的常量类,主要为 `Android` 相关 `Graphics` 的 `Class` 内容,跟随版本更新会逐一进行增加。 -详情可 [点击这里](https://github.com/fankes/YukiHookAPI/blob/master/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.kt) 进行查看。 \ No newline at end of file +详情可 [点击这里](https://github.com/fankes/YukiHookAPI/blob/master/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.kt) 进行查看。 \ No newline at end of file diff --git a/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.md b/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.md index 7574c562..d73e6b2b 100644 --- a/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.md +++ b/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.md @@ -20,4 +20,4 @@ You can use the **Chrome Translation Plugin** to translate entire pages for refe > 这是一个预置反射类型的常量类,主要为 `Android` 相关 `Widget` 的 `Class` 内容,跟随版本更新会逐一进行增加。 -详情可 [点击这里](https://github.com/fankes/YukiHookAPI/blob/master/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.kt) 进行查看。 \ No newline at end of file +详情可 [点击这里](https://github.com/fankes/YukiHookAPI/blob/master/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.kt) 进行查看。 \ No newline at end of file diff --git a/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.md b/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.md index fc513170..1e8b1a4c 100644 --- a/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.md +++ b/docs-source/src/en/api/public/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.md @@ -20,4 +20,4 @@ You can use the **Chrome Translation Plugin** to translate entire pages for refe > 这是一个预置反射类型的常量类,主要为 `Java` 相关基本变量类型的 `Class` 内容,跟随版本更新会逐一进行增加。 -详情可 [点击这里](https://github.com/fankes/YukiHookAPI/blob/master/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.kt) 进行查看。 \ No newline at end of file +详情可 [点击这里](https://github.com/fankes/YukiHookAPI/blob/master/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.kt) 进行查看。 \ No newline at end of file diff --git a/docs-source/src/en/api/special-features/host-inject.md b/docs-source/src/en/api/special-features/host-inject.md index 135bfc41..d4705a61 100644 --- a/docs-source/src/en/api/special-features/host-inject.md +++ b/docs-source/src/en/api/special-features/host-inject.md @@ -4,24 +4,26 @@ Before using the following functions, in order to prevent Resource Id from conflicting with each other, you need to modify the Resource Id in the `build.gradle` of the current Xposed Module project. -- Kotlin Gradle DSL +> Kotlin DSL ```kotlin android { - androidResources.additionalParameters("--allow-reserved-package-id", "--package-id", "0x64") + androidResources.additionalParameters += listOf("--allow-reserved-package-id", "--package-id", "0x64") } ``` -- Groovy +> Groovy DSL ```groovy android { - aaptOptions.additionalParameters '--allow-reserved-package-id', '--package-id', '0x64' + androidResources.additionalParameters += ['--allow-reserved-package-id', '--package-id', '0x64'] } ``` ::: warning +**aaptOptions.additionalParameters** in previous versions has been deprecated, please refer to the above writing method and keep your **Android Gradle Plugin** to the latest version. + The sample Resource Id value provided is for reference only, **0x7f** cannot be used, the default is **0x64**. In order to prevent the existence of multiple Xposed Modules in the current Host App, it is recommended to customize your own Resource Id. @@ -296,7 +298,7 @@ This way, we can create dialogs in the Host App very simply using `MaterialAlert Because some **androidx** dependent libraries or custom themes used by some apps may interfere with the actual style of the current **MaterialAlertDialog**, such as the button style of the dialog. -You can refer to the **Module App Demo** in this case and see [here is the sample code](https://github.com/fankes/YukiHookAPI/tree/master/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/factory/ComponentCompatFactory.kt) to fix this problem. +You can refer to the **Module App Demo** in this case and see [here is the sample code](https://github.com/fankes/YukiHookAPI/tree/master/samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/factory/ComponentCompatFactory.kt) to fix this problem. **ClassCastException** may occur when some apps are created, please manually specify a new **Configuration** instance to fix. diff --git a/docs-source/src/en/guide/example.md b/docs-source/src/en/guide/example.md index 6da7f42c..8e591413 100644 --- a/docs-source/src/en/guide/example.md +++ b/docs-source/src/en/guide/example.md @@ -60,9 +60,9 @@ resources().hook { > You can find the demo provided by the API below to learn how to use `YukiHookAPI`. -- Host App Demo [click here to view](https://github.com/fankes/YukiHookAPI/tree/master/demo-app) +- Host App Demo [click here to view](https://github.com/fankes/YukiHookAPI/tree/master/samples/demo-app) -- Module App Demo [click here to view](https://github.com/fankes/YukiHookAPI/tree/master/demo-module) +- Module App Demo [click here to view](https://github.com/fankes/YukiHookAPI/tree/master/samples/demo-module) Install the Host App and Module App Demo at the same time, and test the hooked function in the Host App by activating the Module App. diff --git a/docs-source/src/en/guide/home.md b/docs-source/src/en/guide/home.md index f1afe296..0b06a309 100644 --- a/docs-source/src/en/guide/home.md +++ b/docs-source/src/en/guide/home.md @@ -22,7 +22,7 @@ Please use `Kotlin`, the framework part of the code composition is also compatib All demo code in this document will be described using `Kotlin`, if you don't know how to use `Kotlin` then you may not be able to use `YukiHookAPI`. -Part of the Java Demo code can be found [here](https://github.com/fankes/YukiHookAPI/tree/master/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/java), but not recommended. +Part of the Java Demo code can be found [here](https://github.com/fankes/YukiHookAPI/tree/master/samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/java), but not recommended. ## Source of Inspiration diff --git a/docs-source/src/en/guide/quick-start.md b/docs-source/src/en/guide/quick-start.md index f7f8cf37..edce1e70 100644 --- a/docs-source/src/en/guide/quick-start.md +++ b/docs-source/src/en/guide/quick-start.md @@ -16,7 +16,7 @@ - Gradle 7.0 and above -- JVM 11 and above (Since API `1.0.80`) +- Java 11 and above (Since API `1.0.80`) ## Automatically Build Project @@ -34,62 +34,183 @@ Use `Android Studio` or `IntelliJ IDEA` to create a new Android project and sele ### Integration Dependencies -Add dependencies to your project `build.gradle`. +We recommend using Kotlin DSL as the Gradle build script language and [SweetDependency](https://github.com/HighCapable/SweetDependency) to manage dependencies. + +#### SweetDependency Method + +Add the repositories and dependencies in your project's `SweetDependency` configuration file. > The following example +```yaml +repositories: + # ❗Must be added when used as an Xposed Module, otherwise optional + rovo89-xposed-api: + url: https://api.xposed.info/ + # MavenCentral has a 2-hour cache, + # if the latest version cannot be integrated, please add this + sonatype-oss-releases: + +plugins: + # ❗Must be added when used as an Xposed Module, otherwise optional + com.google.devtools.ksp: + version: + + ... + +libraries: + # ❗Must be added when used as an Xposed Module, otherwise optional + de.robv.android.xposed: + api: + version: 82 + repositories: + rovo89-xposed-api + com.highcapable.yukihookapi: + api: + version: + + # ❗Must be added when used as an Xposed Module, otherwise optional + ksp-xposed: + version-ref: ::api + ... +``` + +After adding it, run Gradle Sync and all dependencies will be autowired. + +Next, deploy plugins in your project `build.gradle.kts`. + +> The following example + +```kotlin +plugins { + // ❗Must be added when used as an Xposed Module, otherwise optional + autowire(libs.plugins.com.google.devtools.ksp) + // ... +} +``` + +Then, deploy dependencies in your project `build.gradle.kts`. + +> The following example + +```kotlin +dependencies { + // Basic dependencies + implementation(com.highcapable.yukihookapi.api) + // ❗Must be added when used as an Xposed Module, otherwise optional + compileOnly(de.robv.android.xposed.api) + // ❗Must be added when used as an Xposed Module, otherwise optional + ksp(com.highcapable.yukihookapi.ksp.xposed) +} +``` + +#### Traditional Method (Not Recommended) + +Add repositories in your project `build.gradle.kts` or `build.gradle`. + +> Kotlin DSL + +```kotlin +repositories { + google() + mavenCentral() + // ❗Must be added when used as an Xposed Module, otherwise optional + maven { url("https://api.xposed.info/") } + // MavenCentral has a 2-hour cache, if the latest version cannot be integrated, please add this URL + maven { url("https://s01.oss.sonatype.org/content/repositories/releases/") } +} +``` + +> Groovy DSL + ```groovy repositories { google() mavenCentral() - // ❗If your Plugin version is too low, be sure to add it as an Xposed Module, other cases are optional - maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } - // ❗Be sure to add it as an Xposed Module, optional in other cases - maven { url "https://api.xposed.info/" } - // MavenCentral has a 2-hour cache, if you cannot integrate the latest version, please add this address - maven { url "https://s01.oss.sonatype.org/content/repositories/releases" } + // ❗Must be added when used as an Xposed Module, otherwise optional + maven { url 'https://api.xposed.info/' } + // MavenCentral has a 2-hour cache, if the latest version cannot be integrated, please add this URL + maven { url 'https://s01.oss.sonatype.org/content/repositories/releases/' } } ``` -Add `plugin` to your app `build.gradle`. +Add plugins in your project `build.gradle.kts` or `build.gradle`. -> The following example +> Kotlin DSL + +```kotlin +plugins { + // ❗Must be added when used as an Xposed Module, otherwise optional + id("com.google.devtools.ksp") version "" +} +``` + +> Groovy DSL ```groovy plugins { - // ❗Be sure to add it as an Xposed Module, optional in other cases + // ❗Must be added when used as an Xposed Module, otherwise optional id 'com.google.devtools.ksp' version '' } ``` -Add dependencies to your app `build.gradle`. +Add dependencies in your project `build.gradle.kts` or `build.gradle`. -> The following example +> Kotlin DSL + +```kotlin +dependencies { + // Basic dependency + implementation("com.highcapable.yukihookapi:api:") + // ❗Must be added when used as an Xposed Module, otherwise optional + compileOnly("de.robv.android.xposed:api:82") + // ❗Must be added when used as an Xposed Module, otherwise optional + ksp("com.highcapable.yukihookapi:ksp-xposed:") +} +``` + +> Groovy DSL ```groovy dependencies { - // Base dependencies + // Basic dependency implementation 'com.highcapable.yukihookapi:api:' - // ❗Be sure to add it as an Xposed Module, optional in other cases + // ❗Must be added when used as an Xposed Module, otherwise optional compileOnly 'de.robv.android.xposed:api:82' - // ❗Be sure to add it as an Xposed Module, optional in other cases + // ❗Must be added when used as an Xposed Module, otherwise optional ksp 'com.highcapable.yukihookapi:ksp-xposed:' } ``` -Please modify **<ksp-version>** to the latest version from [here](https://github.com/google/ksp/releases) **(Please choose your current corresponding Kotlin version)**. +Please modify **<ksp-version>** to the latest version found [here](https://github.com/google/ksp/releases) **(please note to select your current corresponding Kotlin version)**. -Please modify **<yuki-version>** to the latest version [here](../about/changelog). +Please change **<yuki-version>** to the latest version [here](../about/changelog). -::: danger +:::danger -The **api** of **YukiHookAPI** and the versions that **ksp-xposed** depend on must correspond one by one, otherwise a version mismatch error will occur. +The **api** and **ksp-xposed** dependency versions of **YukiHookAPI** must correspond one-to-one, otherwise a version mismatch error will occur. + +We recommend using [SweetDependency](https://github.com/HighCapable/SweetDependency) to autowire dependencies for you. ::: -Modify the JVM version of `Kotlin` to 11 and above in your app `build.gradle`. +#### Configure Java Version -> The following example +Modify the Java version of Kotlin in your project `build.gradle.kts` or `build.gradle` to 11 or above. + +> Kotlin DSL + +```kt +android { + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + kotlinOptions { + jvmTarget = "11" + } +} +``` + +> Groovy DSL ```groovy android { @@ -105,7 +226,7 @@ android { ::: warning -Since API **1.0.80** version, the default JVM version is 11, and 1.8 and below are no longer supported. +Since API **1.0.80**, the Java version used by Kotlin defaults to 11, and versions 1.8 and below are no longer supported. ::: diff --git a/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.md b/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.md index 5d54f98f..3f894f8b 100644 --- a/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.md +++ b/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.md @@ -12,4 +12,4 @@ pageClass: code-page > 这是一个预置反射类型的常量类,主要为 `Android` 相关组件的 `Class` 内容,跟随版本更新会逐一进行增加。 -详情可 [点击这里](https://github.com/fankes/YukiHookAPI/blob/master/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.kt) 进行查看。 \ No newline at end of file +详情可 [点击这里](https://github.com/fankes/YukiHookAPI/blob/master/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/android/ComponentTypeFactory.kt) 进行查看。 \ No newline at end of file diff --git a/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.md b/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.md index a692a05f..a3630ef0 100644 --- a/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.md +++ b/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.md @@ -12,4 +12,4 @@ pageClass: code-page > 这是一个预置反射类型的常量类,主要为 `Android` 相关 `Graphics` 的 `Class` 内容,跟随版本更新会逐一进行增加。 -详情可 [点击这里](https://github.com/fankes/YukiHookAPI/blob/master/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.kt) 进行查看。 \ No newline at end of file +详情可 [点击这里](https://github.com/fankes/YukiHookAPI/blob/master/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/android/GraphicsTypeFactory.kt) 进行查看。 \ No newline at end of file diff --git a/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.md b/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.md index bf8d9df2..ce1f25c9 100644 --- a/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.md +++ b/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.md @@ -12,4 +12,4 @@ pageClass: code-page > 这是一个预置反射类型的常量类,主要为 `Android` 相关 `Widget` 的 `Class` 内容,跟随版本更新会逐一进行增加。 -详情可 [点击这里](https://github.com/fankes/YukiHookAPI/blob/master/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.kt) 进行查看。 \ No newline at end of file +详情可 [点击这里](https://github.com/fankes/YukiHookAPI/blob/master/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/android/ViewTypeFactory.kt) 进行查看。 \ No newline at end of file diff --git a/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.md b/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.md index 7f004187..e2d60bcc 100644 --- a/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.md +++ b/docs-source/src/zh-cn/api/public/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.md @@ -12,4 +12,4 @@ pageClass: code-page > 这是一个预置反射类型的常量类,主要为 `Java` 相关基本变量类型的 `Class` 内容,跟随版本更新会逐一进行增加。 -详情可 [点击这里](https://github.com/fankes/YukiHookAPI/blob/master/yukihookapi/src/main/java/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.kt) 进行查看。 \ No newline at end of file +详情可 [点击这里](https://github.com/fankes/YukiHookAPI/blob/master/yukihookapi-core/src/main/java/com/highcapable/yukihookapi/hook/type/java/VariableTypeFactory.kt) 进行查看。 \ No newline at end of file diff --git a/docs-source/src/zh-cn/api/special-features/host-inject.md b/docs-source/src/zh-cn/api/special-features/host-inject.md index 1f10434b..e3fcdb9d 100644 --- a/docs-source/src/zh-cn/api/special-features/host-inject.md +++ b/docs-source/src/zh-cn/api/special-features/host-inject.md @@ -4,24 +4,26 @@ 在使用以下功能之前,为防止资源 ID 互相冲突,你需要在当前 Xposed 模块项目的 `build.gradle` 中修改资源 ID。 -- Kotlin Gradle DSL +> Kotlin DSL ```kotlin android { - androidResources.additionalParameters("--allow-reserved-package-id", "--package-id", "0x64") + androidResources.additionalParameters += listOf("--allow-reserved-package-id", "--package-id", "0x64") } ``` -- Groovy +> Groovy DSL ```groovy android { - aaptOptions.additionalParameters '--allow-reserved-package-id', '--package-id', '0x64' + androidResources.additionalParameters += ['--allow-reserved-package-id', '--package-id', '0x64'] } ``` ::: warning +过往版本中的 **aaptOptions.additionalParameters** 已被作废,请参考上述写法并保持你的 **Android Gradle Plugin** 为最新版本。 + 提供的示例资源 ID 值仅供参考,不可使用 **0x7f**,默认为 **0x64**,为了防止当前宿主存在多个 Xposed 模块,建议自定义你自己的资源 ID。 ::: @@ -282,7 +284,7 @@ injectMember { ::: warning 可能存在的问题 -由于一些 APP 自身使用的 **androidx** 依赖库或自定义主题可能会对当前 **MaterialAlertDialog** 实际样式造成干扰,例如对话框的按钮样式,这种情况你可以参考 **模块 Demo** 中 [这里的示例代码](https://github.com/fankes/YukiHookAPI/tree/master/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/factory/ComponentCompatFactory.kt) 来修复这个问题。 +由于一些 APP 自身使用的 **androidx** 依赖库或自定义主题可能会对当前 **MaterialAlertDialog** 实际样式造成干扰,例如对话框的按钮样式,这种情况你可以参考 **模块 Demo** 中 [这里的示例代码](https://github.com/fankes/YukiHookAPI/tree/master/samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/factory/ComponentCompatFactory.kt) 来修复这个问题。 某些 APP 在创建时可能会发生 **ClassCastException** 异常,请手动指定新的 **Configuration** 实例来进行修复。 diff --git a/docs-source/src/zh-cn/guide/example.md b/docs-source/src/zh-cn/guide/example.md index f0c9d399..d3fa8834 100644 --- a/docs-source/src/zh-cn/guide/example.md +++ b/docs-source/src/zh-cn/guide/example.md @@ -60,9 +60,9 @@ resources().hook { > 你可以在下方找到 API 提供的 Demo 来学习 `YukiHookAPI` 的使用方法。 -- 宿主 APP Demo [点击这里查看](https://github.com/fankes/YukiHookAPI/tree/master/demo-app) +- 宿主 APP Demo [点击这里查看](https://github.com/fankes/YukiHookAPI/tree/master/samples/demo-app) -- 模块 APP Demo [点击这里查看](https://github.com/fankes/YukiHookAPI/tree/master/demo-module) +- 模块 APP Demo [点击这里查看](https://github.com/fankes/YukiHookAPI/tree/master/samples/demo-module) 同时安装宿主和模块 Demo,通过激活模块来测试宿主中被 Hook 的功能。 diff --git a/docs-source/src/zh-cn/guide/home.md b/docs-source/src/zh-cn/guide/home.md index 0178f7c9..0016f581 100644 --- a/docs-source/src/zh-cn/guide/home.md +++ b/docs-source/src/zh-cn/guide/home.md @@ -22,7 +22,7 @@ 文档全部的 Demo 示例代码都将使用 `Kotlin` 进行描述,如果你完全不会使用 `Kotlin` 那你将有可能无法使用 `YukiHookAPI`。 -部分 Java Demo 代码可在 [这里](https://github.com/fankes/YukiHookAPI/tree/master/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/java) 找到,但不推荐使用。 +部分 Java Demo 代码可在 [这里](https://github.com/fankes/YukiHookAPI/tree/master/samples/demo-module/src/main/java/com/highcapable/yukihookapi/demo_module/hook/java) 找到,但不推荐使用。 ## 灵感来源 diff --git a/docs-source/src/zh-cn/guide/quick-start.md b/docs-source/src/zh-cn/guide/quick-start.md index 4a8636b6..568baac3 100644 --- a/docs-source/src/zh-cn/guide/quick-start.md +++ b/docs-source/src/zh-cn/guide/quick-start.md @@ -4,7 +4,7 @@ ## 环境要求 -- Windows 7 及以上/macOS 10.14 及以上/Linux 发行版(Arch/Debian) +- Windows 7 及以上/macOS 10.14 及以上/Linux 发行版 (Arch/Debian) - Android Studio 2021.1 及以上 @@ -16,7 +16,7 @@ - Gradle 7.0 及以上 -- Jvm 11 及以上 (Since API `1.0.80`) +- Java 11 及以上 (Since API `1.0.80`) ## 自动构建项目 @@ -34,26 +34,115 @@ ### 集成依赖 -在你的项目 `build.gradle` 中添加依赖。 +我们推荐使用 Kotlin DSL 作为 Gradle 构建脚本语言并推荐使用 [SweetDependency](https://github.com/HighCapable/SweetDependency) 来管理依赖。 + +#### SweetDependency 方式 + +在你的项目 `SweetDependency` 配置文件中添加存储库和依赖。 > 示例如下 +```yaml +repositories: + #❗作为 Xposed 模块使用务必添加,其它情况可选 + rovo89-xposed-api: + url: https://api.xposed.info/ + # MavenCentral 有 2 小时缓存,若无法集成最新版本请添加 + sonatype-oss-releases: + +plugins: + #❗作为 Xposed 模块使用务必添加,其它情况可选 + com.google.devtools.ksp: + version: + + ... + +libraries: + #❗作为 Xposed 模块使用务必添加,其它情况可选 + de.robv.android.xposed: + api: + version: 82 + repositories: + rovo89-xposed-api + com.highcapable.yukihookapi: + api: + version: + + #❗作为 Xposed 模块使用务必添加,其它情况可选 + ksp-xposed: + version-ref: ::api + ... +``` + +添加完成后运行一次 Gradle Sync,所有依赖版本将自动装配。 + +接下来,在你的项目 `build.gradle.kts` 中部署插件。 + +> 示例如下 + +```kotlin +plugins { + // ❗作为 Xposed 模块使用务必添加,其它情况可选 + autowire(libs.plugins.com.google.devtools.ksp) + // ... +} +``` + +然后,在你的项目 `build.gradle.kts` 中部署依赖。 + +> 示例如下 + +```kotlin +dependencies { + // 基础依赖 + implementation(com.highcapable.yukihookapi.api) + // ❗作为 Xposed 模块使用务必添加,其它情况可选 + compileOnly(de.robv.android.xposed.api) + // ❗作为 Xposed 模块使用务必添加,其它情况可选 + ksp(com.highcapable.yukihookapi.ksp.xposed) +} +``` + +#### 传统方式 (不推荐) + +在你的项目 `build.gradle.kts` 或 `build.gradle` 中添加存储库。 + +> Kotlin DSL + +```kotlin +repositories { + google() + mavenCentral() + // ❗作为 Xposed 模块使用务必添加,其它情况可选 + maven { url("https://api.xposed.info/") } + // MavenCentral 有 2 小时缓存,若无法集成最新版本请添加此地址 + maven { url("https://s01.oss.sonatype.org/content/repositories/releases/") } +} +``` + +> Groovy DSL + ```groovy repositories { google() mavenCentral() - // ❗若你的 Plugin 版本过低,作为 Xposed 模块使用务必添加,其它情况可选 - maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // ❗作为 Xposed 模块使用务必添加,其它情况可选 - maven { url "https://api.xposed.info/" } + maven { url 'https://api.xposed.info/' } // MavenCentral 有 2 小时缓存,若无法集成最新版本请添加此地址 - maven { url "https://s01.oss.sonatype.org/content/repositories/releases" } + maven { url 'https://s01.oss.sonatype.org/content/repositories/releases/' } } ``` -在你的 app `build.gradle` 中添加 `plugin`。 +在你的项目 `build.gradle.kts` 或 `build.gradle` 中添加插件。 -> 示例如下 +> Kotlin DSL + +```kotlin +plugins { + // ❗作为 Xposed 模块使用务必添加,其它情况可选 + id("com.google.devtools.ksp") version "" +} +``` + +> Groovy DSL ```groovy plugins { @@ -62,9 +151,22 @@ plugins { } ``` -在你的 app `build.gradle` 中添加依赖。 +在你的项目 `build.gradle.kts` 或 `build.gradle` 中添加依赖。 -> 示例如下 +> Kotlin DSL + +```kotlin +dependencies { + // 基础依赖 + implementation("com.highcapable.yukihookapi:api:") + // ❗作为 Xposed 模块使用务必添加,其它情况可选 + compileOnly("de.robv.android.xposed:api:82") + // ❗作为 Xposed 模块使用务必添加,其它情况可选 + ksp("com.highcapable.yukihookapi:ksp-xposed:") +} +``` + +> Groovy DSL ```groovy dependencies { @@ -85,11 +187,29 @@ dependencies { **YukiHookAPI** 的 **api** 与 **ksp-xposed** 依赖的版本必须一一对应,否则将会造成版本不匹配错误。 +我们推荐使用 [SweetDependency](https://github.com/HighCapable/SweetDependency) 来自动帮你装配依赖。 + ::: -在你的 app `build.gradle` 中修改 `Kotlin` 的 Jvm 版本为 11 及以上。 +#### 配置 Java 版本 -> 示例如下 +在你的项目 `build.gradle.kts` 或 `build.gradle` 中修改 Kotlin 的 Java 版本为 11 及以上。 + +> Kotlin DSL + +```kt +android { + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + kotlinOptions { + jvmTarget = "11" + } +} +``` + +> Groovy DSL ```groovy android { @@ -105,7 +225,7 @@ android { ::: warning -自 API **1.0.80** 版本后 Jvm 版本默认为 11,不再支持 1.8 及以下版本。 +自 API **1.0.80** 版本后 Kotlin 使用的 Java 版本默认为 11,不再支持 1.8 及以下版本。 :::