谷歌地图v1在Android 10中崩溃 [英] Google maps v1 crashing in android 10
问题描述
我试图在我的android应用中使用google map v1,但是一旦我在android 10中打开地图活动,应用就会崩溃.
I'm trying to use google map v1, in my android app, but app crashes as soon as I open map activity in android 10.
*FATAL EXCEPTION: DataRequestDispatcher
Process: c.techahead.androidmapsv1, PID: 6646
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/client/HttpClient;
at com.google.android.maps.MapActivity.<init>(MapActivity.java:356)
at c.techahead.androidmapsv1.MainActivity.<init>(MainActivity.java:8)
at java.lang.Class.newInstance(Native Method)
at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
at android.support.v4.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:43)
at android.app.Instrumentation.newActivity(Instrumentation.java:1250)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3182)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
*
build.gradle
build.gradle
android {
compileSdkVersion 28
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 26
multiDexEnabled true
useLibrary 'org.apache.http.legacy'
}
dependencies {
provided files('libs/maps.jar')
compile files('libs/org.apache.http.legacy.jar')
compile files('libs/httpclient-4.0.3.jar')
}
推荐答案
Support for the Apache HTTP client was removed beginning with Android 9. What you need to do instead is add the following declaration:
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
在AndroidManifest.xml
的<application>
元素中的
.
within the <application>
element of your AndroidManifest.xml
.
请注意,如果您使用(或更新为)com.google.android.gms:play-services-maps:16.1.0
或更高版本,则完全不需要添加此内容.有关更多详细信息,请查看Google的文档.
Note that if you use (or update to) com.google.android.gms:play-services-maps:16.1.0
or above, then you don't need to add this at all. For more details check out Google's documentation.
希望这会有所帮助!
这篇关于谷歌地图v1在Android 10中崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!