Android NDK java.lang.UnsatisfiedLinkError: findLibrary returned null

后端 未结 16 511
我在风中等你
我在风中等你 2020-11-30 01:56

Having the above error in your Android JNI app? Read on...

Up front, I\'ll say that I\'ve already solved this, in my own way, but I feel something in the Android bu

相关标签:
16条回答
  • 2020-11-30 02:01

    I just had this happen and the problem was that the device simply did not have enough space to install the library. I uninstalled some other apps and then it worked.

    0 讨论(0)
  • 2020-11-30 02:04

    Had identical problem. Just cleaned project and it worked. Mystery..

    0 讨论(0)
  • 2020-11-30 02:05

    just had a similar problem.

    Check out your /data/data/your.package.name/lib directory

    When i ls in my package directory it currently displays:

    lib -> /mismatched_uid/settings_10037/fs_1000
    

    probably i accidently switched the sharedUserId and thus the library can't be accessed anymore.

    0 讨论(0)
  • Inside libs folder, I create a new folder called armeabi-v7a, and copied the .so file from armeabi to the new folder. It solves the error.

    0 讨论(0)
  • 2020-11-30 02:10

    None of the previous answers solved my problem, but this did: All along the problem was that a necessary subdirectory and file were not present. All I had in my libs folder was an armeabi folder containing the proper .so file, but there are supposed to be 3 others, each with a .so file in them. Not certain yet which of the other three (armeabi-v7a, mips, or x86) was the required one, but I do know that all three were automatically generated when I added the Application.mk file to the same folder as the Android.mk file, and made sure it had the following line in it:

    APP_ABI := all
    

    For me, that line is the only text in there. When ndk-build is then run the Application.mk file apparently causes "all" the 4 folders to be created and the proper .so files to be created in them. Once I got Application.mk in place, I ran ndk-build again, and then did a clean and a clear on my Eclipse project before trying again. Everything ran perfectly.

    0 讨论(0)
  • 2020-11-30 02:11

    First, check you have the jni files inside you libs folder in eclipse or jniLibs folder in android studio. When you checkin in any svn, cross check to check in the .so files too.

    My Scenario was when Building with Android studio.

    When you are building in android studio, your library .so files or (jni) files should be inside the \src\main\jniLibs\armeabi***.so folder.

    where as these files will be inside the \libs\armeabi***.so in eclipse.

    When building using both eclipse and android studio, you have to modify your build.gradle file as

    main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = ['src']
                resources.srcDirs = ['src']
                aidl.srcDirs = ['src']
                renderscript.srcDirs = ['src']
                res.srcDirs = ['res']
                assets.srcDirs = ['assets']
    
                // Fixed Issue : "android studio java.lang.unsatisfiedlinkerror: couldn't load find library returned null"
                // Cause : For android studio : The JNI files should be placed in the /src/main/jniLibs folder.
                // Fix : Mapping the jniLibs 's source Directories with Lib's folder
                jniLibs.srcDirs = ['libs']
    }
    

    Here I am building the project using both the android studio and the eclipse.

    0 讨论(0)
提交回复
热议问题