nstudio / nstudio/nativescript-plugins
Error when using BarcodeScannerView Tag in NativeScript Core
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 55
- Forks
- 42
- Avg merge
- 49m
- Merged PRs (30d)
- 1
Description
I have an error @nstudio/nativescript-barcodescanner plugin when using BarcodeScannerView Tag
Error
An uncaught Exception occurred on "main" thread.
Unable to start activity ComponentInfo{org.nativescript.app/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed
Error: Building UI from XML. @app-root.xml:1:1
> Building UI from XML. @main-page.xml:7:9
> Module '@nstudio/nativescript-barcodescanner' not found for element '@nstudio/nativescript-barcodescanner:BarcodeScannerView'.
> instanceType is not a constructor
StackTrace:
(file:///data/data/org.nativescript.app/files/app/vendor.js:17130:17)
at (file:///data/data/org.nativescript.app/files/app/vendor.js:17108:36)
at (file:///data/data/org.nativescript.app/files/app/vendor.js:48804:13)
at EasySAXParser.parse(file:///data/data/org.nativescript.app/files/app/vendor.js:12836:23)
at parse(file:///data/data/org.nativescript.app/files/app/vendor.js:48847:22)
at parse(file:///data/data/org.nativescript.app/files/app/vendor.js:17117:31)
at parseInternal(file:///data/data/org.nativescript.app/files/app/vendor.js:17052:15)
at loadInternal(file:///data/data/org.nativescript.app/files/app/vendor.js:16964:27)
at createViewFromEntry(file:///data/data/org.nativescript.app/files/app/vendor.js:16903:45)
at createRootView(file:///data/data/org.nativescript.app/files/app/vendor.js:2295:77)
at setActivityContent(file:///data/data/org.nativescript.app/files/app/vendor.js:25888:74)
at onCreate(file:///data/data/org.nativescript.app/files/app/vendor.js:25717:14)
at onCreate(file:///data/data/org.nativescript.app/files/app/vendor.js:25568:29)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3477)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3641)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2112)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7743)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: com.tns.NativeScriptException: Calling js method onCreate failed
Error: Building UI from XML. @app-root.xml:1:1
> Building UI from XML. @main-page.xml:7:9
> Module '@nstudio/nativescript-barcodescanner' not found for element '@nstudio/nativescript-barcodescanner:BarcodeScannerView'.
> instanceType is not a constructor
at com.tns.Runtime.callJSMethodNative(Native Method)
at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1302)
at com.tns.Runtime.callJSMethodImpl(Runtime.java:1188)
at com.tns.Runtime.callJSMethod(Runtime.java:1175)
at com.tns.Runtime.callJSMethod(Runtime.java:1153)
at com.tns.Runtime.callJSMethod(Runtime.java:1149)
at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:57)
at android.app.Activity.performCreate(Activity.java:8038)
at android.app.Activity.performCreate(Activity.java:8022)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1321)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3450)
... 11 more
Dependencies
"@nativescript/core": "~8.9.0"
"@nativescript/android": "8.9.1"
"@nstudio/nativescript-barcodescanner": "^5.0.1"
XML Code
<Page
xmlns="http://schemas.nativescript.org/tns.xsd"
navigatingTo="onNavigatingTo"
xmlns:Barcode="@nstudio/nativescript-barcodescanner">
<ActionBar title="My App" icon="" />
<StackLayout class="p-4">
<Barcode:BarcodeScannerView
class="scanner-round"
formats="QR_CODE, EAN_13"
beepOnScan="true"
reportDuplicates="true"
preferFrontCamera="false"
pause="pause"
scanResult="onScanResult" />
<Button text="Scan Barcode" tap="scanNow" class="-primary" />
</StackLayout>
</Page>
TS Code
import { Observable } from "@nativescript/core";
var context = new Observable();
export function onNavigatingTo(args) {
const page = args.object;
page.bindingContext = context;
}
export function pause(args) {
console.dir(args);
}
export function onScanResult(args) {
console.dir(args);
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the launch failure with the listed @nativescript/core, @nativescript/android, and @nstudio/nativescript-barcodescanner dependencies and the XML BarcodeScannerView declaration. Compare the XML namespace and component loading behavior with the plugin's supported usage. Done means the app launches and BarcodeScannerView is constructed without the reported module or constructor error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, typescript
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100