diff --git a/README.md b/README.md index f06defc..90fab74 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,20 @@ This library provides a high-level Text-To-Speech (TTS) interface supporting var * Screen readers/SAPI via Tolk (requires `use_tolk` Cargo feature) * WinRT * Linux via [Speech Dispatcher](https://freebsoft.org/speechd) -* MacOS +* MacOS/iOS * AppKit on MacOS 10.13 and below * AVFoundation on MacOS 10.14 and above, and iOS +* Android * WebAssembly + +## Android Setup + +On most platforms, this library is plug-and-play. Because of JNI's complexity, Android setup is a bit more involved. In general, look to the Android example for guidance. Here are some rough steps to get going: + +* Set up _Cargo.toml_ as the example does. Be sure to depend on `ndk-glue`. +* Place _Bridge.java_ appropriately in your app. This is needed to support various Android TTS callbacks. +* Create a main activity similar to _MainActivity.kt_. In particular, you need to derive `android.app.NativeActivity`, and you need a `System.loadLibrary(...)` call appropriate for your app. `System.loadLibrary(...)` is needed to trigger `JNI_OnLoad`. +* * Even though you've loaded the library in your main activity, add a metadata tag to your activity in _AndroidManifest.xml_ referencing it. Yes, this is redundant but necessary. +* Set if your various build.gradle scripts to reference the plugins, dependencies, etc. from the example. In particular, you'll want to set up [cargo-ndk-android-gradle](https://github.com/willir/cargo-ndk-android-gradle/) and either [depend on androidx.annotation](https://developer.android.com/reference/androidx/annotation/package-summary) or otherwise configure your app to keep the class _rs.tts.Bridge_. + +And I think that should about do it. Good luck! \ No newline at end of file diff --git a/examples/android/cargo.toml b/examples/android/cargo.toml index 2748088..a7ff289 100644 --- a/examples/android/cargo.toml +++ b/examples/android/cargo.toml @@ -10,6 +10,5 @@ edition = "2018" crate-type = ["dylib"] [dependencies] -jni = "0.18" ndk-glue = "0.2" tts = { path = "../.." } \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 2e53b5e..81fb009 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,9 +5,10 @@ * * Screen readers/SAPI via Tolk (requires `use_tolk` Cargo feature) * * WinRT * * Linux via [Speech Dispatcher](https://freebsoft.org/speechd) - * * MacOS + * * MacOS/iOS * * AppKit on MacOS 10.13 and below * * AVFoundation on MacOS 10.14 and above, and iOS + * * Android * * WebAssembly */