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)
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.
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 link but I am unsuccessful.
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.
More about java.lang.unsatisfiedlinkerror
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With