Android Studio is warning a call (from Firebase) will be deprecated end of 2019. This updates the versions of * Frebase * Gradle from 4.10.1 to 5.1.1 Also stubs a missing keyboard event handler in some of the sample/test projects. |
||
|---|---|---|
| .. | ||
| KMAPro | ||
| KMEA | ||
| Samples | ||
| Tests | ||
| .editorconfig | ||
| .gitignore | ||
| build.sh | ||
| history.md | ||
| README.md | ||
Keyman for Android & Keyman Engine for Android
Prerequisites
- Android Studio 3.3.2+
- Java SE Development Kit 8
- Node.js 8.9+ (for building KeymanWeb)
Minimum Android Requirements
Keyman for Android has a minSdkVersion of 16 for Android 4.1 Jelly Bean
Setup Android Studio
- Download Android Studio and install with these instructions.
- For Windows users, set environment variable ANDROID_HOME to the location of your Android SDK. The default installation location is C:\Users\[USER]\AppData\Local\Android\sdk where [USER] is your username. You may need to log out and log back in to take effect.
For MacOS/Linux users, add the following to ~/.bashrc or ~/.bash_profile
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
For MacOS users, add the following (adjusted appropriately) to ~/.bashrc or ~/.bash_profile if your Java version is too strange for gradlew to understand (e.g., 11.0.2)
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
echo $JAVA_HOME #should output: /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home
- For Windows users, from a Git Bash Prompt window, cd to the sdk/tools/bin folder and accept all the SDK license agreements
yes | ./sdkmanager.bat --licenses
For MacOS users, from a Terminal window, cd to the ~/Library/Android/sdk/tools/bin folder and accept all the SDK license agreements
yes | ./sdkmanager --licenses
- If you plan to test on a physical device via USB, install the appropriate OEM USB drivers
- Install Java SE Development Kit
Keyman for Android Development
Keyman for Android (formerly named KMAPro) can be built from a command line (preferred) or Android Studio.
Building Keyman Web is a precursor for compiling KMEA, so verify your system has all the Minimum Web Compilation Requirements
Crashlytics
Firebase Crashlytics is used for crash reporting, and it depends on a configured google-services.json file. For this reason, only the Debug variant of KMAPro is intended to be built on a Developer machine. The analytics for Debug are associated with a "Package name" com.tavultesoft.kmapro.debug.
If you need to view near real-time analytics in the Firebase DebugView console, enable Debug mode on the emulator with the command:
adb shell setprop debug.firebase.analytics.app com.tavultesoft.kmapro.debug
To disable Debug mode, use the command:
adb shell setprop debug.firebase.analytics.app .none.
Compiling From Command Line
- Launch a command prompt
- Change to one of these directories depending on what you want to compile:
- For compiling KMEA and KMAPro, cd to the directory keyman/android
- For compiling only KMAPro, cd to the directory keyman/android/KMAPro
./build.sh -debug- The APK will be found in KMAPro/kMAPro/build/outputs/apk/debug/kMAPro-debug.apk
Compiling From Android Studio
- Ensure that Keyman Engine for Android is built.
- Launch Android Studio and import the Gradle project keyman/android/KMAPro/build.gradle
- From the project view, configure anything that Gradle reports.
- Create a run configuration for kMAPro
- Select Run --> Edit Configurations...
- Select Add New Configuration (+) --> Android App
- Change Module to kMAPro
- Name your run configuration kMAPro (or as desired)
- Run your new configuration: Select Run --> Run 'kMAPro'
- Select a physical device or create a new virtual device to match your target API version
For Ubuntu 18.04, you will need to add your user to the
kvmgroup for permission accessing the emulator.
sudo apt install qemu-kvm
sudo adduser <username> kvm
Running From Command Line
- Launch a command prompt
- Ensure that a physical device is connected or an emulator is running.
- To list physical devices:
$ANDROID_HOME/platform-tools/adb.exe devices - To list created emulator devices:
$ANDROID_HOME/tools/emulator.exe -list-avds - Create a new virtual device if there are no existing devices.
- Start an emulator:
$ANDROID_HOME/tools/emulator.exe @nameofemulator
- To list physical devices:
- Load the APK:
$ANDROID_HOME/platform-tools/adb.exe install -r path/to/apk.apk- If multiple devices are connected you may need
$ANDROID_HOME/platform-tools/adb.exe install -r -s SERIAL path/to/apk.apk. ReplaceSERIALwith the device serial number listed in step 2.
- If multiple devices are connected you may need
Sample Projects
There are two included sample projects that can be modified to test a keyboard.
android/Samples/KMSample1 app runs a bare Keyman app for testing a keyboard.
android/Samples/KMSample2 app provides prompts for setting KMSample2 as a system level keyboard. Both sample apps include a default Tamil keyboard.
Building these projects follow the same steps as KMAPro:
- Build KMEA
- cd to the desired KMSample directory
./build.sh- Open Android Studio to run the app
Tests: KeyboardHarness
android/Tests/KeyboardHarness app is a test harness for developers to troubleshoot keyboards.
-
Copy the keyboard js file and applicable ttf fonts to android/Tests/KeyboardHarness/app/src/main/assets/cloud/.
For users of Keyman Engine pre 10.0, use the folders android/Tests/KeyboardHarness/app/src/main/assets/languages/ and android/Tests/KeyboardHarness/app/src/main/assets/fonts/ respectively.
-
Add the keyboard in android/Tests/KeyboardHarness/app/src/main/java/com/keyman/android/tests/keyboardHarness/MainActivity.java
-
cd to android/Tests/KeyboardHarness/
-
./build.sh -
Open Android Studio to run the app
How to Build Keyman Engine for Android
- Open a terminal or Git Bash prompt and go to Keyman Engine for Android project folder (e.g.
cd ~/keyman/android/KMEA/) - Run
./build.sh
Keyman Engine for Android library (keyman-engine.aar) is now ready to be imported in any project.
How to Use Keyman Engine for Android Library
- Add keyman-engine.aar into [Your project folder]/app/libs/ folder. a. We recommend downloading the the latest stable release of Keyman Engine and extracting the .aar file. b. If you choose to use your own build of the Keyman Engine, get the library from android/Samples/KMSample1/app/libs/keyman-engine.aar
- Open your project in Android Studio.
- Open build.gradle (Module: app) in "Gradle Scripts".
- After the
android {}object, include the following:
repositories {
flatDir {
dirs 'libs'
}
google()
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.google.firebase:firebase-crash:15.0.2'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {
transitive = true
}
api (name:'keyman-engine', ext:'aar')
}
- include
import com.tavultesoft.kmea.*;to use Keyman Engine in a class.