致命异常:Android Studio 库中的主要 java.lang.UnsatisfiedLinkError
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20370312/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
FATAL EXCEPTION: main java.lang.UnsatisfiedLinkError in Android Studio library
提问by Ramprasad
I added FDxSDKProAndroid.jar file in libs folder of my project in android studio. Also added dependency in build.gradle file.
我在 android studio 项目的 libs 文件夹中添加了 FDxSDKProAndroid.jar 文件。还在 build.gradle 文件中添加了依赖项。
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'com.google.android.gms:play-services:4.0.30'
compile files('libs/FDxSDKProAndroid.jar')
}
Project builds properly without any error but onRuntime I got following error,How to resolve this error?
项目正确构建,没有任何错误,但在运行时出现以下错误,如何解决此错误?
Error occured in following line,
在以下行中发生错误,
sgfplib=new JSGFPLib((UsbManager)getSystemService(Context.USB_SERVICE));
Error:
错误:
12-04 13:35:13.022 12345-12345/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.UnsatisfiedLinkError: Couldn't load jnisgfplib from loader dalvik.system.PathClassLoader[DexPathList[dexElements=[zip file "/data/app/com.mycompany.mytrack-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.mycompany.mytrack-1, /vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:359)
at java.lang.System.loadLibrary(System.java:514)
at SecuGen.FDxSDKPro.JSGFPLib.<clinit>(JSGFPLib.java:150)
at com.mycompany.mytrack.FingerPrintActivity.onCreate(FingerPrintActivity.java:105)
at android.app.Activity.performCreate(Activity.java:5122)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
at android.app.ActivityThread.access0(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5297)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
12-04 13:35:13.033 511-529/? E/AppErrorDialog﹕ Failed to get ILowStorageHandle instance
采纳答案by Scott Barta
It looks like it's trying to load a native library, and there isn't support in Android Gradle for native code yet. You should double-check the docs for your library to confirm; I tried to look it up but it looks like it's a commercial library without publicly accessible docs.
看起来它正在尝试加载本机库,但 Android Gradle 尚不支持本机代码。您应该仔细检查您图书馆的文档以确认;我试图查找它,但它看起来像是一个没有可公开访问的文档的商业图书馆。
回答by Avinash R
You could just put the .so
files into jniLibs
folder in src/main
. This was introduced in AS 0.7.2 1
你可以只把.so
文件放入jniLibs
文件夹src/main
。这是在 AS 0.7.2 1 中引入的
As a sample, see thisfrom @CommonsWare, or see this pagefor official samples (scroll to the bottom of page)
为样本,看看这个从@CommonsWare,或看到这个网页的官样(滚动到页面底部)
回答by Mohamed
Here is my last hack when i was integrating with the same library for finger print device while trying to import .so files into Android Studio 1.5 Error occurred in this line
这是我在尝试将 .so 文件导入 Android Studio 1.5 时与指纹设备的同一库集成时的最后一次黑客攻击发生在这一行
sgfplib=new JSGFPLib((UsbManager)getSystemService(Context.USB_SERVICE));
Solution was to create a folder with the name armeabi-v7a in src/main/jniLibs so the hierarchy should be as the attached screen shot.
解决方案是在 src/main/jniLibs 中创建一个名为 armeabi-v7a 的文件夹,因此层次结构应与附加的屏幕截图相同。
Hope this can help :) with the latest Android Studio 1.5
希望这可以帮助:) 使用最新的 Android Studio 1.5
回答by Minto
There is a way .. but it is a simple hack. U can bind armeabi folder inside which there is XXXX.so files.
有一种方法......但它是一个简单的黑客。你可以绑定 armeabi 文件夹,里面有 XXXX.so 文件。
these are the native codes and as @Scott Barta said there isn't support in Android Gradle for native code.
这些是本机代码,正如@Scott Barta 所说,Android Gradle 不支持本机代码。
So lets wrap it like our normal jar files.. Step 1: create a folder and name it 'lib' Step 2: took the armeabi>xxxx.so files inside the lib folder. Setp 3: now zip the lib file and name the zipped file as XXXXX.zip.
所以让我们把它像我们普通的 jar 文件一样包装起来。 第 1 步:创建一个文件夹并将其命名为“lib” 第 2 步:将 armeabi>xxxx.so 文件放在 lib 文件夹中。Setp 3:现在压缩 lib 文件并将压缩文件命名为 XXXXX.zip。
Now the project structure will be XXXX.zip-lib-armeabi-xxxx.so
现在项目结构将是 XXXX.zip-lib-armeabi-xxxx.so
Step 4: Copy the zip file to Libs folder of android studio. Step 5: Rename the xxxx.zip to xxxx.jar Step 6: paste the code below in the dependency of gradle.
步骤4:将zip文件复制到android studio的Libs文件夹中。第五步:将xxxx.zip重命名为xxxx.jar 第六步:将下面的代码粘贴到gradle的依赖中。
dependencies { compile fileTree(dir: 'libs', include: '*.jar') }
依赖{编译文件树(目录:'libs',包括:'*.jar')}
Now Sync gradle and then run.
现在同步 gradle 然后运行。
Note: This armeabi will work only if the cpu of emulator is armeabi. For intel x86 you may need to create 'x86' folder inside zip and paste corresponding .so file in that folder.
注意:这个 armeabi 只有在模拟器的 cpu 是 armeabi 时才能工作。对于 intel x86,您可能需要在 zip 中创建“x86”文件夹并将相应的 .so 文件粘贴到该文件夹中。
This worked for me. try it :)
这对我有用。尝试一下 :)
Happy coding..
快乐编码..