嗨,我正在尝试在 android 中运行一个显示 Google 地图的简单应用程序,但是每当我尝试在模拟器上运行时,它都会显示unfortunately gmap has stopped
。请帮帮我。这是我的代码
gmap清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.gmap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<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" >
<activity
android:name="com.example.gmap.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 com.example.gmap;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
public class MainActivity extends MapActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
活动主.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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:enabled="true"
android:apiKey="AIzaSyBS0vnUbvFlLYpqI9Q1IcAwh0mPuDNG07o" />
记录猫错误:
03-06 10:01:05.059: E/Trace(1934): error opening trace file: No such file or directory (2)
03-06 10:01:06.337: E/AndroidRuntime(1934): FATAL EXCEPTION: main
03-06 10:01:06.337: E/AndroidRuntime(1934): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.gmap/com.example.gmap.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.gmap.MainActivity" on path: /data/app/com.example.gmap-1.apk
03-06 10:01:06.337: E/AndroidRuntime(1934): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
03-06 10:01:06.337: E/AndroidRuntime(1934): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-06 10:01:06.337: E/AndroidRuntime(1934): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-06 10:01:06.337: E/AndroidRuntime(1934): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-06 10:01:06.337: E/AndroidRuntime(1934): at android.os.Handler.dispatchMessage(Handler.java:99)
03-06 10:01:06.337: E/AndroidRuntime(1934): at android.os.Looper.loop(Looper.java:137)
03-06 10:01:06.337: E/AndroidRuntime(1934): at android.app.ActivityThread.main(ActivityThread.java:5041)
03-06 10:01:06.337: E/AndroidRuntime(1934): at java.lang.reflect.Method.invokeNative(Native Method)
03-06 10:01:06.337: E/AndroidRuntime(1934): at java.lang.reflect.Method.invoke(Method.java:511)
03-06 10:01:06.337: E/AndroidRuntime(1934): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-06 10:01:06.337: E/AndroidRuntime(1934): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-06 10:01:06.337: E/AndroidRuntime(1934): at dalvik.system.NativeStart.main(Native Method)
03-06 10:01:06.337: E/AndroidRuntime(1934): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.gmap.MainActivity" on path: /data/app/com.example.gmap-1.apk
03-06 10:01:06.337: E/AndroidRuntime(1934): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
03-06 10:01:06.337: E/AndroidRuntime(1934): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-06 10:01:06.337: E/AndroidRuntime(1934): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-06 10:01:06.337: E/AndroidRuntime(1934): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
03-06 10:01:06.337: E/AndroidRuntime(1934): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
03-06 10:01:06.337: E/AndroidRuntime(1934): ... 11 more
03-06 10:07:29.661: E/AndroidRuntime(2071): FATAL EXCEPTION: main
03-06 10:07:29.661: E/AndroidRuntime(2071): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.gmap/com.example.gmap.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.gmap.MainActivity" on path: /data/app/com.example.gmap-1.apk
03-06 10:07:29.661: E/AndroidRuntime(2071): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
03-06 10:07:29.661: E/AndroidRuntime(2071): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-06 10:07:29.661: E/AndroidRuntime(2071): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-06 10:07:29.661: E/AndroidRuntime(2071): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-06 10:07:29.661: E/AndroidRuntime(2071): at android.os.Handler.dispatchMessage(Handler.java:99)
03-06 10:07:29.661: E/AndroidRuntime(2071): at android.os.Looper.loop(Looper.java:137)
03-06 10:07:29.661: E/AndroidRuntime(2071): at android.app.ActivityThread.main(ActivityThread.java:5041)
03-06 10:07:29.661: E/AndroidRuntime(2071): at java.lang.reflect.Method.invokeNative(Native Method)
03-06 10:07:29.661: E/AndroidRuntime(2071): at java.lang.reflect.Method.invoke(Method.java:511)
03-06 10:07:29.661: E/AndroidRuntime(2071): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-06 10:07:29.661: E/AndroidRuntime(2071): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-06 10:07:29.661: E/AndroidRuntime(2071): at dalvik.system.NativeStart.main(Native Method)
03-06 10:07:29.661: E/AndroidRuntime(2071): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.gmap.MainActivity" on path: /data/app/com.example.gmap-1.apk
03-06 10:07:29.661: E/AndroidRuntime(2071): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
03-06 10:07:29.661: E/AndroidRuntime(2071): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-06 10:07:29.661: E/AndroidRuntime(2071): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-06 10:07:29.661: E/AndroidRuntime(2071): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
03-06 10:07:29.661: E/AndroidRuntime(2071): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
03-06 10:07:29.661: E/AndroidRuntime(2071): ... 11 more
03-06 10:10:37.347: E/AndroidRuntime(2399): FATAL EXCEPTION: main
03-06 10:10:37.347: E/AndroidRuntime(2399): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.gmap/com.example.gmap.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.gmap.MainActivity" on path: /data/app/com.example.gmap-1.apk
03-06 10:10:37.347: E/AndroidRuntime(2399): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
03-06 10:10:37.347: E/AndroidRuntime(2399): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-06 10:10:37.347: E/AndroidRuntime(2399): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-06 10:10:37.347: E/AndroidRuntime(2399): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-06 10:10:37.347: E/AndroidRuntime(2399): at android.os.Handler.dispatchMessage(Handler.java:99)
03-06 10:10:37.347: E/AndroidRuntime(2399): at android.os.Looper.loop(Looper.java:137)
03-06 10:10:37.347: E/AndroidRuntime(2399): at android.app.ActivityThread.main(ActivityThread.java:5041)
03-06 10:10:37.347: E/AndroidRuntime(2399): at java.lang.reflect.Method.invokeNative(Native Method)
03-06 10:10:37.347: E/AndroidRuntime(2399): at java.lang.reflect.Method.invoke(Method.java:511)
03-06 10:10:37.347: E/AndroidRuntime(2399): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-06 10:10:37.347: E/AndroidRuntime(2399): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-06 10:10:37.347: E/AndroidRuntime(2399): at dalvik.system.NativeStart.main(Native Method)
03-06 10:10:37.347: E/AndroidRuntime(2399): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.gmap.MainActivity" on path: /data/app/com.example.gmap-1.apk
03-06 10:10:37.347: E/AndroidRuntime(2399): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
03-06 10:10:37.347: E/AndroidRuntime(2399): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-06 10:10:37.347: E/AndroidRuntime(2399): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-06 10:10:37.347: E/AndroidRuntime(2399): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
03-06 10:10:37.347: E/AndroidRuntime(2399): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
03-06 10:10:37.347: E/AndroidRuntime(2399): ... 11 more
03-06 10:15:48.487: E/Trace(2492): error opening trace file: No such file or directory (2)
03-06 10:15:49.018: E/AndroidRuntime(2492): FATAL EXCEPTION: main
03-06 10:15:49.018: E/AndroidRuntime(2492): java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.example.gmap/com.example.gmap.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.gmap.MainActivity" on path: /data/app/com.example.gmap-1.apk
03-06 10:15:49.018: E/AndroidRuntime(2492): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
03-06 10:15:49.018: E/AndroidRuntime(2492): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-06 10:15:49.018: E/AndroidRuntime(2492): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-06 10:15:49.018: E/AndroidRuntime(2492): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-06 10:15:49.018: E/AndroidRuntime(2492): at android.os.Handler.dispatchMessage(Handler.java:99)
03-06 10:15:49.018: E/AndroidRuntime(2492): at android.os.Looper.loop(Looper.java:137)
03-06 10:15:49.018: E/AndroidRuntime(2492): at android.app.ActivityThread.main(ActivityThread.java:5041)
03-06 10:15:49.018: E/AndroidRuntime(2492): at java.lang.reflect.Method.invokeNative(Native Method)
03-06 10:15:49.018: E/AndroidRuntime(2492): at java.lang.reflect.Method.invoke(Method.java:511)
03-06 10:15:49.018: E/AndroidRuntime(2492): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-06 10:15:49.018: E/AndroidRuntime(2492): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-06 10:15:49.018: E/AndroidRuntime(2492): at dalvik.system.NativeStart.main(Native Method)
03-06 10:15:49.018: E/AndroidRuntime(2492): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.gmap.MainActivity" on path: /data/app/com.example.gmap-1.apk
03-06 10:15:49.018: E/AndroidRuntime(2492): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
03-06 10:15:49.018: E/AndroidRuntime(2492): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-06 10:15:49.018: E/AndroidRuntime(2492): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-06 10:15:49.018: E/AndroidRuntime(2492): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
03-06 10:15:49.018: E/AndroidRuntime(2492): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
03-06 10:15:49.018: E/AndroidRuntime(2492): ... 11 more
03-06 10:16:57.220: E/AndroidRuntime(2520): FATAL EXCEPTION: main
03-06 10:16:57.220: E/AndroidRuntime(2520): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.gmap/com.example.gmap.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.gmap.MainActivity" on path: /data/app/com.example.gmap-1.apk
03-06 10:16:57.220: E/AndroidRuntime(2520): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
03-06 10:16:57.220: E/AndroidRuntime(2520): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-06 10:16:57.220: E/AndroidRuntime(2520): at
android.app.ActivityThread.access$600(ActivityThread.java:141)
03-06 10:16:57.220: E/AndroidRuntime(2520): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-06 10:16:57.220: E/AndroidRuntime(2520): at android.os.Handler.dispatchMessage(Handler.java:99)
03-06 10:16:57.220: E/AndroidRuntime(2520): at android.os.Looper.loop(Looper.java:137)
03-06 10:16:57.220: E/AndroidRuntime(2520): at android.app.ActivityThread.main(ActivityThread.java:5041)
03-06 10:16:57.220: E/AndroidRuntime(2520): at java.lang.reflect.Method.invokeNative(Native Method)
03-06 10:16:57.220: E/AndroidRuntime(2520): at java.lang.reflect.Method.invoke(Method.java:511)
03-06 10:16:57.220: E/AndroidRuntime(2520): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-06 10:16:57.220: E/AndroidRuntime(2520): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-06 10:16:57.220: E/AndroidRuntime(2520): at dalvik.system.NativeStart.main(Native Method)
03-06 10:16:57.220: E/AndroidRuntime(2520): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.gmap.MainActivity" on path: /data/app/com.example.gmap-1.apk
03-06 10:16:57.220: E/AndroidRuntime(2520): at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
03-06 10:16:57.220: E/AndroidRuntime(2520): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-06 10:16:57.220: E/AndroidRuntime(2520): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-06 10:16:57.220: E/AndroidRuntime(2520): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
03-06 10:16:57.220: E/AndroidRuntime(2520): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
03-06 10:16:57.220: E/AndroidRuntime(2520): ... 11 more