Skip to content

yukihook-compiler ​

Maven CentralMaven metadata URL

This is the YukiHook Xposed module automatic compilation module.

Configure Dependency ​

You can add this module to your project using the following method.

We recommend that you first refer to yukihook-bom to use BOM for unified version management.

Notice

You need to integrate the Google KSP plugin in your project that is suitable for the current Kotlin version of your project.

Add dependency in your project's gradle/libs.versions.toml.

toml
[versions]
ksp = "<ksp-version>"
yukihook-compiler = "<version>"

[plugins]
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }

[libraries]
yukihook-compiler = { module = "com.highcapable.yukihookapi:yukihook-compiler", version.ref = "yukihook-compiler" }

Configure dependency in your root project's build.gradle.kts.

kotlin
plugins {
    // ...
    alias(libs.plugins.ksp) apply false
}

Configure dependency in your project's build.gradle.kts.

kotlin
plugins {
    // ...
    alias(libs.plugins.ksp)
}

dependencies {
    // ...
    ksp(libs.yukihook.compiler)
}

Please change <version> to the version displayed at the top of this document, and change <ksp-version> to the KSP version corresponding to the Kotlin version currently used by your project.

Traditional Method ​

Configure dependency in your root project's build.gradle.kts.

kotlin
plugins {
    // ...
    id("com.google.devtools.ksp") version "<ksp-version>" apply false
}

Configure dependency in your project's build.gradle.kts.

kotlin
plugins {
    // ...
    id("com.google.devtools.ksp")
}

dependencies {
    // ...
    ksp("com.highcapable.yukihookapi:yukihook-compiler:<version>")
}

Please change <version> to the version displayed at the top of this document, and change <ksp-version> to the KSP version corresponding to the Kotlin version currently used by your project.

Pay Attention

The versions of this module and yukihook-core must be the same. We recommend managing versions with the BOM.

Function Introduction ​

This module finds the class with the entry annotation in your project, and generates the native entry class and configuration files required by the corresponding hook framework based on the base module in use.

Entry Annotations ​

Only one entry annotation can exist in a build variant, and it must match the base module you added. If you need to support multiple base modules at the same time, please refer to Multi-Entry Variants.

Entry AnnotationBase Module
@YukiHookLibXposedEntryyukihook-runtime-libxposed
@YukiHookXposed82Entryyukihook-runtime-xposed82

For the parameters of each entry annotation, please refer to the corresponding base module documentation.

Pay Attention

The following cases cause the compilation to fail.

  • A build variant contains multiple entry annotations
  • A build variant has no base module or multiple base modules
  • The entry annotation does not match the base module you added
  • The class with the entry annotation does not implement the YukiHookXposedModule interface, or its constructor has parameters
  • Configuration files required by the hook framework are declared manually in the source directory (such as resources/META-INF/xposed and assets/xposed_init)

Entry Class Name ​

The hook framework entry class name is generated from the full class name of your entry class with the _YukiHookXposedInit suffix by default.

Suppose this is your entry class.

The following example

kotlin
@YukiHookLibXposedEntry(targetApiVersion = 101)
object HookEntry : YukiHookXposedModule

The class names after compilation are as follows.

The following example

text
HookEntry ← Your entry class
HookEntry_YukiHookXposedInit ← The generated framework entry class

You can use the entryClassName parameter of the entry annotation to customize the generated entry class name.

The following example

kotlin
@YukiHookLibXposedEntry(
    entryClassName = "MyHookEntry",
    targetApiVersion = 102
)
object HookEntry : YukiHookXposedModule

The class names after compilation are as follows.

The following example

text
HookEntry ← Your entry class
MyHookEntry ← The generated framework entry class

Tips

The entry class can be defined with class or object, but it is recommended to use object to make sure each injected process runs it as a singleton.

Pay Attention

A custom entry class name can only contain letters, digits and underscores, cannot start with a digit, and cannot be the same as your entry class name.

Generated Content ​

The entry and configuration files are generated in the build directory for each build variant, you don't need to and should not create them manually in the source directory.

Base ModuleGenerated Files
yukihook-runtime-libxposedMETA-INF/xposed/java_init.list, module.prop, scope.list, native_init.list
yukihook-runtime-xposed82assets/xposed_init

Notice

The compiler does not generate or modify your AndroidManifest.xml, information such as the module name and description needs to be configured according to the specific requirements of the corresponding base module.

Released under the Apache-2.0 License