krushkamx / nativescript-hprt

Print to thermal printers from HPRT in your Nativescript application https://www.hprt.com/
MIT License
29 stars 16 forks source link

java.lang.NullPointerException when printing #17

Closed yclau closed 4 years ago

yclau commented 4 years ago

i using demo version and migrate to latest version, all connect is fine but when printing will shown out the error message

JS: ERROR Error: java.lang.NullPointerException: Attempt to invoke interface method 'int HPRTAndroidSDK.IPort.WriteData(byte[], int)' on a null object reference

JS: HPRTAndroidSDK.HPRTPrinterHelper.PrintText(HPRTPrinterHelper.java:2394) JS: com.tns.Runtime.callJSMethodNative(Native Method) JS: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242) JS: com.tns.Runtime.callJSMethodImpl(Runtime.java:1122) JS: com.tns.Runtime.callJSMethod(Runtime.java:1109) JS: com.tns.Runtime.callJSMethod(Runtime.java:1089) JS: com.tns.Runtime.callJSMethod(Runtime.java:1081) JS: com.tns.gen.java.lang.Object_vendor_115390_32_ClickListenerImpl.onClick(Object_vendor_115390_32_ClickListenerImpl.java:18)

JS: android.view.View.performClick(View.java:6663) JS: android.view.View.performClickInternal(View.java:6635) JS: android.view.View.access$3100(View.java:794)

JS: android.view.View$PerformClick.run(View.java:26199) JS: android.os.Handler.handleCallback(Handler.java:907) JS: android.os.Handler.dispatchMessage(Handler.java:105)

is it need use new hprt jar file or ?

davorpeic commented 4 years ago

Hi @yclau hey, hmm I'm using plugin with latest 6.3 version and didn't noticed the issue, but could be something with demo, will check it out.

thanks

yclau commented 4 years ago

this is my package.json

{ "description": "NativeScript Application", "license": "SEE LICENSE IN ", "readme": "NativeScript Application", "repository": "", "nativescript": { "id": "org.nativescript.nativescripttesthprt", "tns-android": { "version": "6.0.0" } }, "dependencies": { "@angular/animations": "8.0.0", "@angular/common": "8.0.0", "@angular/compiler": "8.0.0", "@angular/core": "8.0.0", "@angular/forms": "8.0.0", "@angular/http": "8.0.0-beta.10", "@angular/platform-browser": "8.0.0", "@angular/platform-browser-dynamic": "8.0.0", "@angular/router": "8.0.0", "nativescript-angular": "8.0.2", "nativescript-hprt": "^0.9.6", "nativescript-loading-indicator": "^2.4.0", "nativescript-theme-core": "~1.0.2", "reflect-metadata": "~0.1.8", "rxjs": "6.3.3", "rxjs-compat": "^6.5.4", "tns-core-modules": "6.0.1", "zone.js": "0.9.1" }, "devDependencies": { "babel-traverse": "6.25.0", "babel-types": "6.25.0", "babylon": "6.17.4", "lazy": "1.0.11", "typescript": "3.4.5", "tns-platform-declarations": "6.0.1", "nativescript-dev-webpack": "1.0.1", "@angular/compiler-cli": "8.0.0", "@ngtools/webpack": "8.0.0" } }

app.zip

this is my demo app folder , i added worker folder inside and i using Nativescript version 6.3.3.

Sorry can't upload 500 mb zip file to you. If anything need to confirm let me know.

Thank you.

yclau commented 4 years ago

I solved the problem. I pass wrong parameter when connect the printer. Because I see the parameter is port. Sorry my mistake.