【问题标题】:Genymotion just Doesnt launch GoogleMapsDemo Application-Eclipse.Genymotion 只是不启动 Google Maps Demo Application-Eclipse。
【发布时间】:2015-02-19 22:18:52
【问题描述】:

我下载了 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);

      }

     }

【问题讨论】:

标签: android eclipse google-maps sdk genymotion


【解决方案1】:
  1. 如果你想使用谷歌服务(如谷歌地图),你需要先为Android设置Google Play Services,你可以按照here的说明进行操作。 (获取您自己的 API 密钥,放入您的 AndroidManifest.xml 等)

  2. 建议您使用真机进行测试。如果你想使用Genymotion 作为模拟器,你还需要先get the google service。更多详情请参考here

【讨论】:

  • 首先感谢您的回答,但我已经完成了所有这些步骤。正如我在代码中提供的那样,我也有自己的 Api 密钥。我使用 Genymotion 作为模拟器。在我做了研究之后,我意识到我需要调试指纹。关于它的任何想法? @bjiang
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-05-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-28
  • 1970-01-01
相关资源
最近更新 更多