I added nativescript-printer to an existing 6.5.3 project and instantiation of a Printer object causes the Android application to crash.
Line 17 of printer.android.ts causes the application to crash:
this.printManager = Utils.ad.getApplicationContext().getSystemService(android.content.Context.PRINT_SERVICE);
The problem is in the import of Utils. Older versions of @nativescript/core don't have 'ad' in the definition of Utils. I'm hesitant to upgrade @nativescript/core because previous attempts at upgrading the application to NS 7 did not go well.
Changing the import to
import * as utils from '@nativescript/core/utils/utils';
and changing line 17 to
this.printManager = utils.ad.getApplicationContext().getSystemService(android.content.Context.PRINT_SERVICE);
fixes this issue.
I added nativescript-printer to an existing 6.5.3 project and instantiation of a Printer object causes the Android application to crash.
Line 17 of printer.android.ts causes the application to crash:
this.printManager = Utils.ad.getApplicationContext().getSystemService(android.content.Context.PRINT_SERVICE);
The problem is in the import of Utils. Older versions of @nativescript/core don't have 'ad' in the definition of Utils. I'm hesitant to upgrade @nativescript/core because previous attempts at upgrading the application to NS 7 did not go well.
Changing the import to
import * as utils from '@nativescript/core/utils/utils';
and changing line 17 tothis.printManager = utils.ad.getApplicationContext().getSystemService(android.content.Context.PRINT_SERVICE);
fixes this issue.I've made a PR to fix the issue.