question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NullPointerException when running on Android

See original GitHub issue

Hey @EddyVerbruggen,

Just tried out the plugin and it works great on iOS, but I’m getting the following error on Android:

JS: Error in mapbox.show: Error: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
JS:     android.view.ViewConfiguration.get(ViewConfiguration.java:359)
JS:     android.view.View.<init>(View.java:3587)
JS:     android.view.View.<init>(View.java:3682)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:497)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:493)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:489)
JS:     android.view.ViewGroup.<init>(ViewGroup.java:485)
JS:     android.widget.FrameLayout.<init>(FrameLayout.java:103)
JS:     com.mapbox.mapboxsdk.views.MapView.<init>(MapView.java:685)

Any idea what’s up? I’m testing on an Android 5.x emulator and I have showUserLocation turned off. Here’s the code I’m using:

mapbox.show({
    accessToken: "---MY TOKEN---",
    style: mapbox.MapStyle.EMERALD,
    margins: {
        left: 0,
        right: 0,
        top: 0,
        bottom: 300
    },
    showUserLocation: false,
    hideAttribution: true,
    hideLogo: true,
    hideCompass: true
});

Thanks.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:22

github_iconTop GitHub Comments

2reactions
tjvantollcommented, Jul 26, 2016

@MikeHuntington To my knowledge there are no updates, but the setTimeout() workaround has been working fine for me. Essentially the code is something like this:

import {Component} from "angular2/core";
var mapbox = require("nativescript-mapbox");

@Component({
  selector: "my-app",
  template: `
<StackLayout [loaded]="layoutLoaded()">
  ...
</StackLayout>
`
})
export class AppComponent {
  layoutLoaded() {
    setTimeout(showMap, 1000);
  }

  showMap() {
    mapbox.show({
      accessToken: "...",
      style: mapbox.MapStyle.EMERALD,
      showUserLocation: false
    });
  }
}

You can show an activity indicator or something in the time it takes to load the map if the delay is awkward.

1reaction
EddyVerbruggencommented, Oct 15, 2016

@Stavanger75 about to push an update that handles this delay automatically.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve NullPointerException error in Android?
NullPointerException means that mp is null. This means the MediaPlayer.create() failed. Does R.raw.alarm exist?
Read more >
NullPointerException - Android Developers
NullPointerException objects may be constructed by the virtual machine as if stack trace was ... Constructs a NullPointerException with no detail message.
Read more >
Frequent NullPointerException when running Android ...
The exception stack suggests this error is occurring because the layout resource does not contain expected elements, which is consistent with corruption of...
Read more >
NullPointerException after app launch fails in Android Emulator
I tried to run a Flutter app in the Android Emulator (Pixel 4 API 30), but that failed with a "Lost connection to...
Read more >
Android Studio NullPointerException in ... - Issue Tracker
I'm running Android Studio 0.3.5 and I'm constantly getting a NullPointerException whenever I click my run config to build and run my app....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found