gpt4 book ai didi

java - Android GPS V2 教程问题-Google map

转载 作者:行者123 更新时间:2023-12-02 06:01:23 25 4
gpt4 key购买 nike

我一直在使用本教程 [http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/]

它的 GPS map 位置应用程序可以获取您的位置或附近的位置。我和其他许多人对此进行了测试,似乎出现了错误,因为应用程序崩溃了。我已经更改了 SHA1 指纹和 Google API key 。代码没有错误,我已经导入了google play store。

有人对此有任何想法吗?我查看了网站上的评论,很多用户都遇到了同样的问题。这是 LogCat:

03-26 03:43:53.835: W/dalvikvm(15048): threadid=1: thread exiting with uncaught exception (group=0x42014700)
03-26 03:43:53.845: E/AndroidRuntime(15048): FATAL EXCEPTION: main
03-26 03:43:53.845: E/AndroidRuntime(15048): java.lang.RuntimeException: Unable to start activity ComponentInfo{info.androidhive.googlemapsv2/info.androidhive.googlemapsv2.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.app.ActivityThread.access$700(ActivityThread.java:159)
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.os.Handler.dispatchMessage(Handler.java:99)
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.os.Looper.loop(Looper.java:176)
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.app.ActivityThread.main(ActivityThread.java:5419)
03-26 03:43:53.845: E/AndroidRuntime(15048): at java.lang.reflect.Method.invokeNative(Native Method)
03-26 03:43:53.845: E/AndroidRuntime(15048): at java.lang.reflect.Method.invoke(Method.java:525)
03-26 03:43:53.845: E/AndroidRuntime(15048): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
03-26 03:43:53.845: E/AndroidRuntime(15048): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
03-26 03:43:53.845: E/AndroidRuntime(15048): at dalvik.system.NativeStart.main(Native Method)
03-26 03:43:53.845: E/AndroidRuntime(15048): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
03-26 03:43:53.845: E/AndroidRuntime(15048): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361)
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.app.Activity.setContentView(Activity.java:1956)
03-26 03:43:53.845: E/AndroidRuntime(15048): at info.androidhive.googlemapsv2.MainActivity.onCreate(MainActivity.java:24)
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.app.Activity.performCreate(Activity.java:5372)
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
03-26 03:43:53.845: E/AndroidRuntime(15048): ... 11 more
03-26 03:43:53.845: E/AndroidRuntime(15048): Caused by: java.lang.IllegalStateException: A required meta-data tag in your app's AndroidManifest.xml does not exist. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
03-26 03:43:53.845: E/AndroidRuntime(15048): at com.google.android.gms.common.GooglePlayServicesUtil.t(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048): at com.google.android.gms.maps.internal.q.B(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048): at com.google.android.gms.maps.internal.q.A(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048): at com.google.android.gms.maps.MapFragment$b.gW(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048): at com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048): at com.google.android.gms.dynamic.a.a(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.app.Activity.onCreateView(Activity.java:4965)
03-26 03:43:53.845: E/AndroidRuntime(15048): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695)
03-26 03:43:53.845: E/AndroidRuntime(15048): ... 21 more

最佳答案

你的 logcat 明确表示:

 Caused by: java.lang.IllegalStateException: A required meta-data tag in your app's AndroidManifest.xml does not exist.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
03-26 03:43:53.845: E/AndroidRuntime(15048): at com.google.android.gms.common.GooglePlayServicesUtil.t(Unknown Source)
03-26 03:43:53.845: E/AndroidRuntime(15048): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAv

将 Google Play 服务版本添加到您应用的 list 中

Edit your application's AndroidManifest.xml file, and add the following declaration within the element. This embeds the version of Google Play services that the app was compiled with.

您只需添加 <meta-data><application>标记到您的 AndroidManifest.xml

....<application>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>

这是因为最新的Google Play服务需要版本名称,可以使用<meta-data .. />来提及。里面AndroidManifest.xml

构建您的ma​​nifest.xml,如下所示:

....<application>
..............
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="APIKEY" />

<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

</application>

关于java - Android GPS V2 教程问题-Google map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22651192/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com