I'm just about ready to start banging my head off the wall here. I've read every SO thread I can find about this issue, read every single google result on the issue and can't find squat. I'm building an android app where I've written a 2D engine in C++ and I'm using the shared version of stlport with NDK r6b. The .so file for libstlport_shared is generated and copied successfully to my libs folder. I even checked using adb shell on the device and the .so file is copied correctly.
I tried various solutions, such as modifying my .mk file to explicitly declare libstlport_shared.so as a required module. During compile time everything goes great, it shows up in the APK, it successfully copies to the device. Yet I get this error:
09-17 17:35:26.450: DEBUG/dalvikvm(19277): Trying to load lib /data/data/ca.ascensionsystems.mypackagename/lib/libstlport_shared.so 0x476c6f30
09-17 17:35:26.450: INFO/dalvikvm(19277): Unable to dlopen(/data/data/ca.ascensionsystems.mypackagename/lib/libstlport_shared.so): Cannot load library: link_image[1995]: failed to link libstlport_shared.so
09-17 17:35:26.450: WARN/dalvikvm(19277): Exception Ljava/lang/UnsatisfiedLinkError; thrown during Lca/ascensionsystems/mypackagename/Ascengine;.<clinit>
09-17 17:35:26.450: WARN/dalvikvm(19277): threadid=8: thread exiting with uncaught exception (group=0x40025a70)
09-17 17:35:26.470: VERBOSE/WindowManager(4837): Remove Window{479ca678 Starting ca.ascensionsystems.mypackagename paused=false}: mSurface=Surface(name=Starting ca.ascensionsystems.mypackagename, identity=90) mExiting=false isAnimating=true app-animation=android.view.animation.AnimationSet@4794fa10 inPendingTransaction=false mDisplayFrozen=false
09-17 17:35:26.470: ERROR/WindowManager(4837): return in removeWindowLocked
09-17 17:35:26.490: ERROR/AndroidRuntime(19277): FATAL EXCEPTION: GLThread 9
09-17 17:35:26.490: ERROR/AndroidRuntime(19277): java.lang.ExceptionInInitializerError
09-17 17:35:26.490: ERROR/AndroidRuntime(19277): at ca.ascensionsystems.mypackagename.GL2JNIView$Renderer.onSurfaceChanged(GL2JNIView.java:336)
09-17 17:35:26.490: ERROR/AndroidRuntime(19277): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1327)
09-17 17:35:26.490: ERROR/AndroidRuntime(19277): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
09-17 17:35:26.490: ERROR/AndroidRuntime(19277): Caused by: java.lang.UnsatisfiedLinkError: Library stlport_shared not found
09-17 17:35:26.490: ERROR/AndroidRuntime(19277): at java.lang.Runtime.loadLibrary(Runtime.java:461)
09-17 17:35:26.490: ERROR/AndroidRuntime(19277): at java.lang.System.loadLibrary(System.java:557)
09-17 17:35:26.490: ERROR/AndroidRuntime(19277): at ca.ascensionsystems.mypackagename.Ascengine.<clinit>(Ascengine.java:26)
09-17 17:35:26.490: ERROR/AndroidRuntime(19277): ... 3 more
09-17 17:35:26.500: WARN/ActivityManager(4837): Force finishing activity ca.ascensionsystems.mypackagename/.mypackagenameActivity
Note that I replaced my rea开发者_JAVA技巧l package name with "mypackagename" as to not give away the super secret awesome name of my upcoming game. :) Also note Ascengine is another .SO, my main application SO which is my 2D engine.
Anyone experience an issue like this? Any ideas? Also note I did a objdump on libstlport_shared to check its deps. I confirmed they exist on my device with DDMS and even explicitly loaded them in my java code before attempting to load libstlport_shared. Made no difference. Thanks in advance!
ALSO
This is kind of a second, optional component to the question. One solution I've thought of but haven't tried yet is to use System.load(absolutePathToLibrary) but I can't find how to generate this path within java. I don't want to hard code it, for obvious reasons. Thanks again!
Okay well, it seems that I've found a solution, sort of. I basically just abandoned using the shared version of the stl port and switched to static. I then rebuilt the static version using the Application.mk flag: STLPORT_FORCE_REBUILD := true
However, I still had weird issues. It compiled once and installed fine. Then I did a clean and recomplied/deployed and it would finish building fine, then tell me my app had errors in a dialog box but not actually in eclipse. I exited eclipse, restarted it, cleaned and rebuilt and it all works now. Seems like there's some bugs/issues with the latest NDK... hopefully will be fixed with NDK r7 when they do a full STL port with exceptions etc.
精彩评论