1

I am importing geoJSON data from .jsons files. It works very well with some files but not with others. I thought my files had problems but I tested them on geojson lint as well as geojson.io without issues.

Here is the stack:

FATAL EXCEPTION: main
Process: com.example.andrea.blank_test, PID: 8780
java.lang.NoSuchMethodError: No virtual method isClickable()Z in class Lcom/google/android/gms/maps/model/PolylineOptions; or its super classes (declaration of 'com.google.android.gms.maps.model.PolylineOptions' appears in /data/data/com.example.andrea.blank_test/files/instant-run/dex/slice-dependencies_2c16afb1f7a3d667bc9f1bb08f04b953876fdec1-classes.dex)
    at com.google.maps.android.geojson.GeoJsonLineStringStyle.toPolylineOptions(GeoJsonLineStringStyle.java:167)
    at com.google.maps.android.geojson.GeoJsonRenderer.addLineStringToMap(GeoJsonRenderer.java:297)
    at com.google.maps.android.geojson.GeoJsonRenderer.addFeatureToMap(GeoJsonRenderer.java:238)
    at com.google.maps.android.geojson.GeoJsonRenderer.addFeature(GeoJsonRenderer.java:166)
    at com.google.maps.android.geojson.GeoJsonRenderer.addLayerToMap(GeoJsonRenderer.java:117)
    at com.google.maps.android.geojson.GeoJsonLayer.addLayerToMap(GeoJsonLayer.java:112)

Here is my very simple code

int d = R.raw.geojson;
try {
    GeoJsonLayer layer = new GeoJsonLayer(map, d,
            getApplicationContext());
    layer.addLayerToMap();
} catch (Exception ex){
    Log.e("hey", ex.toString());
}

And here is one of my JSONs causing that bug

build.gradle (project) and build.gradle(app)

Any idea is welcome

Rayjax
  • 7,494
  • 11
  • 56
  • 82

2 Answers2

3

The problem is that the PolylineOptions implementation in Google Play Services version 8.3.0 does not include the isClickable() method.

It has been added in version 8.4.0, and if you take a look at the GeoJsonLineStringStyle.java history on GitHub you will see that it has changed 24 days ago to add polyline clickability. so to solve your problem you need to change your build.gradle from

compile 'com.google.android.gms:play-services:8.3.0'

to

compile 'com.google.android.gms:play-services:8.4.0'
antonio
  • 18,044
  • 4
  • 45
  • 61
  • Works. had to do this stuff also to upgrade to 8.4.0 http://stackoverflow.com/questions/34398191/found-com-google-android-gmsplay-services8-4-0-but-version-8-3-0-is-needed-fo – Rayjax Mar 16 '16 at 10:54
1

You may fail to add dependencies in your gradle file. Here is a short example: dependencies { compile 'com.google.android.gms:play-services:8.4.0' } But it is just my assumption. Maybe you fail to get google service in your application as well. If you can share more code, I can help you more.

Adam Lyu
  • 431
  • 1
  • 5
  • 17
  • project dependencies { classpath 'com.android.tools.build:gradle:2.0.0-beta6' classpath 'com.google.gms:google-services:1.5.0' } app dependencies { compile 'com.google.android.gms:play-services:8.3.0' compile 'com.google.maps.android:android-maps-utils:+'} Besides, I do not think its a dependency bug because maps works and some geoJSON works. its just some features which are crashing the whole thing, but on the online google maps they do not crash anything – Rayjax Mar 15 '16 at 10:35
  • added the detailed gradles to answer – Rayjax Mar 15 '16 at 10:39