Integrate HiddenApiRefinePlugin into your Android application
mainTo use the hidden APIs in your main application module, follow these steps:
- Apply the plugin: Apply
dev.rikka.tools.refineto your Android application module. If you have multiple modules using hidden APIs, apply it to all of them. You can apply it to all Android modules at once from your rootbuild.gradleusing thesubprojectsblock. - Import the stub module: Add your
hidden-apimodule usingcompileOnlyso that the stubs are available at compile time but do not exist in the final APK. - (Optional) Add the runtime library: If you need the
Refine.unsafeCastmethod, add thedev.rikka.tools.refine:runtimedependency viaimplementation.
// 1. Apply plugin in application module (or root build.gradle)
plugins {
id('dev.rikka.tools.refine') version '<version>'
}
// OR apply to all subprojects in root build.gradle
subprojects {
plugins.withId("com.android.base") {
plugins.apply('dev.rikka.tools.refine')
}
}
// 2. Import stub module
dependencies {
compileOnly project(':hidden-api')
}
// 3. Optional: Import runtime for unsafeCast
// implementation("dev.rikka.tools.refine:runtime:<version>")