Yermo / nativescript-mapbox

:statue_of_liberty: :tokyo_tower: :mount_fuji: Native OpenGL powered Maps, by Mapbox
MIT License
194 stars 94 forks source link

Show Map Function Crashes due to Null Pointer Exception #329

Open BMwanza opened 5 years ago

BMwanza commented 5 years ago

Hi Eddy,

I had to update to NS 6 including updating tns android to 6.0.0 due to some listview problems.

I am using version 4.3.1 of this plugin in, and now when I try call the mapview.show() function I get the following error:

I also tried setting a Timeout when pressing the button before calling the .show() method but no luck


System.err: Calling js method run failed
System.err: Error: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
System.err:     android.view.ViewConfiguration.get(ViewConfiguration.java:447)
System.err:     android.view.View.<init>(View.java:4806)
System.err:     android.view.View.<init>(View.java:4948)
System.err:     android.view.ViewGroup.<init>(ViewGroup.java:659)
System.err:     android.view.ViewGroup.<init>(ViewGroup.java:655)
System.err:     android.view.ViewGroup.<init>(ViewGroup.java:651)
System.err:     android.view.ViewGroup.<init>(ViewGroup.java:647)
System.err:     android.widget.FrameLayout.<init>(FrameLayout.java:78)
System.err:     com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242)
System.err:     com.tns.Runtime.callJSMethodImpl(Runtime.java:1122)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:1109)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:1089)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:1081)
System.err:     com.tns.gen.java.lang.Runnable.run(Unknown Source:5)
System.err:     android.os.Handler.handleCallback(Handler.java:873)
System.err:     android.os.Handler.dispatchMessage(Handler.java:99)
System.err:     android.os.Looper.loop(Looper.java:193)
System.err:     android.app.ActivityThread.main(ActivityThread.java:6669)
System.err:     java.lang.reflect.Method.invoke(Native Method)
System.err:     com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
System.err:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
System.err:
System.err: StackTrace:
System.err:     Frame: function:'showIt', file:'file:///node_modules/nativescript-mapbox/mapbox.js:456:0
System.err:     Frame: function:'invoke', file:'file:///node_modules/tns-core-modules/timer/timer.js:20:30
System.err:     Frame: function:'run', file:'file:///node_modules/tns-core-modules/timer/timer.js:24:0
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:1122)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1109)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1089)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1081)
System.err:     at com.tns.gen.java.lang.Runnable.run(Unknown Source:5)
System.err:     at android.os.Handler.handleCallback(Handler.java:873)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:99)
System.err:     at android.os.Looper.loop(Looper.java:193)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6669)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
System.err: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
System.err:     at android.view.ViewConfiguration.get(ViewConfiguration.java:447)
System.err:     at android.view.View.<init>(View.java:4806)
System.err:     at android.view.View.<init>(View.java:4948)
System.err:     at android.view.ViewGroup.<init>(ViewGroup.java:659)
System.err:     at android.view.ViewGroup.<init>(ViewGroup.java:655)
System.err:     at android.view.ViewGroup.<init>(ViewGroup.java:651)
System.err:     at android.view.ViewGroup.<init>(ViewGroup.java:647)
System.err:     at android.widget.FrameLayout.<init>(FrameLayout.java:78)
System.err:     ... 14 more```

Any ideas?
PlayNext commented 5 years ago

I think this is because NS 6 uses androidx. Unfortunatelly current plugin is not compatible with it yet. The options are to keep using NS 5.4.3 or try to add customization to the plugin code.

felixkrautschuk commented 4 years ago

@EddyVerbruggen are there any plans when this plugins gets updated to support NS 6.x?

Yermo commented 4 years ago

See my fork. There's a bit of work left to do, namely getting geolocation to work on Android and maybe paring down some console log messages before it will be merged here. I've been slammed for longer than expected. I'll eventually get to it, but if someone wants to take a crack at getting Android geolocation working for the current API level, it would help move things along. It'll be a few weeks yet before I can get to it.