google-maps-services-java icon indicating copy to clipboard operation
google-maps-services-java copied to clipboard

java.lang.NoClassDefFoundError: okhttp3/Interceptor

Open tovbinm opened this issue 2 years ago • 11 comments

java.lang.NoClassDefFoundError: okhttp3/Interceptor
    at com.google.maps.GeoApiContext$Builder.<init>(GeoApiContext.java:389)
Caused by: java.lang.ClassNotFoundException: okhttp3.Interceptor
    at jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    ... 9 more

Environment details

  1. Java 11
  2. Mac OS X 12.3.1
  3. com.google.maps:google-maps-services:2.1.0

Code example

new GeoApiContext.Builder().apiKey("...")

Additional information

The issue does not exist on com.google.maps:google-maps-services:2.0.0

tovbinm avatar Jun 06 '22 17:06 tovbinm

Happens on java 8 also An error occurred while executing a save: java.lang.NoClassDefFoundError: okhttp3/Interceptor] (APNX-1-4198-000)

raghulvishnudhinesh avatar Jun 07 '22 12:06 raghulvishnudhinesh

I see the okhttp 5.0.0-alpha7 jar has no class files in it. Is this a Java 9 modules thing? An issue with how okhttp published it?

❯ zipinfo okhttp-5.0.0-alpha.7.jar
Archive:  okhttp-5.0.0-alpha.7.jar
Zip file size: 13361 bytes, number of entries: 20
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 META-INF/
-rw-r--r--  2.0 unx       25 b- defN 22-Apr-27 03:58 META-INF/MANIFEST.MF
-rw-r--r--  2.0 unx      811 b- defN 22-Apr-27 03:58 META-INF/kotlin-project-structure-metadata.json
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 commonMain/
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 commonMain/default/
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/root_package/
-rw-r--r--  2.0 unx       12 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/root_package/0_.knm
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3.internal.http/
-rw-r--r--  2.0 unx     2751 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3.internal.http/1_http.knm
-rw-r--r--  2.0 unx      910 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3.internal.http/0_http.knm
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3/
-rw-r--r--  2.0 unx     8627 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3/0_okhttp3.knm
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3.internal/
-rw-r--r--  2.0 unx      650 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3.internal/0_internal.knm
-rw-r--r--  2.0 unx     1589 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3.internal/2_internal.knm
-rw-r--r--  2.0 unx     6109 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/package_okhttp3.internal/1_internal.knm
-rw-r--r--  2.0 unx       75 b- defN 22-Apr-27 03:58 commonMain/default/linkdata/module
-rw-r--r--  2.0 unx       95 b- defN 22-Apr-27 03:58 commonMain/default/manifest
drwxr-xr-x  2.0 unx        0 b- defN 22-Apr-27 03:58 commonMain/default/resources/
20 files, 21654 bytes uncompressed, 10097 bytes compressed:  53.4%

okhttp 4.9.3 has class files

benwaffle avatar Jun 07 '22 20:06 benwaffle

@arriolac is there any update or timeline for a fix?

pmayeur avatar Jun 13 '22 18:06 pmayeur

okhttp Version 5.0.0-alpha.4 is the first version without class files.

New: Change the build from Kotlin-JVM to Kotlin-multiplatform (which includes JVM). Both native and JavaScript platforms are unstable preview releases and subject to backwards-incompatible changes in forthcoming releases.

Selaron avatar Jun 14 '22 09:06 Selaron

I filed #839, which should resolve this issue.

Stephan202 avatar Jun 22 '22 20:06 Stephan202

If it is related to the kotlin-multiplatform change, that's here - https://github.com/square/okhttp/commit/3ad1912f783e108b3d0ad2c4a5b1b89b827e4db9.

@swankjesse, do you have any insight, could this NoClassDefFoundError be related to that commit

benwaffle avatar Jun 22 '22 21:06 benwaffle

We’re tracking this here: https://github.com/square/okhttp/issues/7339

In 5.x we adopted a Gradle feature for resolving artifacts that doesn’t work in Maven, so we’re going to update our builds to not require that feature.

swankjesse avatar Jun 22 '22 21:06 swankjesse

thanks! Does that issue apply even when just the library (google-maps-services-java) depends on okhttp3 and the app does not?

benwaffle avatar Jun 22 '22 21:06 benwaffle

Any updates on the fix?

raghulvishnudhinesh avatar Jul 05 '22 10:07 raghulvishnudhinesh

It would be nice if one of the maintainers had a look at #839.

Stephan202 avatar Jul 05 '22 11:07 Stephan202

Same problem here, due to this issue we can't update the jar from 2.0.0 to 2.1.0

irineuruiz avatar Sep 06 '22 16:09 irineuruiz

:tada: This issue has been resolved in version 2.1.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

googlemaps-bot avatar Oct 18 '22 20:10 googlemaps-bot

Any reason why the latest maven release is still v2.1.0?

https://search.maven.org/search?q=a:google-maps-services

https://mvnrepository.com/artifact/com.google.maps/google-maps-services

irineuruiz avatar Oct 25 '22 13:10 irineuruiz

Any reason why the latest maven release is still v2.1.0?

https://search.maven.org/search?q=a:google-maps-services

https://mvnrepository.com/artifact/com.google.maps/google-maps-services

+1

zhengcan avatar Oct 29 '22 14:10 zhengcan

Oops - looks like something borked in the release action. Just published as 2.1.2

amuramoto avatar Nov 03 '22 00:11 amuramoto

I just cloned the repo, built a jar with gradlew that's labeled 2.1.2 but I'm getting this error when I move the JAR to another project:

Exception in thread "main" java.lang.NoClassDefFoundError: okhttp3/Interceptor at com.google.maps.GeoApiContext$Builder.(GeoApiContext.java:389) at org.wayner.json.util.GoogleMapServices.test1(GoogleMapServices.java:24) at org.wayner.json.util.GoogleMapServices.main(GoogleMapServices.java:44) Caused by: java.lang.ClassNotFoundException: okhttp3.Interceptor at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ... 3 more

Any ideas?

pwayner avatar Feb 15 '23 17:02 pwayner

getting the same error with 2.2.0.

Caused by: java.lang.ClassNotFoundException: okhttp3.Interceptor not found by google-maps-2.1.0 [642] at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1597) at org.apache.felix.framework.BundleWiringImpl.access$300(BundleWiringImpl.java:79) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1982) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 158 common frames omitted

vijayselvas avatar Dec 26 '23 07:12 vijayselvas