App crashes when running maps activity

前端 未结 3 1850
[愿得一人]
[愿得一人] 2020-12-11 01:38

My projects Map activity is not working
I just pasted the api key in place google_maps_api.xml and clicked run

Logcat:

E/Andr

相关标签:
3条回答
  • 2020-12-11 01:45

    I've found another solution at Android Google maps java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion

    Just add this in your manifest:

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

    Update:

    Starting from Google Maps SDK version 16.1.0 you can skip adding the solution above as the tag has been added to the AndroidManifest of the maps library.

    https://developers.google.com/maps/documentation/android-sdk/releases#2019-02-06

    Added the following declaration to the AndroidManifest.xml to support the Apache HTTP client on Android P and above. After updating to com.google.android.gms:play-services-maps:16.1.0 you can remove this line from your own AndroidManifest.xml. (Issue 117591497)

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

    0 讨论(0)
  • 2020-12-11 01:52

    The same problem here when using target SDK 28. Reverting to SDK 27 solved the problem.


    Don't revert your target SDK.

    Better use this solution https://stackoverflow.com/a/50944537/5710605

    0 讨论(0)
  • 2020-12-11 02:01

    Put this in the Manifest tag:

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

    More info: https://issuetracker.google.com/issues/79478779

    as google documentation said:

    If you are using com.google.android.gms:play-services-maps:16.0.0 or below and your app is targeting API level 28 (Android 9.0) or above, you must include the following declaration within the element of AndroidManifest.xml.

    0 讨论(0)
提交回复
热议问题