Android can';t在安卓系统中运行谷歌地图功能
我正在尝试在android中使用谷歌地图功能。我在办公室里按照指示做了。但当我运行应用程序时,似乎出现了某种问题。我不确定它是什么,但应用程序无法加载。 以下是logcat中列出的错误Android can';t在安卓系统中运行谷歌地图功能,android,maps,Android,Maps,我正在尝试在android中使用谷歌地图功能。我在办公室里按照指示做了。但当我运行应用程序时,似乎出现了某种问题。我不确定它是什么,但应用程序无法加载。 以下是logcat中列出的错误 07-26 02:01:01.771: ERROR/AndroidRuntime(158): ERROR: thread attach failed 07-26 02:01:06.761: ERROR/AndroidRuntime(211): Uncaught handler: thread main exit
07-26 02:01:01.771: ERROR/AndroidRuntime(158): ERROR: thread attach failed
07-26 02:01:06.761: ERROR/AndroidRuntime(211): Uncaught handler: thread main exiting due to uncaught exception
07-26 02:01:06.841: ERROR/AndroidRuntime(211): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.trainingcenter.maps/com.trainingcenter.maps.HelloGoogleMaps}: java.lang.ClassNotFoundException: com.trainingcenter.maps.HelloGoogleMaps in loader dalvik.system.PathClassLoader@43b7d958
07-26 02:01:06.841: ERROR/AndroidRuntime(211): Caused by: java.lang.ClassNotFoundException: com.trainingcenter.maps.HelloGoogleMaps in loader dalvik.system.PathClassLoader@43b7d958
07-26 02:01:06.931: ERROR/dalvikvm(211): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
07-26 02:01:17.400: ERROR/AndroidRuntime(242): ERROR: thread attach failed
07-26 02:01:26.391: ERROR/ActivityThread(63): Failed to find provider info for com.google.settings
07-26 02:02:24.580: ERROR/AndroidRuntime(323): ERROR: thread attach failed
07-26 02:07:12.640: ERROR/AndroidRuntime(417): Uncaught handler: thread main exiting due to uncaught exception
07-26 02:07:12.640: ERROR/AndroidRuntime(417): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.trainingcenter.maps/com.trainingcenter.maps.HelloGoogleMaps}: java.lang.ClassNotFoundException: com.trainingcenter.maps.HelloGoogleMaps in loader dalvik.system.PathClassLoader@43d02ee8
07-26 02:07:12.640: ERROR/AndroidRuntime(417): Caused by: java.lang.ClassNotFoundException: com.trainingcenter.maps.HelloGoogleMaps in loader dalvik.system.PathClassLoader@43d02ee8
你能告诉我怎么了吗?谢谢你的帮助
这是android清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.trainingcenter.maps" android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<uses-library android:name="com.google.android.maps" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".HelloGoogleMaps" android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
这是main.xml文件
<?xml version="1.0" encoding="utf-8"?>
<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="I inserted the API key here, I got it from http://code.google.com/android/maps-api-signup.html" />
顺便说一句,我使用的是谷歌API 2.1级更新1,需要在
标签中
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.trainingcenter.maps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/icon"
android:label="@string/app_name" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name=".HelloGoogleMaps"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
你把活动添加到你的清单了吗?我刚刚复制了我给出的链接中的代码。我将编辑问题以包含代码和清单现在让我们看看您的xml,您是否为其提供了map API密钥?我添加了xml部分。我在MapView中包含了API键,它起作用了。非常感谢。顺便说一句,我的代码中只有这个。输出是否仅为带有网格线的白色屏幕?或者出现了问题?您是在设备上运行还是在模拟器中运行?我相信人们在模拟器中不上网会有问题,但我可能错了。接下来检查你的API密钥,那是很久以前发生在我身上的。您是否确保在注册API密钥时获得了MD5 sum而不是SHA?我正在模拟器上运行。我不确定是否在模拟器中使用internet,我将试用浏览器。很抱歉,我不熟悉SHA,当我使用keytool生成密钥时,我得到了一个证书指纹(MD5),当我注册API密钥时,我使用了该密钥。事实证明,我没有从我使用的模拟器获得internet连接,我将尝试使用另一个模拟器,看看是否可以获得。我使用了另一个模拟器。有一个互联网连接。我可以浏览互联网,但应用程序的输出仍然是一样的
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.trainingcenter.maps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/icon"
android:label="@string/app_name" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name=".HelloGoogleMaps"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<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:enabled="true"
android:apiKey="I inserted the API key here, I got it from http://code.google.com/android/maps-api-signup.html"
android:clickable="true" />