React-native-mapbox-gl: No static method toHumanReadableAscii

Created on 27 Mar 2018  ·  40Comments  ·  Source: nitaliano/react-native-mapbox-gl

got the following error on runtime:

java.lang.NoSuchMethodError: No static method toHumanReadableAscii(Ljava/lang/String;)Ljava/lang/String; in class Lokhttp3/internal/Util

seems to be the same like here:
https://github.com/mapbox/mapbox-java/issues/726
https://github.com/mapbox/mapbox-gl-native/issues/11325

but how to fix it for react native, I installed the package from github:

"@mapbox/react-native-mapbox-gl": "git://github.com/mapbox/react-native-mapbox-gl.git",

Thanks,
Ben

Most helpful comment

here is workaround:

build.gradle

compile (project(':mapbox-react-native-mapbox-gl')) {
        compile ('com.squareup.okhttp3:okhttp:3.6.0') {
            force = true
        }
}

All 40 comments

tested with

"@mapbox/react-native-mapbox-gl": "^6.1.0",
and
"@mapbox/react-native-mapbox-gl": "6.0.3",

and got the same runtime error

I edit this file:
rctmgl/build.gradle

   compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.1@aar') {
        transitive=true
    }

it was 5.4.1 bevor, and in one post I see it will be fixed in 5.5.0, it seems to work

here is workaround:

build.gradle

compile (project(':mapbox-react-native-mapbox-gl')) {
        compile ('com.squareup.okhttp3:okhttp:3.6.0') {
            force = true
        }
}

Just an FYI: updating to Android version 5.5.1 will break the map snapshot functionality. It's probably safer to follow @krystianpach's approach.

Running "@mapbox/react-native-mapbox-gl": "^6.1.2-beta2" with this issue, any progress fixing this? What has to be done?

Exact same error with react-native: 0.57.0 and "@mapbox/react-native-mapbox-gl": "^6.1.3". Answer from @bemazo to update mapbox-android-sdk to 5.5.1 fixes the issue. What should we do?

@ferrannp don't upgrade. Follow @krystianpach's approach for now. This will be resolved when we get the latest Android SDK into the RN repo.

@krystianpach fixes issue even for react native 0.57.0

The workaround https://github.com/mapbox/react-native-mapbox-gl/issues/1139#issuecomment-379647942 does fix the issue even on RN 0.57.2 :)

I cannot get it to work with the workaround on 0.57.3.
I really hope they will do something about it, as people seem to face this issue for a long time now.

Workaround works for me in 0.57.3. Tried several hours ago. Check you are
doing right.

On Thu, Oct 18, 2018, 6:21 PM GrosJob notifications@github.com wrote:

The workaround does not work on 0.57.3 either.
I really hope they will do something about it, as people seem to face this
issue for a long time now...


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/mapbox/react-native-mapbox-gl/issues/1139#issuecomment-431051410,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACPAveV6YQs-H3Ggtig19avfKXSsuxXvks5umJyLgaJpZM4S8Xgt
.

Thank you for your answer, I started it back from the begenning and got it to work indeed =)

The workaround does fix crashes, but now map is empty... Did i miss something?
react-native: 0.57.4
screenshot_4

UPD: This was another problem #1041

After days of beating my head on desk, followed @krystianpach's approach. Works for RN 0.57.3

Same here...
Thank you so much @krystianpach. its working now...!!!

Same here.

environment

package.json

...

 "dependencies": {
    "@mapbox/react-native-mapbox-gl": "^6.1.3",
    "react": "16.6.1",
    "react-native": "0.57.5"
  },

...

@krystianpach Compilation can't pass, know what's going on? Thank you very much if you can help me.

image

Oh my God !!!
@mapbox_react-native-mapbox-gl @mapbox is followed by _ instead of -,
@bemazo How can there be such a naming method ? Make people puzzled .

image

We did @krystianpach's approach and now we're getting a lot of crashes in production. The bug is reported here: https://github.com/square/okhttp/issues/3438, and we really need to use a higher version of okhttp than 3.6.0. Any other way to solve this? Is there a better solution on the way?

Edit Seems to work when forcing 3.9.1 instead. Does not recommend anyone using 3.6.0 for now

@giantss It depends on what is registered inside the settings.gradle which includes the projects and gives them "new project names". You can define them yourself. We are using these lines, because gradle didn't like the @ sign in the project-name:

include ':mapbox-react-native-mapbox-gl'
project(':mapbox-react-native-mapbox-gl').projectDir = new File(rootProject.projectDir, '../node_modules/@mapbox/react-native-mapbox-gl/android/rctmgl')

@FibreFoX Thanks. Yes, plugin naming is rarely seen using the @ symbol . I use the way that the react native link is automatically added, the plugin name is with the @ symbol.

include ':mapbox-react-native-mapbox-gl'
project(':mapbox-react-native-mapbox-gl').projectDir = new File(rootProject.projectDir, '../node_modules/@mapbox/react-native-mapbox-gl/android/rctmgl')

This naming is good . 😊

here is workaround:

build.gradle

compile (project(':mapbox-react-native-mapbox-gl')) {
        compile ('com.squareup.okhttp3:okhttp:3.6.0') {
            force = true
        }
}

