首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >谷歌地图v2 API集成问题

谷歌地图v2 API集成问题
EN

Stack Overflow用户
提问于 2014-09-30 05:17:29
回答 1查看 167关注 0票数 0

我试图将谷歌地图集成到我的android应用程序中,但在创建apk并在手机(Android 4.4.4)上启动它后,它崩溃了。如果我在模拟器上启动,我得到消息"Failure INSTALL_FAILED_MISSING_SHARED_LIBRARY“。我可以做哪些不正确的事情?

这是我的文件

MainActivity.java

代码语言:javascript
复制
private GoogleMap mMap;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tieride);

    SupportMapFragment mapFragment =
            (SupportMapFragment)     getSupportFragmentManager().findFragmentById(R.id.map);

    if (savedInstanceState == null) {
        // First incarnation of this activity.
        mapFragment.setRetainInstance(true);
    } else {

        mMap = mapFragment.getMap();
    }
    setUpMapIfNeeded();
}

@Override
protected void onResume() {
    super.onResume();
    setUpMapIfNeeded();
}

private void setUpMapIfNeeded() {
    if (mMap == null) {
        mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
                .getMap();
        if (mMap != null) {
            // Enabling MyLocation Layer of Google Map
            mMap.setMyLocationEnabled(true);
        }
    }
}

这是我的布局

代码语言:javascript
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context=".MainActivity" >


<fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment" />

</RelativeLayout> 

清单文件

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="there is my package" >

<application

    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

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

    <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="there is my key, which i got from API console"/>


    <uses-library android:name="com.google.android.maps" />

    <permission
            android:name="(there is my app path).permission.MAPS_RECEIVE"
            android:protectionLevel="signature"/>
    <uses-permission android:name="(there is my app path).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"/>

    <activity
        android:screenOrientation="portrait"
        android:name=".login.LoginActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:screenOrientation="portrait"
        android:name=".main.MainActivity"
        android:label="@string/thereismytitle" >
    </activity>
</application>

</manifest>
EN

回答 1

Stack Overflow用户

发布于 2014-09-30 05:49:41

您的仿真器目标是否设置为Google API (Google Inc.)?上次我使用google map api时,我也有过同样的体验,在我将目标设置为Google APIs (Google Inc.)-API Level (版本)后,它就可以工作了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26109076

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档