android - 谷歌地图 ApiV2 在 Android 2.3.7 上不断崩溃

标签 android

我按照 Google 在其开发者页面上提供的所有步骤构建了一个项目。该项目无法在我运行 2.3.7 的 Android 设备上运行。但是,它在运行 API 级别 19 的 eclipse 模拟器上运行。以下是 list 、xml 和 Java 的代码。 list

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.googmaps"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />
    <!-- OpenGL reference -->
    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="19" />
    <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" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <!-- GooglePaly Services Reference -->
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <activity
            android:name="com.example.googmaps.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>
        <!-- Key Reference -->
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="i don't want to paste the key here. but there is no prob with it" />
    </application>
</manifest>

这是 XML 代码

<?xml version="1.0" encoding="utf-8"?>
    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/map"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:name="com.google.android.gms.maps.MapFragment"/>

这是Java代码

package my.package;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

请再次注意,该应用程序在具有 API 19 的模拟器上运行。 感谢帮助。

最佳答案

改变这个

public class MainActivity extends Activity {

public class MainActivity extends FragmentActivity {

还有这个

android:name="com.google.android.gms.maps.MapFragment"/>

android:name="com.google.android.gms.maps.SupportMapFragment"/>

您的最小 sdk 是 10。因此您需要使用 SupportMapFragment,在这种情况下您需要扩展 FragmentActivity

使用API​​级别11以上的MapFragment

注意:在安装了 google play 服务的真实设备上进行测试。 Android 4.2.2 (API 17) Goole api 具有 google play 服务。检查以下链接中的第 3 点。因此,在以下版本的模拟器上进行测试将不起作用,因为谷歌地图需要谷歌播放服务。

http://developer.android.com/google/play-services/setup.html

关于android - 谷歌地图 ApiV2 在 Android 2.3.7 上不断崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22089429/

相关文章:

android - 如何在 Android 的 AWS Amplify 中指定存储路径。?

java - 在 Samsung Galaxy S 中添加 300 个联系人到组时出现 StringIndexOutOfBoundsException

java - 解决使用 SAX 解析器解析 xml 的安全问题

android - Android AsyncTask onPostExecution 中的空异常

android - 避免在 android 中重复 fill_parent & wrap_content & match_parent

android - 将 Card.IO 移植到 C# Xamarin Studio

android - 想要在后台应用程序时隐藏 Android toast

java - 多个屏幕上的 View 组(控件)

Android官方字母快速滚动查看

android - 对话框布局双层错误透明背景