I'm trying to build a template Android app using Grammatical Framework's Java bindings (however, I don't think what Java code I'm using in particular actually matters. Let's just say I'm trying to use some external non-Android Java code in an Android app).
After some trial and error, I got to successfully build an app using this external code by following these steps:
- generating a
.jarfile for the library I want to use (it's calledjpgf.jar - copying it to
app/libs - adding it as a library and verifying that the
build.gradlegets updated withimplementation files('libs/jpgf.jar') - importing it in my app's
MainActivityand writing some code that uses it
However, nothing can be easy in Android development, ever. So my app, after nicely compiling, crashes on startup with the following error:
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/bho.harisont.gfdemo-8c870hpW06uEnMQHV1ILjw==/base.apk"],nativeLibraryDirectories=[/data/app/bho.harisont.gfdemo-8c870hpW06uEnMQHV1ILjw==/lib/x86, /system/lib, /system/product/lib]]] couldn't find "libjpgf.so"
In short, some .so file can't be found. Now, I'm not Java or .so file expert, but I do know that when I installed jpgf system-wide on my machine using the dedicated Makefile, a .so file was generated and copied to some location. My probably naive attempt was to take that .so file and move it to the appropriate subfolder of jniLibs. I know I placed it in the correct folder and all, because in this way I managed to change the error message, but not to solve the problem: at this point the complaint is that libjpgf.so is 64 instead of 32 bits. You bet, my machine is 64 bits.
So, to help me you can answer one both of these questions:
- how do I compile a 32 bit version of the
.sofile on a 64 bit machine? I tried somegccoptions but it's not like that helped - do I actually need that prebuilt
.sofile? I see other people just importing JARs. Can I not just do that (or even import the source code somehow), and have Android Studio generate all the assets it wants the way it wants?