2
votes

I'm working with the HelloGoogleMaps tutorial on the Android Developers' Resource page (http://developer.android.com/resources/tutorials/views/hello-mapview.html) and when I run part 1 of the application ("Creating a Map Activity") on my emulator, I get the message "The application HelloGoogleMaps (process com.example) has stopped unexpectedly. Please try again." I'm pretty sure that I followed all of the instructions correctly, however I'm not sure that I set up my emulator environment correctly. Can anyone please help me figure out what's going on? Thanks.

Here's the output from logcat:

I/ActivityManager(   63): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example/.HelloGoogleMaps }
I/ActivityManager(   63): Start proc com.example for activity com.example/.HelloGoogleMaps: pid=344 uid=10026 gids={3003, 1015}
D/ddm-heap(  344): Got feature list request
W/dalvikvm(  344): Class resolved by unexpected DEX: Lcom/example/HelloGoogleMaps;(0x43d02e18):0x11fbb0 ref [Lcom/google/android/maps/MapActivity;] Lcom/google/android/maps/MapActivity;(0x43d02e18):0x11f510
W/dalvikvm(  344): (Lcom/example/HelloGoogleMaps; had used a different Lcom/google/android/maps/MapActivity; during pre-verification)
W/dalvikvm(  344): Unable to resolve superclass of Lcom/example/HelloGoogleMaps; (41)
W/dalvikvm(  344): Link of class 'Lcom/example/HelloGoogleMaps;' failed
D/AndroidRuntime(  344): Shutting down VM
W/dalvikvm(  344): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
E/AndroidRuntime(  344): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime(  344): java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
E/AndroidRuntime(  344):     at dalvik.system.DexFile.defineClass(Native Method)
E/AndroidRuntime(  344):     at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:209)
E/AndroidRuntime(  344):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:203)
E/AndroidRuntime(  344):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
E/AndroidRuntime(  344):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
E/AndroidRuntime(  344):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime(  344):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
E/AndroidRuntime(  344):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
E/AndroidRuntime(  344):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
E/AndroidRuntime(  344):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
E/AndroidRuntime(  344):     at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(  344):     at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(  344):     at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime(  344):     at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(  344):     at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(  344):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime(  344):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime(  344):     at dalvik.system.NativeStart.main(Native Method)
I/Process (   63): Sending signal. PID: 344 SIG: 3
I/dalvikvm(  344): threadid=7: reacting to signal 3
E/dalvikvm(  344): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
W/ActivityManager(   63): Launch timeout has expired, giving up wake lock!
W/ActivityManager(   63): Activity idle timeout for HistoryRecord{43dc9818 com.example/.HelloGoogleMaps}
D/dalvikvm(  143): GC freed 2317 objects / 132032 bytes in 107ms
4

4 Answers

2
votes

Hi I am not sure if you are having the same problem as I had but make sure your maps and internet permission in your manifest are within the Activity brackets not the manifest i.e:

  </activity>
    <uses-library android:name="com.google.android.maps" />
   <uses-permission android:name="android.permission.INTERNET" />

<activity android:name=".champ" android:label="@string/app_name"

android:theme="@android:style/Theme.NoTitleBar">

1
votes

The following thing works (it shows a map and not just a grid):

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="ru.studiomobile.example"
  android:versionCode="1"
  android:versionName="1.0">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="@string/app_name" android:icon="@drawable/icon">
    <activity android:name="HelloMapsActivity"
              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>
    <uses-library android:name="com.google.android.maps" />
</application>
</manifest>

It is important where you put these uses-permission's. Also, I suspect that it began to work after adding ACCESS_COARSE_LOCATION.

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="9AaAaaaA7AAA_9AaAAARottenAAAAkMJD8h084Q"
/>

The key was obtained through the following two-step procedure:

step1:

$keytool -list -alias androiddebugkey -keystore ~/.android/debug.keystore -storepass android -keypass android
androiddebugkey, May 5, 2011, PrivateKeyEntry, 
Certificate fingerprint (MD5): 99:99:99:99:99:99:99:99:99:99:99:99:99:99:99:99

step2: that 99:99... was given to google at http://code.google.com/android/maps-api-signup.html and the key was obtained.

Without this key, MapView shows only a grid and does not work.

import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

public class HelloMapsActivity 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() {
        return false;
    }
}

But... I had to try with a release key and then with a debug key again before it worked. No idea what I have changed. Maybe the trick was to install it with a different certificate.

I have to add that

E/MapActivity Couldn't get connection factory client

does not really mean there's an error. The map works and still prints it in the log.

The log of a working application looks like this:

I/ActivityManager(  110): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=xx.yy.example/.HelloMapsActivity } from pid 211
I/ActivityManager(  110): Start proc xx.yy.example for activity xx.yy.example/.HelloMapsActivity: pid=21102 uid=10064 gids={3003, 1015}
V/RenderScript_jni(  211): surfaceDestroyed
D/dalvikvm(21102): GC_CONCURRENT freed 1163K, 54% free 3149K/6727K, external 1625K/2137K, paused 3ms+2ms
D/dalvikvm(21102): GC_CONCURRENT freed 532K, 51% free 3308K/6727K, external 1625K/2137K, paused 1ms+3ms
I/MapActivity(21102): Handling network change notification:CONNECTED
E/MapActivity(21102): Couldn't get connection factory client
D/dalvikvm(21102): GC_EXTERNAL_ALLOC freed 880K, 55% free 3034K/6727K, external 1993K/2137K, paused 23ms
I/ActivityManager(  110): Displayed xx.yy.example/.HelloMapsActivity: +584ms
1
votes

"uses-library" should be inside application tag. "uses-permission" should be outside application tag.

0
votes
You will also need to set up a new AVD that uses the same Google APIs deployment target

Have you done that?