Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property \'getApplicationContext\' of undefined' #249

Open
jakubstankowski opened this issue Sep 25, 2020 · 8 comments
Open

Comments

@jakubstankowski
Copy link

jakubstankowski commented Sep 25, 2020

Hi,
when i want start my vue-nativescript aplication i get error Cannot read property \'getApplicationContext\' of undefined'

i use this version native script: "@nativescript/core": "^7.0.3",
and this nativescript-barcodescanner - "nativescript-barcodescanner": "^4.0.1",

there is my code: https://codesandbox.io/s/nativescript-vue-web-template-forked-iyjci

every logic is available in main.js, and in components > App.vue

I used Android 7 +

thanks for help!

@EddyVerbruggen
Copy link
Owner

That's usually a symptom of invoking the plugin too early. Can you wait until after the app has fully started?

@jakubstankowski
Copy link
Author

thanks for response!

i add this two solution for delay starting functionality, first i add a showButton flag to showing button, second in scanQrCode function i used setTimeout, unfortunetely this is not helping, i still get the same error

<Button v-if="showButton" class="btn btn-outline" text="Scan QR code" @tap="scanQrCode"/>

mounted() { this.showButton = true; },

scanQrCode() { setTimeout(() => { var barcodescanner = new BarcodeScanner(); barcodescanner.scan({ //basic options } ); }, 3000) },

this code is available here
`

@jakubstankowski
Copy link
Author

@EddyVerbruggen do you have some solution for this ?

@MarioCat
Copy link

MarioCat commented Oct 5, 2020

Hi,
I have the same issue. I did not try yet but I think that the problem is due to the new version : 4.0.1

Try downgrading to version 3.4.2

EDIT :

I have tried downgrading and it worked for me !

@jakubstankowski
Copy link
Author

@MarioCat which version of nativescript you have ? Because i have 7.0.9 and now i get this error: 'No scan: TypeError: Cannot read property \'client\' of undefined'

@MarioCat
Copy link

MarioCat commented Oct 6, 2020

@jakubstankowski I also have 7.0.9

@vincent7q
Copy link

vincent7q commented Oct 16, 2020

Same Error with below environments:

  1. Error: Cannot read property 'getApplicationContext' of undefined
    @nativescript/core: 7.0.11
    nativescript-barcodescanner: 4.0.1

  2. Error: Cannot read property 'client' of undefined
    @nativescript/core: 7.0.11
    nativescript-barcodescanner: 3.4.2

Solved by building and deploy with Apk

@vincent7q
Copy link

The error only happen on Preview. After build and install the apk (android) on mobile and works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants