Genymotion just不启动Google Maps Demo Application-Eclipse。

时间:2014-12-21 17:57:58

标签: android eclipse google-maps sdk genymotion

我下载了GoogleMapsDemo应用程序的项目,它没有在Eclipse上出错。但是在genymotion模拟器中它一直说不幸的是应用程序无法启动。

它的MY Android清单:

<?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ca.sfu.cmpt276.bfraser"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="17" />

<permission
    android:name="ca.sfu.cmpt276.bfraser.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"/>
<uses-permission android:name="ca.sfu.cmpt276.bfraser.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"/>
<!-- The following two permissions are not required to use
     Google Maps Android API v2, but are recommended. -->
<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" >

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

    <activity
        android:name="ca.sfu.cmpt276.bfraser.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>
</application>

它是我的主要活动:

package ca.sfu.cmpt276.bfraser;

import android.app.Activity;
import android.os.Bundle;
 import android.view.Menu;
import android.view.View;

import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
 import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

 public class MainActivity extends Activity {
    private final LatLng LOCATION_BURNABY = new LatLng(49.27645, -122.917587);
    private final LatLng LOCATION_SURRREY = new LatLng(49.187500, -122.849000);

    private GoogleMap map;

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

    map  = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

    map.addMarker(new MarkerOptions().position(LOCATION_SURRREY).title("Find me here!"));
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
    }

     public void onClick_City(View v) {
     //     CameraUpdate update = CameraUpdateFactory.newLatLng(LOCATION_BURNABY);
    map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
    CameraUpdate update = CameraUpdateFactory.newLatLngZoom(LOCATION_BURNABY, 9);
    map.animateCamera(update);
     }
    public void onClick_Burnaby(View v) {
    map.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
    CameraUpdate update = CameraUpdateFactory.newLatLngZoom(LOCATION_BURNABY, 14);
    map.animateCamera(update);

     }
    public void onClick_Surrey(View v) {
    map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    CameraUpdate update = CameraUpdateFactory.newLatLngZoom(LOCATION_SURRREY, 16);
    map.animateCamera(update);

      }

     }

1 个答案:

答案 0 :(得分:0)

  1. 如果您想使用Google服务(例如Google地图),则需要先为Android设置Google Play Services,然后您可以按照here的说明进行操作。 (获取您自己的API密钥,放入AndroidManifest.xml等)

  2. 我建议您使用真实设备进行测试。如果您想将Genymotion用作模拟器,则还需要先get the google service。有关详细信息,请参阅here