-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
docs(android): add dynamic library name guide for plugins (fix #14569) #14578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
docs(android): add dynamic library name guide for plugins (fix #14569) #14578
Conversation
…apps#14569) Signed-off-by: Subham Sangwan <[email protected]>
|
@IT-ess ,@FabianLars can you please review this. |
|
|
Thanks for the PR ! |
|
Thanks for the feedback @IT-ess! |
|
It is the former, and I don't know if that requires modifications in the code. I guess it does need some, otherwise it would probably have been documented either |
|
@IT-ess Found the solution! Plugin devs can auto-generate the library name using Gradle BuildConfig: In android {
defaultConfig {
// Read from Cargo.toml at build time
val cargoToml = file("../../Cargo.toml")
val libraryName = cargoToml.readText()
.lines()
.find { it.trim().startsWith("name") }
?.substringAfter("\"")?.substringBefore("\"")
?.replace("-", "_") ?: "unknown"
buildConfigField("String", "LIBRARY_NAME", "\"$libraryName\"")
}
buildFeatures { buildConfig = true }
}
In Example.kt:
kotlin
companion object {
init {
System.loadLibrary(BuildConfig.LIBRARY_NAME) // Auto-generated!
}
} |
|
I'm not sure but the config should be added to the build.gradle.kts of the plugin user, not the plugin itself ? 🤔 |
|
@IT-ess It goes in the plugin's build.gradle.kts not the user's app. Flow:
Structure: user-app/ └── (just imports plugin, no changes needed) This makes your plugin automatically load the correct library so users don't have to configure anything. Try it out when you get a chance! |
|
I just tested that, and it doesn't work at all 🫤 |
Closes #14569
Documents how to properly load native libraries in Android plugins with dynamic naming instead of hardcoding
System.loadLibrary("app_lib").Adds guide explaining:
Reference for updating tauri-apps/tauri-docs.