java.lang.UnsatisfiedLinkError中:无法加载eposprint:findLibrary返回null [英] java.lang.UnsatisfiedLinkError: Couldn't load eposprint: findLibrary returned null
问题描述
我使用Android的工作室。我使用的E-POS-Print.jar在我的应用程序。每当我运行code我得到这个错误:
I am using Android Studio. I am using e-POS-Print.jar in my app. Whenever I run the code I get this error:
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.access$600(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)
我的code:
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);
}
这是爱普生示例项目具有的.so分机上的本机文件。但即使我删除示例项目,文件,它的工作原理。
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.
我也尝试添加该文件到我的项目。但我不能给文件添加到我的构建路径。
I also tried adding that file to my project. But I am not able to add that file to my build path.
我还提到多个答案从<一个href="http://stackoverflow.com/questions/9037966/android-ndk-java-lang-unsatisfiedlinkerror-findlibrary-returned-null">this链接但我没有成功。
I also referred multiple answers from this link but I am unsuccessful.
推荐答案
检查很多网站,阅读多个答案之后,我终于想通了该解决方案。
After checking many sites, reading multiple answers, finally I figured out the solution.
创建文件夹树:
|---src
|---main
|---jniLibs
|---armeabi
|---nativeLib.so
将您的文件,在 armeabi
文件夹。而且它会工作。
Place your files under armeabi
folder. And it will work.
<一个href="http://examples.java$c$cgeeks.com/java-basics/exceptions/java-lang-unsatisfiedlinkerror-how-to-handle-unsatisfied-link-error/">More关于 java.lang.UnsatisfiedLinkError中
这篇关于java.lang.UnsatisfiedLinkError中:无法加载eposprint:findLibrary返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!