I’m trying to use the google maps feature in android. I followed the instructions at https://developers.google.com/maps/documentation/android/hello-mapview. But when I run the app, there seems to be some kind of problem. I’m not sure what it is but the app won’t load.
Here is the errors listed in the 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 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
Can you tell me what’s wrong? Thanks for the help.
Here is the android manifest
<?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>
Here is the activity
package com.trainingcenter.maps;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class HelloGoogleMaps extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Here’s the main.xml file
<?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" />
Btw, I’m using Google API level 2.1 update 1
<uses-library android:name="com.google.android.maps" />Needs to be within the<application>tagEdit:
In your xml file, i’d also add the
android:enabled="true"