Question

For multiple reasons I'm building my project manually (more or less following these steps http://geosoft.no/development/android.html), whithout using ant.

My projects uses the NDK and builds a .so library.

  • With Eclipse:

When I use Eclipse to build my project, everything works: I drag&drop libMyNativeLib.so in the libs/armeabi directory and when I call loadLibrary(MyNativeLib) it works fine: I can call native method from my Java code.

  • Manually:

Now I want to build manually my .apk. Everything works except from the native lib loading. Using aapt add, I have added in my apk : lib/armeabi/libMyNativeLib.so (I saw that the apk generated by Eclipse contains this .so in lib/armeabi so I used the same path in the apk). When calling loadLibrary(MyNativeLib), I got the following exception

java.lang.UnsatisfiedLinkError: Couldn't load MyNativeLib from loader dalvik.system.PathClassLoader[DexPathList...

Why is that ?

Should I do something in the dx --dex step regarding the native code (.so lib) ? I don't think so but I'm maybe wrong ? (I'm only using dx --dex with my .jar libs which is logic I guess).

Do you have any idea ?

Thanks

Was it helpful?

Solution

Thanks to apktool (http://ibotpeaches.github.io/Apktool/) I found out what was wrong.

The makefile that generates the final .apk bundle had an error. Indeed the aapt add command contained \ in the path instead of /. As I'm generating on Windows, all my paths use \ as a separator. That's why I used \ for aapt add. However as this path is used during the installation of the .apk on Android (Unix), then I should have used / separator.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top