@mapbox_react-native-mapbox-gl @mapbox is followed by _ instead of -,

compile (project(':@mapbox_react-native-mapbox-gl')) {
        compile ('com.squareup.okhttp3:okhttp:3.6.0') {
            force = true
        }
        implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.1'
     } 

this worked for me.

@ferrannp don't upgrade. Follow @krystianpach's approach for now. This will be resolved when we get the latest Android SDK into the RN repo.

Hey. Are we going to see this issue fixed? This repo seems to never get updated anymore. RN repo uses very old versions of Mapbox native libraries.

Agree, this repo is just stale :( very pity because I like mapbox but this outdated library makes me consider other solutions

@krystianpach 's workaround works, but can someone please explain me what causes the issue?

Thank you @krystianpach. I tried a newer version of okhttp com.squareup.okhttp3:okhttp:3.11.0, but you specifically need com.squareup.okhttp3:okhttp:3.6.0.

For those that are still having issues after the workaround, I had multiple dependencies using okhttp so that was causing some issues. I forced the version 3.9.1 (which fixes the bug) in the project build.gradle:

allprojects {

    repositories {

        configurations.all {
            resolutionStrategy {
                force "com.squareup.okhttp3:okhttp:3.9.1"
            }
        }
    }

}

Anyone got this working for RN 0.58?

here is workaround:

build.gradle

compile (project(':mapbox-react-native-mapbox-gl')) {
        compile ('com.squareup.okhttp3:okhttp:3.6.0') {
            force = true
        }
}

thanks a lot @krystianpach, it works 100% for me using React Native 0.58.4 & Mapbox 6.1.3

here is workaround:

build.gradle

compile (project(':mapbox-react-native-mapbox-gl')) {
        compile ('com.squareup.okhttp3:okhttp:3.6.0') {
            force = true
        }
}

I am getting error :
compile is not method something like this.

With upcoming RN 0.59 they updated to a later version of okhttp ... does anyone know if this workaround still works?

With upcoming RN 0.59 they updated to a later version of okhttp ... does anyone know if this workaround still works?

See my previous answer. You can force any okhttp version in the project. Just use the same version that RN is using. okhttp fixed this in 3.9.1 so anything after that should be ok.

https://github.com/mapbox/react-native-mapbox-gl/issues/1139#issuecomment-460067369

I couldn't get it to work and it is likely my lack of knowledge of okhttp
dependency constraints within Android Studio/gradle etc.

On Thu, 21 Feb 2019 at 16:46, Danny Althoff notifications@github.com
wrote:

With upcoming RN 0.59 they updated to a later version of okhttp ... does
anyone know if this workaround still works?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/mapbox/react-native-mapbox-gl/issues/1139#issuecomment-466026103,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AKC35vuJnDKmwgSrS1d0lAy8cz5dQ5tJks5vPrFSgaJpZM4S8Xgt
.

All versions after 3.9.1 throw the error. RN 0.59-rc.2 uses 3.12.1

What do you say about mentioning krystianpach's workaround in https://github.com/mapbox/react-native-mapbox-gl/blob/master/android/install.md as known issue and temp solution until it is resolved?

finally succeeded

what were your minsdk, targetsdk, compilesdk, etc versions, when you
succeeded?

On Mon, 11 Mar 2019, 09:17 RagePu, notifications@github.com wrote:

finally succeeded


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/nitaliano/react-native-mapbox-gl/issues/1139#issuecomment-471429308,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AKC35jjLbwNEWgj_W_7fd0S5FmcY7v_-ks5vVgMhgaJpZM4S8Xgt
.

Oh my God !!!
@mapbox_react-native-mapbox-gl @mapbox is followed by _ instead of -,
@bemazo How can there be such a naming method ? Make people puzzled .

image

It actually completely depends on what you have in your settings.gradle file:

include ':mapbox-react-native-mapbox-gl'
project(':mapbox-react-native-mapbox-gl').projectDir = new File( rootProject.projectDir, './node_modules/@mapbox/react-native-mapbox-gl/android/rctmgl' )

You could have mapbox_funky-chicken_whoop and it would work, just as long as you call it that in your settings.gradle and then compile it with that name in your build.gradle.

compile project(':mapbox_funky-chicken_whoop') 

Just for referencing this, the current master-Branch does not need this hacky workaround, as a different version will be used:

https://github.com/nitaliano/react-native-mapbox-gl/pull/1543/files#diff-3cdbb53829ced746d6fe4a3a702677a5R40

Yes, please use master, it should be considerably less painful to use on Android.
Note: You may need to force match the version of Okhttp if it is used by your project already.

Can confirm, works great using master, specifically this last commit is what we're statically versioned to: https://github.com/nitaliano/react-native-mapbox-gl/commit/8629d43e89515c6d473244810182d8a7ed1f5fb1

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

olofd picture olofd  ·  3Comments

alexisohayon picture alexisohayon  ·  4Comments

igor9silva picture igor9silva  ·  3Comments

Amalp picture Amalp  ·  3Comments

madroneropaulo picture madroneropaulo  ·  4Comments