我正在开发Google map v2 Android应用程序。它崩溃了,根本没有打开。我按照Google开发人员的教程进行了操作,并获得了我在Manifest文件中使用的API密钥
MainActivity.java
package com.example.maps;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
清单文件
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.maps.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>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCx7eq9mnY609bDebfAEeBLx8L2Exw8J30" />
</application>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<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" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</manifest>
这是logcat
12-27 14:12:43.490: D/SystemBroadcastService(766): Received broadcast action=android.intent.action.PACKAGE_CHANGED and uri=
12-27 14:13:13.410: D/dalvikvm(766): GC_FOR_ALLOC freed 324K, 13% free 2960K/3368K, paused 132ms, total 133ms
12-27 14:13:16.970: D/dalvikvm(766): No JNI_OnLoad found in /system/lib/libAppDataSearch.so 0xb3d364a0, skipping init
12-27 14:13:17.060: D/Icing(766): Default language: en
12-27 14:13:17.830: D/Icing(766): Upgrading storage to version to 0
12-27 14:13:18.930: D/Icing(766): Upgrading storage to version to 1
12-27 14:13:18.930: D/Icing(766): Upgrading storage to version to 2
12-27 14:13:18.930: D/Icing(766): Upgrading storage to version to 3
12-27 14:13:19.120: D/Icing(766): Upgrading storage to version to 4
12-27 14:13:19.120: D/Icing(766): Upgrading storage to version to 5
12-27 14:13:19.120: D/Icing(766): Upgrading storage to version to 6
12-27 14:13:19.120: D/Icing(766): Upgrading storage to version to 7
12-27 14:13:19.120: D/Icing(766): Upgrading storage to version to 8
12-27 14:13:19.120: D/Icing(766): Upgrading storage to version to 9
12-27 14:13:19.130: D/Icing(766): Upgrading storage to version to 10
12-27 14:13:19.130: D/Icing(766): Upgrading storage to version to 11
12-27 14:13:19.130: D/Icing(766): Upgrading storage to version to 12
12-27 14:13:19.130: D/Icing(766): Upgrading storage to version to 13
12-27 14:13:19.130: D/Icing(766): Upgrading storage to version to 14
12-27 14:13:19.130: D/Icing(766): Upgrading storage to version to 15
12-27 14:13:19.130: D/Icing(766): Upgrading storage to version to 16
12-27 14:13:19.130: D/Icing(766): Upgrading storage to version to 17
12-27 14:13:19.200: D/Icing(766): Upgrading storage to version to 18
12-27 14:13:19.200: D/Icing(766): Upgrading storage to version to 19
12-27 14:13:19.200: E/Icing(766): Opening file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/ds.urifps.h for write failed: No such file or directory
12-27 14:13:19.200: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/ds.urifps.h
12-27 14:13:19.200: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/ds.urifps.n
12-27 14:13:19.210: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/ds.urifps.x
12-27 14:13:19.210: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/ds.urifps.s
12-27 14:13:19.210: E/Icing(766): Couldn't create a URI mapping store
12-27 14:13:19.210: E/Icing(766): Couldn't upgrade native from version -1 to 26
12-27 14:13:19.210: E/Icing(766): Clearing storage
12-27 14:13:21.650: D/Icing(766): Clearing docstore and index
12-27 14:13:21.720: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.index
12-27 14:13:21.720: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.display.h
12-27 14:13:21.720: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.display.n
12-27 14:13:21.720: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.display.x
12-27 14:13:21.720: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.display.s
12-27 14:13:21.720: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.display.deleted
12-27 14:13:21.720: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.lexicon.h
12-27 14:13:21.720: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.lexicon.n
12-27 14:13:21.720: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.lexicon.x
12-27 14:13:21.720: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.lexicon.s
12-27 14:13:21.720: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.lexicon.deleted
12-27 14:13:21.830: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.hb
12-27 14:13:21.830: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lexicon.h
12-27 14:13:21.830: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lexicon.n
12-27 14:13:21.830: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lexicon.x
12-27 14:13:21.840: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lexicon.s
12-27 14:13:21.840: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lexicon.deleted
12-27 14:13:21.840: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.display.h
12-27 14:13:21.840: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.display.n
12-27 14:13:21.840: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.display.x
12-27 14:13:21.850: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.display.s
12-27 14:13:21.850: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.display.deleted
12-27 14:13:21.850: D/Icing(766): Clearing /data/data/com.google.android.gms/files/AppDataSearch/main/cur from uninitialized state
12-27 14:13:21.850: D/Icing(766): Removing all document store files for /data/data/com.google.android.gms/files/AppDataSearch/main/cur
12-27 14:13:21.850: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/ds.docids
12-27 14:13:21.850: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/ds.perdocdata
12-27 14:13:21.850: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/ds.cscoring
12-27 14:13:21.850: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/ds.docs
12-27 14:13:21.850: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/ds.urifps.h
12-27 14:13:21.850: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/ds.urifps.n
12-27 14:13:21.850: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/ds.urifps.x
12-27 14:13:21.850: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/ds.urifps.s
12-27 14:13:21.850: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/ds.urifps.deleted
12-27 14:13:21.930: D/Icing(766): Init last flush num docs 0 last docstore size 0
12-27 14:13:21.930: D/Icing(766): Docid map file has no data, nothing to scan
12-27 14:13:22.310: D/Icing(766): File /data/data/com.google.android.gms/files/AppDataSearch/main/cur/ds.perdocdata contains 0 records of size 6
12-27 14:13:22.810: D/Icing(766): Init docstore ok num docs 0 bytes 0
12-27 14:13:23.330: D/Icing(766): Block size 0: 4080
12-27 14:13:23.330: D/Icing(766): Block size 1: 2040
12-27 14:13:23.340: D/Icing(766): Block size 2: 1020
12-27 14:13:23.340: D/Icing(766): Block size 3: 510
12-27 14:13:23.340: D/Icing(766): Block size 4: 255
12-27 14:13:23.340: D/Icing(766): Block size 5: 125
12-27 14:13:23.340: D/Icing(766): Block size 6: 60
12-27 14:13:23.340: D/Icing(766): Block size 7: 30
12-27 14:13:23.340: D/Icing(766): Block size 8: 15
12-27 14:13:24.120: V/Icing(766): Creating new hit buffer
12-27 14:13:24.250: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.lexicon.h
12-27 14:13:24.550: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.lexicon.n
12-27 14:13:24.550: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.lexicon.x
12-27 14:13:24.550: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.lexicon.s
12-27 14:13:24.860: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.lexicon.deleted
12-27 14:13:25.190: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.display.h
12-27 14:13:25.190: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.display.n
12-27 14:13:25.190: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.display.x
12-27 14:13:25.190: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.display.s
12-27 14:13:25.350: D/Icing(766): Deleting file /data/data/com.google.android.gms/files/AppDataSearch/main/cur/idx.lite.display.deleted
12-27 14:13:25.510: V/Icing(766): Lite index crc computed in 1.692ms
12-27 14:13:25.510: V/Icing(766): Lite index created ok
12-27 14:13:25.520: V/Icing(766): Warming lite-index took 0.264ms
12-27 14:13:25.520: V/Icing(766): Warming lexicon took 0.084ms
12-27 14:13:25.520: V/Icing(766): Warming display mappings took 0.071ms
12-27 14:13:25.520: D/Icing(766): Init index ok num docs 0
12-27 14:13:25.520: D/Icing(766): Init done
12-27 14:13:40.790: D/dalvikvm(766): GC_FOR_ALLOC freed 432K, 15% free 3040K/3556K, paused 158ms, total 161ms
12-27 14:13:41.470: W/ContextImpl(766): Implicit intents with startService are not safe: Intent { act=com.google.android.gms.INITIALIZE } android.content.ContextWrapper.startService:494 android.content.ContextWrapper.startService:494 com.google.android.gms.init.InitializeGmsReceiver.onReceive:29
12-27 14:13:48.750: D/SystemBroadcastService(766): Received broadcast action=android.intent.action.PACKAGE_CHANGED and uri=
12-27 14:13:49.730: D/dalvikvm(766): GC_FOR_ALLOC freed 431K, 15% free 3121K/3636K, paused 579ms, total 582ms
12-27 14:14:25.701: D/SystemBroadcastService(766): Received broadcast action=android.intent.action.PACKAGE_CHANGED and uri=
12-27 14:14:25.741: W/ContextImpl(766): Implicit intents with startService are not safe: Intent { act=com.google.android.gms.INITIALIZE } android.content.ContextWrapper.startService:494 android.content.ContextWrapper.startService:494 com.google.android.gms.init.InitializeGmsReceiver.onReceive:29
12-27 14:14:34.611: I/PeopleSync(766): First sync
12-27 14:14:36.881: I/LocationInitializer(766): Initiliazing location.
12-27 14:14:37.001: I/PeopleDatabaseHelper(766): cleanUpNonGplusAccounts done.
12-27 14:14:37.081: I/PeopleSearchIndexManage(766): ICU version changed from unknown to 51.1.0.1
12-27 14:14:37.161: I/PeopleSearchIndexManage(766): Rebuilding index...
12-27 14:14:37.591: I/PeopleSearchIndexManage(766): Rebuilding index done.
12-27 14:14:37.641: V/GA-SERVICE(766): Thread[IntentService[InitializeIntentService],5,main]: Update service enabled state to: 2
12-27 14:14:37.991: E/MDM(766): Missing android_id
12-27 14:14:38.141: E/ProtoRequest(766): want to send authenticated request, but no Google account on device
12-27 14:14:38.961: D/dalvikvm(766): GC_FOR_ALLOC freed 355K, 12% free 3277K/3716K, paused 128ms, total 153ms
12-27 14:14:41.651: W/ActivityThread(766): ClassLoader.loadClass: The class loader returned by Thread.getContextClassLoader() may fail for processes that host multiple applications. You should explicitly specify a context class loader. For example: Thread.setContextClassLoader(getClass().getClassLoader());
12-27 14:14:42.101: D/Volley(766): [115] ot.a: HTTP response for request=<[ ] https://android.googleapis.com/nova/sitrep 0x58872a44 NORMAL 3> [lifetime=3869], [size=0], [rc=200], [retryCount=0]
12-27 14:14:42.171: V/AuthZen(1251): Received a GCM message.
12-27 14:14:42.271: D/dalvikvm(766): GC_FOR_ALLOC freed 436K, 14% free 3356K/3876K, paused 101ms, total 105ms
12-27 14:14:42.421: D/Volley(766): [1] oa.b: 4273 ms: [ ] https://android.googleapis.com/nova/sitrep 0x58872a44 NORMAL 3
12-27 14:14:45.611: V/AuthZen(1251): Authzen is disabled
12-27 14:15:05.181: V/AuthZen(1251): Received broadcast action: android.intent.action.BOOT_COMPLETED
12-27 14:15:05.281: V/AuthZen(1251): Received a GCM message.
12-27 14:15:05.371: V/AuthZen(1251): Authzen is disabled
12-27 14:15:35.941: W/ContextImpl(766): Implicit intents with startService are not safe: Intent { act=com.google.android.gms.INITIALIZE } android.content.ContextWrapper.startService:494 android.content.ContextWrapper.startService:494 com.google.android.gms.init.InitializeGmsReceiver.onReceive:29
12-27 14:15:41.611: D/dalvikvm(766): GC_FOR_ALLOC freed 492K, 15% free 3372K/3952K, paused 671ms, total 692ms
12-27 14:15:42.721: D/SystemBroadcastService(766): Received broadcast action=android.intent.action.PACKAGE_ADDED and uri=
12-27 14:15:42.761: W/ContextImpl(766): Implicit intents with startService are not safe: Intent { act=com.google.android.gms.games.service.INTENT } android.content.ContextWrapper.startService:494 com.google.android.gms.games.service.GamesIntentService.a:101 com.google.android.gms.games.service.GamesIntentService.b:368
12-27 14:15:49.411: W/ContextImpl(766): Implicit intents with startService are not safe: Intent { act=com.google.android.gms.INITIALIZE } android.content.ContextWrapper.startService:494 android.content.ContextWrapper.startService:494 com.google.android.gms.init.InitializeGmsReceiver.onReceive:29
12-27 14:15:49.811: D/SystemBroadcastService(766): Received broadcast action=android.intent.action.PACKAGE_CHANGED and uri=
12-27 14:15:50.211: D/SystemBroadcastService(766): Received broadcast action=android.intent.action.PACKAGE_CHANGED and uri=
12-27 14:15:52.031: V/GA-SERVICE(766): Thread[IntentService[RefreshEnabledStateService],5,main]: Update service enabled state to: 2
12-27 14:15:55.421: D/SystemBroadcastService(766): Received broadcast action=android.intent.action.PACKAGE_CHANGED and uri=
12-27 14:15:55.781: D/SystemBroadcastService(766): Received broadcast action=android.intent.action.PACKAGE_CHANGED and uri=
12-27 14:15:56.231: I/GCM(766): Message from Bundle[{registration_id=APA91bGB2_ju83eBD1jWGGKwz-4P4zCyKgPYs-v2hlH8B2Rl2jauU9Hip6oFKRL6LmrWWhzVsAhJtn-CdTAfkEMJWWtxvoIlkvwlTteBXNb3O51O7haOvAk1QGLkKd8r1i8yTyGwsC4XGyt5WNJX1LUrAecpp-4ktA}] null
12-27 14:15:58.531: V/GA-SERVICE(766): Thread[IntentService[RefreshEnabledStateService],5,main]: Update service enabled state to: 2
12-27 14:15:58.991: D/dalvikvm(766): GC_FOR_ALLOC freed 494K, 15% free 3390K/3968K, paused 332ms, total 332ms
12-27 14:15:59.511: W/Uploader(766): No account for auth token provided
12-27 14:16:01.281: V/GA-SERVICE(766): Thread[IntentService[RefreshEnabledStateService],5,main]: Update service enabled state to: 2
12-27 14:16:03.131: W/Uploader(766): No account for auth token provided
答案 0 :(得分:0)
看起来你在没有Google API的AVD上运行它。检查以确保Google API是AVD的一部分(谨防2.3上的许可问题:https://code.google.com/p/marketlicensing/issues/detail?id=27)
您可能必须使用真实设备:google maps api v2
即使使用Google API,看起来您需要确保您的AVD上设置了Google帐户。