java.lang.UnsatisfiedLinkError:无法加载eposprint:findLibrary返回null

我正在使用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.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)

我的代码:

@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);
}

Epson的示例项目有一个扩展名为.so的本机文件.但即使我从示例项目中删除该文件也可以.

我也尝试将该文件添加到我的项目中.但是我无法将该文件添加到构建路径中.

我也提到了this link的多个答案,但我没有成功.

最佳答案
在检查了很多站点后,阅读了多个答案,最后我找到了解决方案.

创建文件夹树为:

|---src
     |---main
           |---jniLibs
                  |---armeabi
                         |---nativeLib.so

将文件放在armeabi文件夹下.它会奏效.

More about java.lang.unsatisfiedlinkerror

转载注明原文:java.lang.UnsatisfiedLinkError:无法加载eposprint:findLibrary返回null - 代码日志