Okhttp: java.lang.NoSuchMethodError: No virtual method getHttpUrlChecked(Ljava/lang/String;)Lokhttp3/HttpUrl

Created on 22 Feb 2019  路  8Comments  路  Source: square/okhttp

Hello, everyone.

I am developing an Ionic App (hence I don't know much about Android).

Recently I am facing a problem since I installed two different cordova plugins which are:

When I install these two plugins and make a HTTP request, I get the following error:

java.lang.NoSuchMethodError: No virtual method getHttpUrlChecked(Ljava/lang/String;)Lokhttp3/HttpUrl; in class Lokhttp3/internal/Internal; or its super classes (declaration of 'okhttp3.internal.Internal' appears in /data/app/es.sanitas.hospitales.portalpaciente-1/base.apk)
        at okhttp3.internal.huc.OkHttpURLConnection.buildCall(OkHttpURLConnection.java:373)
        at okhttp3.internal.huc.OkHttpURLConnection.getResponse(OkHttpURLConnection.java:435)
        at okhttp3.internal.huc.OkHttpURLConnection.getResponseCode(OkHttpURLConnection.java:491)
        at okhttp3.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:106)
        at okhttp3.internal.huc.OkHttpsURLConnection.getResponseCode(OkHttpsURLConnection.java:26)
        at com.github.kevinsawicki.http.HttpRequest.code(HttpRequest.java:1758)
        at com.synconset.cordovahttp.CordovaHttp.returnResponseObject(CordovaHttp.java:247)
        at com.synconset.cordovahttp.CordovaHttpGet.run(CordovaHttpGet.java:30)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:776)

In the second plugin I've read that it uses proguard and that it could cause some problems so I modified it as I read as follows (but the problem is not gone):

# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html
-keepattributes Signature
-keepattributes Annotation
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**
-dontwarn okio.**

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
-keepclassmembers class fqcn.of.javascript.interface.for.webview {
   public *;
}

# Uncomment this to preserve the line number information for
# debugging stack traces.
-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
-renamesourcefileattribute SourceFile

Could anyone please give me a hand with this?

I've been a couple days with this problem and cant find out how to fix it. Please, help.

Thanks.

bug proguard

All 8 comments

Make sure the version of okhttp and okhttp-urlconnection are the same?

Make sure the version of okhttp and okhttp-urlconnection are the same?

Hi, they're the same.

https://github.com/square/okhttp/issues/3959 May be it isn't a bug in OkHttp

No clear action for us to take on this.

I now have this exact issue after upgrading from android to androidx and capacitor from 1.x to 2.x

@Keepertje make sure every OkHttp dependency is on the same OkHttp version. If you want you can use a platform dependency to make this easy:

dependencies {
   api(platform("com.squareup.okhttp3:okhttp-bom:4.7.2"))
   api("com.squareup.okhttp3:okhttp")              // No version!
   api("com.squareup.okhttp3:logging-interceptor") // No version!
}

@Keepertje make sure every OkHttp dependency is on the same OkHttp version. If you want you can use a platform dependency to make this easy:

dependencies {
   api(platform("com.squareup.okhttp3:okhttp-bom:4.7.2"))
   api("com.squareup.okhttp3:okhttp")              // No version!
   api("com.squareup.okhttp3:logging-interceptor") // No version!
}

Where you put this? In the build.gradle file?
Thanks

in my case, the problem was Firebase dependencies, i fix with this solution for every Firebase implementation.

implementation ('com.google.firebase:firebase-messaging:20.3.0'){
     exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

vanshg picture vanshg  路  3Comments

lyf571321556 picture lyf571321556  路  3Comments

yschimke picture yschimke  路  3Comments

tangjiabing picture tangjiabing  路  3Comments

theotherp picture theotherp  路  3Comments