0

I have created a google map activity in android studio. I have also generated an api key from the link given and placed it in the appropriate place. But when I run the app it crashes without displaying anything. Here is the logcat

2018-12-19 16:13:00.080 17295-17295/? I/ik7.locationap: Not late-enabling -Xcheck:jni (already on)
2018-12-19 16:13:00.312 17295-17295/? W/ik7.locationap: Unexpected CPU variant for X86 using defaults: x86
2018-12-19 16:13:00.667 17295-17295/com.example.nik7.locationapp W/ik7.locationap: JIT profile information will not be recorded: profile file does not exits.
2018-12-19 16:13:00.669 17295-17295/com.example.nik7.locationapp I/chatty: uid=10087(com.example.nik7.locationapp) identical 10 lines
2018-12-19 16:13:00.670 17295-17295/com.example.nik7.locationapp W/ik7.locationap: JIT profile information will not be recorded: profile file does not exits.
2018-12-19 16:13:00.733 17295-17295/com.example.nik7.locationapp I/InstantRun: starting instant run server: is main process
2018-12-19 16:13:01.001 17295-17295/com.example.nik7.locationapp I/zzbz: Making Creator dynamically
2018-12-19 16:13:01.022 17295-17295/com.example.nik7.locationapp W/ik7.locationap: Unsupported class loader
2018-12-19 16:13:01.023 17295-17295/com.example.nik7.locationapp W/ik7.locationap: Skipping duplicate class check due to unsupported classloader
2018-12-19 16:13:01.033 17295-17295/com.example.nik7.locationapp I/DynamiteModule: Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:221
2018-12-19 16:13:01.033 17295-17295/com.example.nik7.locationapp I/DynamiteModule: Selected remote version of com.google.android.gms.maps_dynamite, version >= 221
2018-12-19 16:13:01.033 17295-17295/com.example.nik7.locationapp V/DynamiteModule: Dynamite loader version >= 2, using loadModule2NoCrashUtils
2018-12-19 16:13:01.113 17295-17295/com.example.nik7.locationapp W/ik7.locationap: Unsupported class loader
2018-12-19 16:13:01.131 17295-17295/com.example.nik7.locationapp W/ik7.locationap: Skipping duplicate class check due to unsupported classloader
2018-12-19 16:13:01.180 17295-17295/com.example.nik7.locationapp I/Google Maps Android API: Google Play services client version: 12451000
2018-12-19 16:13:01.192 17295-17295/com.example.nik7.locationapp I/Google Maps Android API: Google Play services package version: 14799040
2018-12-19 16:13:01.319 17295-17295/com.example.nik7.locationapp W/ik7.locationap: Accessing hidden field Ljava/nio/Buffer;->address:J (light greylist, reflection)
2018-12-19 16:13:01.712 17295-17295/com.example.nik7.locationapp D/OpenGLRenderer: HWUI GL Pipeline
2018-12-19 16:13:01.877 17295-17341/com.example.nik7.locationapp I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
2018-12-19 16:13:01.878 17295-17341/com.example.nik7.locationapp I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
2018-12-19 16:13:01.878 17295-17341/com.example.nik7.locationapp I/OpenGLRenderer: Initialized EGL, version 1.4
2018-12-19 16:13:01.878 17295-17341/com.example.nik7.locationapp D/OpenGLRenderer: Swap behavior 1
2018-12-19 16:13:01.883 17295-17341/com.example.nik7.locationapp W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
2018-12-19 16:13:01.883 17295-17341/com.example.nik7.locationapp D/OpenGLRenderer: Swap behavior 0
2018-12-19 16:13:01.907 17295-17341/com.example.nik7.locationapp D/EGL_emulation: eglCreateContext: 0xe8310280: maj 2 min 0 rcv 2
2018-12-19 16:13:01.913 17295-17341/com.example.nik7.locationapp D/EGL_emulation: eglMakeCurrent: 0xe8310280: ver 2 0 (tinfo 0xe7093fa0)
2018-12-19 16:13:02.025 17295-17341/com.example.nik7.locationapp D/EGL_emulation: eglMakeCurrent: 0xe8310280: ver 2 0 (tinfo 0xe7093fa0)
2018-12-19 16:13:02.034 17295-17338/com.example.nik7.locationapp D/EGL_emulation: eglCreateContext: 0xe9d05f00: maj 1 min 0 rcv 1
2018-12-19 16:13:02.229 17295-17338/com.example.nik7.locationapp D/EGL_emulation: eglMakeCurrent: 0xe9d05f00: ver 1 0 (tinfo 0xe9d03470)
2018-12-19 16:13:02.564 17295-17319/com.example.nik7.locationapp D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2018-12-19 16:13:03.305 17295-17319/com.example.nik7.locationapp E/AndroidRuntime: FATAL EXCEPTION: Thread-6
    Process: com.example.nik7.locationapp, PID: 17295
    java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion;
        at ez.b(:com.google.android.gms.dynamite_mapsdynamite@14799084@14.7.99 (100700-223214910):3)
        at ey.a(:com.google.android.gms.dynamite_mapsdynamite@14799084@14.7.99 (100700-223214910):3)
        at fa.a(:com.google.android.gms.dynamite_mapsdynamite@14799084@14.7.99 (100700-223214910):15)
        at com.google.maps.api.android.lib6.drd.al.a(:com.google.android.gms.dynamite_mapsdynamite@14799084@14.7.99 (100700-223214910):6)
        at ed.a(:com.google.android.gms.dynamite_mapsdynamite@14799084@14.7.99 (100700-223214910):21)
        at ed.run(:com.google.android.gms.dynamite_mapsdynamite@14799084@14.7.99 (100700-223214910):8)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.ProtocolVersion" on path: DexPathList[[zip file "/data/user_de/0/com.google.android.gms/app_chimera/m/00000015/MapsDynamite.apk"],nativeLibraryDirectories=[/data/user_de/0/com.google.android.gms/app_chimera/m/00000015/MapsDynamite.apk!/lib/x86, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at ad.loadClass(:com.google.android.gms.dynamite_dynamiteloader@14799084@14.7.99 (100700-223214910):4)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at ez.b(:com.google.android.gms.dynamite_mapsdynamite@14799084@14.7.99 (100700-223214910):3) 
        at ey.a(:com.google.android.gms.dynamite_mapsdynamite@14799084@14.7.99 (100700-223214910):3) 
        at fa.a(:com.google.android.gms.dynamite_mapsdynamite@14799084@14.7.99 (100700-223214910):15) 
        at com.google.maps.api.android.lib6.drd.al.a(:com.google.android.gms.dynamite_mapsdynamite@14799084@14.7.99 (100700-223214910):6) 
        at ed.a(:com.google.android.gms.dynamite_mapsdynamite@14799084@14.7.99 (100700-223214910):21) 
        at ed.run(:com.google.android.gms.dynamite_mapsdynamite@14799084@14.7.99 (100700-223214910):8) 
