Reporting issues installing with Android Studio with detailed notes on workaround:
MaxieKeyboard is complex using GNU Aspell spell checker as a native library and KeyPoint's OpenAdaptxt as a binary library. The files here form an Eclipse project. Importing the project to Android Studio needs care and although it isn't automatic by far it is fairly easy.
I have a fair amount of experience with Android Java in Eclipse and Studio but limited experience of Git, libraries and native code. I successfully imported MaxieKeyboard but there might be cleaner solutions -- but hey this works and only takes about 30 mins.
Notes:
- Before you start anything serious in Studio it is worth excluding its main directories from your virus checker - Java and Android access thousands of wee files and this tends to be badly slowed down by checkers.
- I could not get MaxieKeyboard debugging running in the emulator but it does run on the phone and you can still watch the LogCat of a connected phone.
Importing steps:
-
Go to SDK Manager in Android Studio then to the SDK Tools tab and turn on (tick) NDK. Wait for instal to finish....
-
Download the full zip of MaxieKeyboard and expand / decompress it
-
In Android Studio "Import Project" and select the directory MaxieKeyboard-master\Android (the directory containing the .project and .classpath files). You should get a customised import wizard including questions about replacing JARs - leave these ticked. If it doesn't feel customised you probably have the wrong directory.
-
The import should end with an error about NDK (Native Dev Kit) integration being deprecated. The easiest solution, I think, is to click "set useDeprectedNdk=true" in gradle.properties. Everything should now build.
-
When the build processes are finished try to build the Signed APK. For me this resulted in NDK errors with basic things like string.h and stdlib.h not being recognised in C++ code. Switch the side panel view of Android Studio from "Android" to "Project" using the <> arrows. Open the build.gradle file within your app folder - there are (at least) two of these files, it must be the one in the app folder that starts "apply plugin: 'com.android.application' ... android {". Change the ndk entry from
ndk {
moduleName "aspell"
}
to
ndk {
moduleName "aspell"
sourceSets.main.jni.srcDirs = [] // disable automatic ndk-build call, which ignore our Android.mk
sourceSets.main.jniLibs.srcDir 'src/main/libs'
cFlags "-std=c++11 -fexceptions -frtti" //enable rtti and exceptions
ldLibs "log"
stl "gnustl_shared" //use gnu compiler
}
You should now have a yellow warning bar - "Sync now" to rebuild the gradle setup.
-
Try again to build the Signed APK, again this failed for me. Android Studio has more powerful Lint probable error detection. This triggered for me on the two calls to onDraw in CandidateView.java. See your Event Log for the error and find the TWO calls to onDraw and click on them - a red warning bulb should appear, click it and pick Add @SuppressLint("WrongCall"). You have to do both. While you are here there is an erroneous parameter in the CandidateView method that you should delete. Once done all compilation (red) errors in CandidateView.java should be gone.
-
Try building the Signed APK again - this time you should succeed :-) But you are not there quite yet... this APK will install but will crash when the keyboard tries to use ASpell. The build has not run the cpp compiler so the aspell libraries (named libaspell.so) don't exist in the build. There is probably a way to resolve this automatically but my solution was to get a command prompt in the app\src\main folder and run ndk-build (full path something like C:\Users<>\AppData\Local\Android\sdk\ndk-bundle\build\ndk-build). I changed armeabi-v7 to all in Application.mk before doing this build but don't think that's necessary. Thanks to https://www.youtube.com/watch?v=G0vL7-_xuDM for this step - a very helpful intro to NDK.
-
Try again and hopefully this time it will all work. You might need to uninstal the previous version and reboot your phone first as sometimes the crash kills the spell check service.
Reporting issues installing with Android Studio with detailed notes on workaround:
MaxieKeyboard is complex using GNU Aspell spell checker as a native library and KeyPoint's OpenAdaptxt as a binary library. The files here form an Eclipse project. Importing the project to Android Studio needs care and although it isn't automatic by far it is fairly easy.
I have a fair amount of experience with Android Java in Eclipse and Studio but limited experience of Git, libraries and native code. I successfully imported MaxieKeyboard but there might be cleaner solutions -- but hey this works and only takes about 30 mins.
Notes:
Importing steps:
Go to SDK Manager in Android Studio then to the SDK Tools tab and turn on (tick) NDK. Wait for instal to finish....
Download the full zip of MaxieKeyboard and expand / decompress it
In Android Studio "Import Project" and select the directory MaxieKeyboard-master\Android (the directory containing the .project and .classpath files). You should get a customised import wizard including questions about replacing JARs - leave these ticked. If it doesn't feel customised you probably have the wrong directory.
The import should end with an error about NDK (Native Dev Kit) integration being deprecated. The easiest solution, I think, is to click "set useDeprectedNdk=true" in gradle.properties. Everything should now build.
When the build processes are finished try to build the Signed APK. For me this resulted in NDK errors with basic things like string.h and stdlib.h not being recognised in C++ code. Switch the side panel view of Android Studio from "Android" to "Project" using the <> arrows. Open the build.gradle file within your app folder - there are (at least) two of these files, it must be the one in the app folder that starts "apply plugin: 'com.android.application' ... android {". Change the ndk entry from
to
You should now have a yellow warning bar - "Sync now" to rebuild the gradle setup.
Try again to build the Signed APK, again this failed for me. Android Studio has more powerful Lint probable error detection. This triggered for me on the two calls to onDraw in CandidateView.java. See your Event Log for the error and find the TWO calls to onDraw and click on them - a red warning bulb should appear, click it and pick Add @SuppressLint("WrongCall"). You have to do both. While you are here there is an erroneous parameter in the CandidateView method that you should delete. Once done all compilation (red) errors in CandidateView.java should be gone.
Try building the Signed APK again - this time you should succeed :-) But you are not there quite yet... this APK will install but will crash when the keyboard tries to use ASpell. The build has not run the cpp compiler so the aspell libraries (named libaspell.so) don't exist in the build. There is probably a way to resolve this automatically but my solution was to get a command prompt in the app\src\main folder and run ndk-build (full path something like C:\Users<>\AppData\Local\Android\sdk\ndk-bundle\build\ndk-build). I changed armeabi-v7 to all in Application.mk before doing this build but don't think that's necessary. Thanks to https://www.youtube.com/watch?v=G0vL7-_xuDM for this step - a very helpful intro to NDK.
Try again and hopefully this time it will all work. You might need to uninstal the previous version and reboot your phone first as sometimes the crash kills the spell check service.