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

Error: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.nfc.Tag.hasTech(int)' on a null object reference #40

Closed
larscifi opened this issue Jul 3, 2019 · 9 comments
Milestone

Comments

@larscifi
Copy link

larscifi commented Jul 3, 2019

Hi, when i try to write an nfc tag on android, the following error occurs:

I´m working with the latest version

[Error: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.nfc.Tag.hasTech(int)' on a null object reference JS: android.nfc.tech.Ndef.get(Ndef.java:146) JS: com.tns.Runtime.callJSMethodNative(Native Method) JS: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1203) JS: com.tns.Runtime.callJSMethodImpl(Runtime.java:1083) JS: com.tns.Runtime.callJSMethod(Runtime.java:1070) JS: com.tns.Runtime.callJSMethod(Runtime.java:1050) JS: com.tns.Runtime.callJSMethod(Runtime.java:1042) JS: com.tns.gen.org.nativescript.widgets.Async_CompleteCallback.onComplete(Async_CompleteCallback.java:20) JS: org.nativescript.widgets.Async$Http$HttpRequestTask.onPostExecute(Async.java:573) JS: org.nativescript.widgets.Async$Http$1$1.run(Async.java:304) JS: android.os.Handler.handleCallback(Handler.java:789) JS: android.os.Handler.dispatchMessage(Handler.java:98) JS: android.os.Looper.loop(Looper.java:180) JS: android.app.ActivityThread.main(ActivityThread.java:6950) JS: java.lang.reflect.Method.invo...

@a-backman
Copy link

a-backman commented Aug 16, 2019

Any progress on this issue? I get the same error.

I'm using Nativescript 6.0.2 btw.

@Fatfrido
Copy link

I've got the same problem with Nativescript 6.0.0.

@EddyVerbruggen
Copy link
Owner

Interestingly I can't reproduce this.. how do you trigger it exactly?

Looking at the stacktrace you could try and guard this line; only run that bit of code if tag is not null. You can go into node_modules/nativescript-nfc and give it a go.

@EddyVerbruggen EddyVerbruggen added this to the 4.0.2 milestone Aug 17, 2019
EddyVerbruggen added a commit that referenced this issue Aug 17, 2019
…od 'boolean android.nfc.Tag.hasTech(int)' on a null object reference #40
@EddyVerbruggen
Copy link
Owner

I'm just going to assume the aforementioned issue is the problem on your end, and publish 4.0.2 in a bit.

@Fatfrido
Copy link

So.. I quickly created a new project just to test the writing here (when an empty tag is discovered it should write a string to it). However, I still get this error.
I've also tried to guard the line @EddyVerbruggen mentioned earlier (thanks for your input, btw), but this part of the code is not executed, since I only try to write on empty tags, I guess.
I used Nativescript 6.0.0 and tested on Android 9.

@EddyVerbruggen
Copy link
Owner

@Fatfrido Thx for the repo. Indeed, when writing a tag I can reproduce this error.

@EddyVerbruggen EddyVerbruggen modified the milestones: 4.0.2, 4.0.3 Aug 17, 2019
EddyVerbruggen added a commit that referenced this issue Aug 17, 2019
…od 'boolean android.nfc.Tag.hasTech(int)' on a null object reference #40
@EddyVerbruggen
Copy link
Owner

@Fatfrido Should be much better with 4.0.3.

@Fatfrido
Copy link

@EddyVerbruggen thanks for the quick fix mate. You are awesome :D

@a-backman
Copy link

@EddyVerbruggen thanks for the fix!

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

No branches or pull requests

4 participants