我正在尝试启动Android原生应用,在Android模拟器中显示Google地图。但是,我无法在模拟器中执行此操作。
最初我尝试使用MapView
执行此操作。我使用的是Google Play Services版本4,它不喜欢Google Play Services第6版(最新版)
的 main.xml中 的
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android.clickable="true"
android.apiKey="<my_api_key>" />
的的AndroidManifest.xml 的
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:name="com.ccc.mygooglemaps.MyMapsActivity"
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>
</manifest>
的 MyMapsActivity.java 的
package com.ccc.mygooglemaps;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
import android.view.Menu;
public class MyMapsActivity extends MapActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.getMenuInflater().inflate(R.menu.my_maps, menu);
return true;
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
以下是在模拟器中启动MyMapsApp.apk应用程序的 LogCat (日志):
<br>05-03 17:37:28.936: W/ActivityThread(420): Application com.ccc.mygooglemaps is waiting for the debugger on port 8100...
<br>05-03 17:37:28.947: I/System.out(420): Sending WAIT chunk
<br>05-03 17:37:28.957: I/dalvikvm(420): Debugger is active
<br>05-03 17:37:28.976: I/System.out(420): Debugger has connected
<br>05-03 17:37:28.976: I/System.out(420): waiting for debugger to settle...
<br>05-03 17:37:30.842: I/System.out(420): debugger has settled (1405)
<br>05-03 17:37:42.516: D/dalvikvm(420): GC_CONCURRENT freed 273K, 45% free 3399K/6151K, external 410K/517K, paused 3ms+5ms
<br>05-03 17:37:51.552: D/AndroidRuntime(420): Shutting down VM
<br>05-03 17:37:51.552: W/dalvikvm(420): threadid=1: thread exiting with uncaught exception (group=0x40015560)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): FATAL EXCEPTION: main
<br>05-03 17:37:51.716: E/AndroidRuntime(420): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ccc.mygooglemaps/com.ccc.mygooglemaps.MyMapsActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class com.google.android.maps.MapView
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at android.os.Handler.dispatchMessage(Handler.java:99)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at android.os.Looper.loop(Looper.java:130)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at android.app.ActivityThread.main(ActivityThread.java:3683)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at java.lang.reflect.Method.invokeNative(Native Method)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at java.lang.reflect.Method.invoke(Method.java:507)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at dalvik.system.NativeStart.main(Native Method)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class com.google.android.maps.MapView
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at android.app.Activity.setContentView(Activity.java:1657)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at com.ccc.mygooglemaps.MyMapsActivity.onCreate(MyMapsActivity.java:24)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): ... 11 more
<br>05-03 17:37:51.716: E/AndroidRuntime(420): Caused by: java.lang.reflect.InvocationTargetException
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at java.lang.reflect.Constructor.constructNative(Native Method)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): ... 20 more
<br>05-03 17:37:51.716: E/AndroidRuntime(420): Caused by: java.lang.IllegalArgumentException: You need to specify an API Key for each MapView. See the MapView documentation for details.
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at com.google.android.maps.MapView.<init>(MapView.java:283)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at com.google.android.maps.MapView.<init>(MapView.java:264)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): at com.google.android.maps.MapView.<init>(MapView.java:247)
<br>05-03 17:37:51.716: E/AndroidRuntime(420): ... 23 more
<br>05-03 17:37:52.106: D/dalvikvm(420): GC_CONCURRENT freed 687K, 51% free 3112K/6279K, external 410K/517K, paused 4ms+5ms
<br>05-03 17:42:52.086: I/Process(420): Sending signal. PID: 420 SIG: 9
AVD(模拟器):
<br>AVD Name: MyMaps
<br>Device: 3.4" WQVGA (240 x 432:lpi)
<br>Target: Google APIs (Google Inc.) - API Level 10
<br>CPU/ABI: ARM (armeabi)
=============================================== ===================================
然后我尝试使用SupportMapFragment
执行此操作。我使用的是Google Play Services第4版,它不喜欢Google Play Services第6版(最新版)
的 main.xml中 的
<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=".MyMapsAppAPIv2Activity" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>
的的AndroidManifest.xml 的
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ccc.mygooglemaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="15" />
<permission
android:name="com.ccc.mygooglemaps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-permission android:name="com.ccc.mygooglemaps.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<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" >
<activity
android:name="com.ccc.mygooglemaps.MyMapsAppAPIv2Activity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="<my_api_key>" />
</application>
</manifest>
的 MyMapsAppAPIv2Activity.java 的
package com.ccc.mygooglemaps;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
public class MyMapsAppAPIv2Activity extends FragmentActivity {
private static final LatLng SYDNEY = new LatLng(-33.88,151.21);
private static final LatLng MOUNTAIN_VIEW = new LatLng(37.4, -122.1);
private GoogleMap map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
// Obtain the map from a MapFragment (API v2) or MapView (API v1)
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
map.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
map.setMyLocationEnabled(true);
// Move the camera instantly to Sydney, Australia with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(SYDNEY, 15));
// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomIn());
// Zoom out to zoom level 10, animating with a duration of 2 seconds.
map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
// Construct a CameraPosition focusing on Mountain View and animate the camera to that position.
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(MOUNTAIN_VIEW) // Sets the center of the map to Mountain View
.zoom(17) // Sets the zoom
.bearing(90) // Sets the orientation of the camera to east
.tilt(30) // Sets the tilt of the camera to 30 degrees
.build(); // Creates a CameraPosition from the builder
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.my_maps_app_apiv2, menu);
return true;
}
}
以下是在模拟器中启动MyMapsAppAPIv2.apk应用程序的 LogCat (日志):
<br>05-03 15:02:22.111: E/Trace(1032): error opening trace file: No such file or directory (2)
<br>05-03 15:02:22.272: W/ActivityThread(1032): Application com.ccc.mygooglemaps is waiting for the debugger on port 8100...
<br>05-03 15:02:22.371: I/System.out(1032): Sending WAIT chunk
<br>05-03 15:02:22.391: I/dalvikvm(1032): Debugger is active
<br>05-03 15:02:22.581: I/System.out(1032): Debugger has connected
<br>05-03 15:02:24.252: I/System.out(1032): waiting for debugger to settle...
<br>05-03 15:02:24.474: I/System.out(1032): debugger has settled (1401)
<br>05-03 15:02:29.872: E/ActivityThread(1032): Failed to find provider info for com.google.settings
<br>05-03 15:02:33.012: D/dalvikvm(1032): GC_CONCURRENT freed 142K, 2% free 11769K/11975K, paused 52ms+55ms, total 253ms
<br>05-03 15:02:34.672: D/libEGL(1032): Emulator without GPU support detected. Fallback to software renderer.
<br>05-03 15:02:34.682: D/libEGL(1032): loaded /system/lib/egl/libGLES_android.so
<br>05-03 15:02:34.714: I/Choreographer(1032): Skipped 66 frames! The application may be doing too much work on its main thread.
<br>05-03 15:02:34.992: D/gralloc_goldfish(1032): Emulator without GPU emulation detected.
<br>05-03 15:02:36.132: D/dalvikvm(1032): GC_CONCURRENT freed 231K, 3% free 12049K/12359K, paused 485ms+78ms, total 699ms
<br>05-03 15:02:36.132: D/dalvikvm(1032): WAIT_FOR_CONCURRENT_GC blocked 175ms
<br>05-03 15:02:36.352: D/dalvikvm(1032): GC_FOR_ALLOC freed 283K, 6% free 11918K/12551K, paused 131ms, total 134ms
<br>05-03 15:02:36.492: D/dalvikvm(1032): GC_FOR_ALLOC freed 305K, 6% free 11917K/12551K, paused 39ms, total 63ms
<br>05-03 15:02:36.652: I/Choreographer(1032): Skipped 67 frames! The application may be doing too much work on its main thread.
<br>05-03 15:02:36.944: D/dalvikvm(1032): GC_FOR_ALLOC freed 350K, 5% free 11929K/12551K, paused 119ms, total 146ms
<br>05-03 15:02:37.384: D/dalvikvm(1032): GC_FOR_ALLOC freed 319K, 5% free 11926K/12551K, paused 167ms, total 186ms
<br>05-03 15:02:38.072: D/dalvikvm(1032): GC_CONCURRENT freed 343K, 5% free 11998K/12551K, paused 76ms+87ms, total 268ms
AVD(模拟器):
<br>AVD Name: MyGoogleMaps
<br>Device: 4.65" 720p (720 x 1280:xhdpi)
<br>Target: Android 4.1.2 - API Level 16
<br>CPU/ABI: ARM (armeabi-v7a)
如果我将模拟器的目标从“Android 4.1.2 - API级别16”更改为“Google API(Google Inc.) - API级别16”,我会得到不同的结果和错误。
AVD(模拟器):
<br>AVD Name: MyGoogleMaps
<br>Device: 4.65" 720p (720 x 1280:xhdpi)
<br>Target: Google APIs (Google Inc.) - API Level 16
<br>CPU/ABI: ARM (armeabi-v7a)
logcat的
<br>05-03 19:40:59.118: E/Trace(859): error opening trace file: No such file or directory (2)
<br>05-03 19:40:59.188: W/ActivityThread(859): Application com.ccc.mygooglemaps is waiting for the debugger on port 8100...
<br>05-03 19:40:59.208: I/System.out(859): Sending WAIT chunk
<br>05-03 19:40:59.228: I/dalvikvm(859): Debugger is active
<br>05-03 19:40:59.418: I/System.out(859): Debugger has connected
<br>05-03 19:41:01.038: I/System.out(859): waiting for debugger to settle...
<br>05-03 19:41:01.238: I/System.out(859): debugger has settled (1361)
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): Signature not valid. Found:
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): EQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29n
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): bGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0wODA4MjEyMzEz
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): MzRaFw0zNjAxMDcyMzEzMzRaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYw
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): FAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5k
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): cm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBAKtW
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): LgDYO6IIrgqWbxJOKdoR8qtW0I9Y4sypEwPpt1TTcvZApxsdyxMJZ2JORland2qSGT2y5b+3JKke
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): dxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjA
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): sb/GEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/Cx
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): URaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJE
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): qO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/T
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): gt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYD
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIG
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): A1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): 4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/y
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): zKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCE
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): yj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1S
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): KMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifK
<br>05-03 19:41:02.648: W/GooglePlayServicesUtil(859): Z0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3Wf
<br>05-03 19:41:02.828: W/GooglePlayServicesUtil(859): MBEmh/9iFBDAaTCK
<br>05-03 19:41:02.828: W/GooglePlayServicesUtil(859): Google Play services signature invalid.
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): Signature not valid. Found:
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMw
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): EQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29n
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): bGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0wODA4MjEyMzEz
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): MzRaFw0zNjAxMDcyMzEzMzRaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYw
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): FAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5k
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): cm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBAKtW
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): LgDYO6IIrgqWbxJOKdoR8qtW0I9Y4sypEwPpt1TTcvZApxsdyxMJZ2JORland2qSGT2y5b+3JKke
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): dxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjA
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): sb/GEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/Cx
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): URaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJE
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): qO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/T
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): gt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYD
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIG
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): A1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): 4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/y
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): zKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCE
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): yj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1S
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): KMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifK
<br>05-03 19:41:02.878: W/GooglePlayServicesUtil(859): Z0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3Wf
<br>05-03 19:41:03.088: D/dalvikvm(859): threadid=1: still suspended after undo (sc=1 dc=1)
<br>05-03 19:41:03.118: D/dalvikvm(859): GC_CONCURRENT freed 290K, 4% free 10907K/11271K, paused 43ms+9ms, total 148ms
<br>05-03 19:41:41.878: D/AndroidRuntime(859): Shutting down VM
<br>05-03 19:41:41.878: W/dalvikvm(859): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
<br>05-03 19:41:41.950: E/AndroidRuntime(859): FATAL EXCEPTION: main
<br>05-03 19:41:41.950: E/AndroidRuntime(859): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ccc.mygooglemaps/com.ccc.mygooglemaps.MyMapsAppAPIv2Activity}: java.lang.NullPointerException
<br>05-03 19:41:41.950: E/AndroidRuntime(859): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
<br>05-03 19:41:41.950: E/AndroidRuntime(859): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
<br>05-03 19:41:41.950: E/AndroidRuntime(859): at android.app.ActivityThread.access$600(ActivityThread.java:130)
<br>05-03 19:41:41.950: E/AndroidRuntime(859): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
<br>05-03 19:41:41.950: E/AndroidRuntime(859): at android.os.Handler.dispatchMessage(Handler.java:99)
<br>05-03 19:41:41.950: E/AndroidRuntime(859): at android.os.Looper.loop(Looper.java:137)
<br>05-03 19:41:41.950: E/AndroidRuntime(859): at android.app.ActivityThread.main(ActivityThread.java:4745)
<br>05-03 19:41:41.950: E/AndroidRuntime(859): at java.lang.reflect.Method.invokeNative(Native Method)
<br>05-03 19:41:41.950: E/AndroidRuntime(859): at java.lang.reflect.Method.invoke(Method.java:511)
<br>05-03 19:41:41.950: E/AndroidRuntime(859): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
<br>05-03 19:41:41.950: E/AndroidRuntime(859): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
<br>05-03 19:41:41.950: E/AndroidRuntime(859): at dalvik.system.NativeStart.main(Native Method)
<br>05-03 19:41:41.950: E/AndroidRuntime(859): Caused by: java.lang.NullPointerException
<br>05-03 19:41:41.950: E/AndroidRuntime(859): at com.ccc.mygooglemaps.MyMapsAppAPIv2Activity.onCreate(MyMapsAppAPIv2Activity.java:51)
<br>05-03 19:41:41.950: E/AndroidRuntime(859): at android.app.Activity.performCreate(Activity.java:5008)
<br>05-03 19:41:41.950: E/AndroidRuntime(859): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
<br>05-03 19:41:41.950: E/AndroidRuntime(859): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
<br>05-03 19:41:41.950: E/AndroidRuntime(859): ... 11 more
<br>05-03 19:41:51.908: I/Process(859): Sending signal. PID: 859 SIG: 9
我下载了以下APK:
com.android.vending.apk
com.google.android.gms.apk
然后我使用ADB命令将它们安装到我的运行(目标)模拟器中:
DOS/Console Prompt> adb -e install [path-to-APK-file]
由于某种原因,地图不会出现或显示在原生应用中。任何想法!
我注意到了:
Google Maps Android API v1已于2012年12月3日正式弃用。这意味着从2013年3月18日起,您将无法再为此版本请求API密钥。 Google Maps Android API v1不会添加任何新功能。但是,使用v1的应用程序将继续在设备上运行。鼓励现有和新开发人员使用Google Maps Android API v2。
我不确定这是否与问题有关。
答案 0 :(得分:0)
答案 1 :(得分:0)
我已经创建了一个(德语)描述如何让它工作:
http://linuxchef.blogspot.de/2013/05/google-maps-api-v2-im-android-emulator.html
您基本上需要一个至少具有API级别9且没有Google API的模拟器。然后你必须从root设备上获取APK:
adb -d pull /data/app/com.android.vending-2.apk adb -d pull /data/app/com.google.android.gms-2.apk
并将它们安装在模拟器中:
adb -e install com.android.vending-2.apk adb -e install com.google.android.gms-2.apk
如果您的模拟器至少具有API级别14并且另外安装了com.google.android.apps.maps-1.apk
,您甚至可以运行原生Google地图应用玩得开心。