gpt4 book ai didi

android - 谷歌地图 API v2。安卓

转载 作者:行者123 更新时间:2023-11-29 14:14:44 25 4
gpt4 key购买 nike

我正在尝试开发一个 Android 应用程序,它可以在谷歌地图上显示我的当前位置,但我在模拟器上显示 map 时遇到了困难。从昨天开始我就一直在处理这个问题,我尝试通过浏览类似的线程来寻找解决方案,但我无法弄清楚我的代码有什么问题。

这是我的日志:

    07-24 03:35:27.041: I/dalvikvm(1268): Could not find method 

android.app.AlertDialog$Builder.<init>, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.a
07-24 03:35:27.041: W/dalvikvm(1268): VFY: unable to resolve direct method 145: Landroid/app/AlertDialog$Builder;.<init> (Landroid/content/Context;I)V
07-24 03:35:27.041: D/dalvikvm(1268): VFY: replacing opcode 0x70 at 0x002c
07-24 03:35:27.051: I/dalvikvm(1268): Could not find method android.app.Activity.getFragmentManager, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.b
07-24 03:35:27.051: W/dalvikvm(1268): VFY: unable to resolve virtual method 94: Landroid/app/Activity;.getFragmentManager ()Landroid/app/FragmentManager;
07-24 03:35:27.051: D/dalvikvm(1268): VFY: replacing opcode 0x6e at 0x0023
07-24 03:35:27.051: D/dalvikvm(1268): VFY: dead code 0x0026-0030 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b (ILandroid/app/Activity;Landroid/support/v4/app/Fragment;ILandroid/content/DialogInterface$OnCancelListener;)Z
07-24 03:35:27.061: D/dalvikvm(1268): DexOpt: couldn't find field Landroid/content/res/Configuration;.smallestScreenWidthDp
07-24 03:35:27.061: W/dalvikvm(1268): VFY: unable to resolve instance field 60
07-24 03:35:27.061: D/dalvikvm(1268): VFY: replacing opcode 0x52 at 0x0012
07-24 03:35:27.061: D/dalvikvm(1268): VFY: dead code 0x0014-0018 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b (Landroid/content/res/Resources;)Z
07-24 03:35:27.081: D/AndroidRuntime(1268): Shutting down VM
07-24 03:35:27.081: W/dalvikvm(1268): threadid=1: thread exiting with uncaught exception (group=0xb5f054f0)
07-24 03:35:27.091: E/AndroidRuntime(1268): FATAL EXCEPTION: main
07-24 03:35:27.091: E/AndroidRuntime(1268): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.googlemapdemo/com.example.googlemapdemo.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
07-24 03:35:27.091: E/AndroidRuntime(1268): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
07-24 03:35:27.091: E/AndroidRuntime(1268): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-24 03:35:27.091: E/AndroidRuntime(1268): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-24 03:35:27.091: E/AndroidRuntime(1268): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-24 03:35:27.091: E/AndroidRuntime(1268): at android.os.Handler.dispatchMessage(Handler.java:99)
07-24 03:35:27.091: E/AndroidRuntime(1268): at android.os.Looper.loop(Looper.java:130)
07-24 03:35:27.091: E/AndroidRuntime(1268): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-24 03:35:27.091: E/AndroidRuntime(1268): at java.lang.reflect.Method.invokeNative(Native Method)
07-24 03:35:27.091: E/AndroidRuntime(1268): at java.lang.reflect.Method.invoke(Method.java:507)
07-24 03:35:27.091: E/AndroidRuntime(1268): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-24 03:35:27.091: E/AndroidRuntime(1268): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-24 03:35:27.091: E/AndroidRuntime(1268): at dalvik.system.NativeStart.main(Native Method)
07-24 03:35:27.091: E/AndroidRuntime(1268): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
07-24 03:35:27.091: E/AndroidRuntime(1268): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
07-24 03:35:27.091: E/AndroidRuntime(1268): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
07-24 03:35:27.091: E/AndroidRuntime(1268): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
07-24 03:35:27.091: E/AndroidRuntime(1268): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
07-24 03:35:27.091: E/AndroidRuntime(1268): at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:128)
07-24 03:35:27.091: E/AndroidRuntime(1268): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
07-24 03:35:27.091: E/AndroidRuntime(1268): at com.example.googlemapdemo.MainActivity.onCreate(MainActivity.java:17)
07-24 03:35:27.091: E/AndroidRuntime(1268): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-24 03:35:27.091: E/AndroidRuntime(1268): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-24 03:35:27.091: E/AndroidRuntime(1268): ... 11 more
07-24 03:35:27.091: E/AndroidRuntime(1268): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 5077000 but found 0. 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" />
07-24 03:35:27.091: E/AndroidRuntime(1268): at com.google.android.gms.common.GooglePlayServicesUtil.x(Unknown Source)
07-24 03:35:27.091: E/AndroidRuntime(1268): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
07-24 03:35:27.091: E/AndroidRuntime(1268): at com.google.android.gms.maps.internal.u.F(Unknown Source)
07-24 03:35:27.091: E/AndroidRuntime(1268): at com.google.android.gms.maps.internal.u.E(Unknown Source)
07-24 03:35:27.091: E/AndroidRuntime(1268): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
07-24 03:35:27.091: E/AndroidRuntime(1268): at com.google.android.gms.maps.SupportMapFragment$b.ju(Unknown Source)
07-24 03:35:27.091: E/AndroidRuntime(1268): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
07-24 03:35:27.091: E/AndroidRuntime(1268): at com.google.android.gms.dynamic.a.a(Unknown Source)
07-24 03:35:27.091: E/AndroidRuntime(1268): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
07-24 03:35:27.091: E/AndroidRuntime(1268): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
07-24 03:35:27.091: E/AndroidRuntime(1268): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:291)
07-24 03:35:27.091: E/AndroidRuntime(1268): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
07-24 03:35:27.091: E/AndroidRuntime(1268): ... 19 more

这是我的activity_main.xml

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />

GoogleMapDemo.manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.googlemapdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="20" />
<permission
android:name="com.example.mapdemo.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />

<uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAMQ0-kK-KaFM_SeGjn7Nv22WvETNRmRZc"
/>
</application>
</manifest>

最佳答案

在 Eclipse IDE 中创建 AVD 时使用 google api 19 版本模拟器。

map 仅在 google api 模拟器中可用。如果问题再次出现,请将模拟器的 SDK 更新到最新版本,然后重试。

关于android - 谷歌地图 API v2。安卓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24924790/

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