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.

Crash when setting icon on marker from file

See original GitHub issue

Hi, I get a crash when using a custom image as a marker on Android.

I’m using Cordova 5.0.0 so that may be part of the issue.

I’ve tried using file:///, using www/, and using cdvfile:// and it crashes every time. It works with http:// though.

Crash logs using www/

/AndroidRuntime(19049): FATAL EXCEPTION: AsyncTask #2
E/AndroidRuntime(19049): Process: com.example.example, PID: 19049
E/AndroidRuntime(19049): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime(19049):    at android.os.AsyncTask$3.done(AsyncTask.java:304)
E/AndroidRuntime(19049):    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
E/AndroidRuntime(19049):    at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
E/AndroidRuntime(19049):    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
E/AndroidRuntime(19049):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
E/AndroidRuntime(19049):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/AndroidRuntime(19049):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/AndroidRuntime(19049):    at java.lang.Thread.run(Thread.java:818)
E/AndroidRuntime(19049): Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'android.app.Activity org.apache.cordova.CordovaInterface.getActivity()' on a null object reference
E/AndroidRuntime(19049):    at plugin.google.maps.PluginMarker$7.doInBackground(PluginMarker.java:716)
E/AndroidRuntime(19049):    at plugin.google.maps.PluginMarker$7.doInBackground(PluginMarker.java:683)
E/AndroidRuntime(19049):    at android.os.AsyncTask$2.call(AsyncTask.java:292)
E/AndroidRuntime(19049):    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
E/AndroidRuntime(19049):    ... 4 more

Crash logs using file:///:

E/AndroidRuntime(24243): FATAL EXCEPTION: AsyncTask #2
E/AndroidRuntime(24243): Process: com.example.example, PID: 24243
E/AndroidRuntime(24243): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime(24243):    at android.os.AsyncTask$3.done(AsyncTask.java:304)
E/AndroidRuntime(24243):    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
E/AndroidRuntime(24243):    at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
E/AndroidRuntime(24243):    at java.util.concurrent.FutureTask.run(FutureTask.java:242)
E/AndroidRuntime(24243):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
E/AndroidRuntime(24243):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/AndroidRuntime(24243):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/AndroidRuntime(24243):    at java.lang.Thread.run(Thread.java:818)
E/AndroidRuntime(24243): Caused by: java.lang.IllegalStateException: Not on the main thread
E/AndroidRuntime(24243):    at com.google.l.a.ce.b(Unknown Source)
E/AndroidRuntime(24243):    at com.google.maps.api.android.lib6.d.ct.a(Unknown Source)
E/AndroidRuntime(24243):    at com.google.maps.api.android.lib6.d.aq.b(Unknown Source)
E/AndroidRuntime(24243):    at com.google.android.gms.maps.model.internal.t.onTransact(SourceFile:169)
E/AndroidRuntime(24243):    at android.os.Binder.transact(Binder.java:380)
E/AndroidRuntime(24243):    at com.google.android.gms.maps.model.internal.zzl$zza$zza.setVisible(Unknown Source)
E/AndroidRuntime(24243):    at com.google.android.gms.maps.model.Marker.setVisible(Unknown Source)
E/AndroidRuntime(24243):    at plugin.google.maps.PluginMarker$1.onPostExecute(PluginMarker.java:161)
E/AndroidRuntime(24243):    at plugin.google.maps.PluginMarker$7.doInBackground(PluginMarker.java:728)
E/AndroidRuntime(24243):    at plugin.google.maps.PluginMarker$7.doInBackground(PluginMarker.java:683)
E/AndroidRuntime(24243):    at android.os.AsyncTask$2.call(AsyncTask.java:292)
E/AndroidRuntime(24243):    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
E/AndroidRuntime(24243):    ... 4 more

My directory structure is:

main-app/
    platform/
    plugins/
    www/
        js/
        img/
            marker.png

Relevant js code:

        var div = this.refs.mapCanvas.getDOMNode();

        // Initialize the map view
        var mapObj = plugin.google.maps.Map.getMap(div);
        mapObj.addEventListener(plugin.google.maps.event.MAP_READY, (map) => {
            Server.get("/markers")
                .then((res) => {
                    for (let marker of res.results) {
                        var [lat, lng] = $.map(marker.position.split(","), parseFloat);
                        var position = new plugin.google.maps.LatLng(lat, lng);
                        map.addMarker({
                            position: position,
                            title: marker.name,
                            icon: "file:///img/marker.png"
                        });
                    }
                });
        });

Any ideas on what might be causing this?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:48 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
leandro-shifteightcommented, Jun 24, 2015

I am getting the same error.

FATAL EXCEPTION: AsyncTask #1 Process:, PID: 7935 java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:300) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) at java.util.concurrent.FutureTask.setException(FutureTask.java:222) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818) Caused by: java.lang.NullPointerException: Attempt to invoke interface method ‘android.app.Activity org.apache.cordova.CordovaInterface.getActivity()’ on a null object reference at plugin.google.maps.PluginMarker$7.doInBackground(PluginMarker.java:716) at plugin.google.maps.PluginMarker$7.doInBackground(PluginMarker.java:683) at android.os.AsyncTask$2.call(AsyncTask.java:288) at java.util.concurrent.FutureTask.run(FutureTask.java:237) … 4 more

Any idea? I am using Cordova 5 too with https://github.com/Nipher/phonegap-googlemaps-plugin fork, It was working ok with the master branch here but is probably something with Cordova Android new version.

0reactions
wf9a5m75commented, Feb 15, 2017

This plugin does not support SVG path.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Marker tap leading to crash - android - Stack Overflow
Everything is working fine but after adding setInfoAdapter to map object ,marker that showing my current location leads to app crash when i...
Read more >
Goggle map crashed after drawing m… - Apple Developer
Goggle map crashed after drawing more than 1300 markers with custom color. I can draw more than around 8000 default red markers without...
Read more >
Fix Google Earth errors
Fix crashes and graphics issues. Here are some steps to try if you have ... Remove old files to add memory space. Google...
Read more >
How to fix Premiere Pro crash issues - Adobe Support
Learn how you can fix common Premiere Pro freezing or crashing issues using these six simple steps.
Read more >
Marker | Maps JavaScript API - Google Developers
Get the icon of the Marker . See MarkerOptions.icon . getLabel. getLabel(). Parameters: None. Return Value: ...
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