2014-09-29 246 views
0

我想在我的Android应用程序中集成谷歌地图,但在creatng apk之后,在手机上启动它(Android 4.4.4)它崩溃。如果我在模拟器上启动,我会收到消息“Failure [INSTALL_FAILED_MISSING_SHARED_LIBRARY]”。我能做什么不正确?谷歌地图V2 API集成问题

这里是我的文件

MainActivity.java

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); 
     } 
    } 
} 

,这里是我的布局

<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> 

清单文件

<?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> 
+0

只是检查,如果你读这篇文章的同一职位: http://stackoverflow.com/questions/1113088/install-failed-missing-shared-library-error-in-android – denden130 2014-09-29 21:29:49

+0

我这样做了。现在模拟器像电话一样崩溃 – Nickstery 2014-09-29 21:41:12

+0

由于您正在使用'SupportMapFragment'确保支持库已正确添加。 – ashoke 2014-09-30 00:07:22

回答

0

是您的模拟器的目标与谷歌设置API (谷歌公司)?上次我使用google map api时,我有相同的体验,并且在将目标设置为Google API(Google Inc。) - API Level(版本)之后,它的工作方式就起作用了。