2018-12-19 16:13:03.338 17295-17295/com.example.nik7.locationapp E/SchedPolicy: set_timerslack_ns write failed: Operation not permitted
2018-12-19 16:13:03.379 17295-17319/com.example.nik7.locationapp I/Process: Sending signal. PID: 17295 SIG: 9

This is the compelte log.I have even tried by removing the restrictions but that didn't work. Whats the issue here. I have also seledted api 23 marshmallow. I have done nothing except entering the api key in its place

EDIT: I also included the key in the manifest but still the app is crashing

<meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="YOUR_API_KEY"/>
Zoe
  • 27,060
  • 21
  • 118
  • 148
Nikhil Rathore
  • 170
  • 2
  • 14
  • As you didn't provided your code i would suggest you to follow Map SDK for android documentation https://developers.google.com/maps/documentation/android-sdk/start – Arpan Dec 19 '18 at 18:43
  • Possible duplicate of [java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion](https://stackoverflow.com/questions/50461881/java-lang-noclassdeffounderrorfailed-resolution-of-lorg-apache-http-protocolve) – Martin Zeitler Jan 31 '19 at 13:23

2 Answers2

3

EDIT:

Seems to be an issue in API 28

To fix it add this code under application in your manifest file:

<uses-library android:name="org.apache.http.legacy" android:required="false"/>

Its probably because you dont have google play services installed. If you ran the app on your actual phone it would work just fine.

moe2theg
  • 46
  • 4
  • I too think that google play services are not installed. How can I install them – Nikhil Rathore Jan 31 '19 at 14:25
  • @NikhilRathore You go to tools SDK manager, check the "Show Package Details" in the lower right of the popup box, and on your AVD check that google services are installed. Also, when you open SDK Manger you will be at the SDK platforms page to do the above. Click on the SDK Tools and make sure google play services are also checked. It will isntall after you apply. I just tried to use a map view in the latest API it would crash immediately unless I added the "uses-library" code in my answer above. – moe2theg Jan 31 '19 at 17:55
1

To fix it, you either add this line of code inside the in the manifest

<uses-library android:name="org.apache.http.legacy" android:required="false"/>

Or to upgrade your play-services-maps in build.gradle to

implementation 'com.google.android.gms:play-services-maps:16.1.0'

That worked for me

elnaka
  • 41
  • 6