Closed zheng022 closed 9 years ago
How are you compiling the code? You're missing a dependency (okhttp). I suggest using Maven or Gradle to link against google-maps-services.
Marking as closed as it's not actually a bug with the library. You can also get some help over on stackoverflow.com
Hi, I just have a very stupid question: I have created a java application like this:
package test;
import com.google.maps.DistanceMatrixApi; import com.google.maps.GeoApiContext; import com.google.maps.GeocodingApi; import com.google.maps.model.DistanceMatrix; import com.google.maps.model.DistanceMatrixRow; import com.google.maps.model.GeocodingResult; import com.google.maps.model.TravelMode;
public class TestGoogle { public static void main(String[] args) { GeoApiContext context = new GeoApiContext().setApiKey("AIz***"); GeocodingResult[] results; try { results = GeocodingApi.geocode(context,"1600 Amphitheatre Parkway Mountain View, CA 94043").await(); System.out.println(results[0].formattedAddress); } catch (Exception e) { e.printStackTrace(); } } }
But when I ran it, I got an error: Exception in thread "main" java.lang.NoClassDefFoundError: com/squareup/okhttp/OkHttpClient at com.google.maps.GeoApiContext.(GeoApiContext.java:49)
at test.TestGoogle.main(TestGoogle.java:40)
Caused by: java.lang.ClassNotFoundException: com.squareup.okhttp.OkHttpClient
Do you know, what could be the reason? I have tried with both server key and browser key.
Thank you!