java.lang.UnsatisfiedLinkError: 无法加载 eposprint: findLibrary 返回 null
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25340423/
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
java.lang.UnsatisfiedLinkError: Couldn't load eposprint: findLibrary returned null
提问by Paritosh
I am using Android Studio. I am using e-POS-Print.jar in my app. Whenever I run the code I get this error:
我正在使用 Android Studio。我在我的应用程序中使用 e-POS-Print.jar。每当我运行代码时,我都会收到此错误:
java.lang.ExceptionInInitializerError
at com.stc.printer.MyActivity.onCreate(MyActivity.java:48)
at android.app.Activity.performCreate(Activity.java:5163)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
at android.app.ActivityThread.access0(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4895)
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:994)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load eposprint: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:535)
at com.epson.eposprint.Print.<clinit>(Print.java:18)
at com.stc.printer.MyActivity.onCreate(MyActivity.java:48)
My code:
我的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
System.out.println("started");
printerName = getString(R.string.printername_t81ii);
language = Builder.MODEL_SOUTHASIA;
//bellow is line no. 48
Print newPrinter = new Print(getApplicationContext());
try{
newPrinter.openPrinter(deviceType, openDeviceName, enabled, interval);
}catch(Exception e){
System.out.println("Error");
e.printStackTrace();
newPrinter = null;
}
setPrinter(newPrinter);
}
The sample project from Epson is having one native file with .so extension. But even if I remove that file from sample project it works.
Epson 的示例项目有一个扩展名为 .so 的本机文件。但即使我从示例项目中删除该文件,它也能工作。
I also tried adding that file to my project. But I am not able to add that file to my build path.
我也尝试将该文件添加到我的项目中。但是我无法将该文件添加到我的构建路径中。
I also referred multiple answers from this linkbut I am unsuccessful.
我也从这个链接中提到了多个答案,但我没有成功。
回答by Paritosh
After checking many sites, reading multiple answers, finally I figured out the solution.
检查了许多网站,阅读了多个答案后,终于找到了解决方案。
Create folder tree as:
创建文件夹树为:
|---src
|---main
|---jniLibs
|---armeabi
|---nativeLib.so
Place your files under armeabi
folder. And it will work.
将您的文件放在armeabi
文件夹下。它会起作用。
More aboutjava.lang.unsatisfiedlinkerror
更多关于java.lang.unsatisfiedlinkerror