user1129139
user1129139

Reputation:

How To Display Google Map in android emulator?I tried this program in google AVD in android

Here is my code to display the google map in my android emulator using google AVD.... How to fix this problem?anybody can know this?

Map.java:

    public class MapsActivity extends MapActivity 
    {    
        private MapView mapView;
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            mapView = (MapView) findViewById(R.id.mapView);      
            mapView.setBuiltInZoomControls(true);
        }

        @Override
        protected boolean isRouteDisplayed() {
            return false;
        }

Xml File:

        <com.google.android.maps.MapView 
            android:id="@+id/mapView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:enabled="true"
            android:clickable="true"
            android:apiKey="0l4sCTTyRmXTNo7k8DREHvEaLar2UmHGwnhZVHQ"
            >
            </com.google.android.maps.MapView>

Manifost File:

                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>
    <uses-permission android:name="android.permission.INTERNET" />  
 <uses-library android:name="com.google.android.maps" /> 

Output: In my emulator map activity has stopped unexpexctly.. i got the runtime exception

01-04 10:36:24.540: D/dalvikvm(641): Not late-enabling CheckJNI (already on)
01-04 10:36:25.290: W/dalvikvm(641): Unable to resolve superclass of Lcom/example/MapsActivity; (10)
01-04 10:36:25.290: W/dalvikvm(641): Link of class 'Lcom/example/MapsActivity;' failed
01-04 10:36:25.290: D/AndroidRuntime(641): Shutting down VM
01-04 10:36:25.290: W/dalvikvm(641): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
01-04 10:36:25.430: E/AndroidRuntime(641): FATAL EXCEPTION: main
01-04 10:36:25.430: E/AndroidRuntime(641): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example/com.example.MapsActivity}: java.lang.ClassNotFoundException: com.example.MapsActivity
01-04 10:36:25.430: E/AndroidRuntime(641):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
01-04 10:36:25.430: E/AndroidRuntime(641):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
01-04 10:36:25.430: E/AndroidRuntime(641):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
01-04 10:36:25.430: E/AndroidRuntime(641):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
01-04 10:36:25.430: E/AndroidRuntime(641):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-04 10:36:25.430: E/AndroidRuntime(641):  at android.os.Looper.loop(Looper.java:137)
01-04 10:36:25.430: E/AndroidRuntime(641):  at android.app.ActivityThread.main(ActivityThread.java:4424)
01-04 10:36:25.430: E/AndroidRuntime(641):  at java.lang.reflect.Method.invokeNative(Native Method)
01-04 10:36:25.430: E/AndroidRuntime(641):  at java.lang.reflect.Method.invoke(Method.java:511)
01-04 10:36:25.430: E/AndroidRuntime(641):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-04 10:36:25.430: E/AndroidRuntime(641):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-04 10:36:25.430: E/AndroidRuntime(641):  at dalvik.system.NativeStart.main(Native Method)
01-04 10:36:25.430: E/AndroidRuntime(641): Caused by: java.lang.ClassNotFoundException: com.example.MapsActivity
01-04 10:36:25.430: E/AndroidRuntime(641):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
01-04 10:36:25.430: E/AndroidRuntime(641):  at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-04 10:36:25.430: E/AndroidRuntime(641):  at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-04 10:36:25.430: E/AndroidRuntime(641):  at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
01-04 10:36:25.430: E/AndroidRuntime(641):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
01-04 10:36:25.430: E/AndroidRuntime(641):  ... 11 more
01-04 10:36:31.140: W/dalvikvm(679): Unable to resolve superclass of Lcom/example/MapsActivity; (10)
01-04 10:36:31.160: W/dalvikvm(679): Link of class 'Lcom/example/MapsActivity;' failed
01-04 10:36:31.160: D/AndroidRuntime(679): Shutting down VM
01-04 10:36:31.180: W/dalvikvm(679): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
01-04 10:36:31.240: E/AndroidRuntime(679): FATAL EXCEPTION: main
01-04 10:36:31.240: E/AndroidRuntime(679): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example/com.example.MapsActivity}: java.lang.ClassNotFoundException: com.example.MapsActivity
01-04 10:36:31.240: E/AndroidRuntime(679):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
01-04 10:36:31.240: E/AndroidRuntime(679):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
01-04 10:36:31.240: E/AndroidRuntime(679):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
01-04 10:36:31.240: E/AndroidRuntime(679):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
01-04 10:36:31.240: E/AndroidRuntime(679):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-04 10:36:31.240: E/AndroidRuntime(679):  at android.os.Looper.loop(Looper.java:137)
01-04 10:36:31.240: E/AndroidRuntime(679):  at android.app.ActivityThread.main(ActivityThread.java:4424)
01-04 10:36:31.240: E/AndroidRuntime(679):  at java.lang.reflect.Method.invokeNative(Native Method)
01-04 10:36:31.240: E/AndroidRuntime(679):  at java.lang.reflect.Method.invoke(Method.java:511)
01-04 10:36:31.240: E/AndroidRuntime(679):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-04 10:36:31.240: E/AndroidRuntime(679):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-04 10:36:31.240: E/AndroidRuntime(679):  at dalvik.system.NativeStart.main(Native Method)
01-04 10:36:31.240: E/AndroidRuntime(679): Caused by: java.lang.ClassNotFoundException: com.example.MapsActivity
01-04 10:36:31.240: E/AndroidRuntime(679):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
01-04 10:36:31.240: E/AndroidRuntime(679):  at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-04 10:36:31.240: E/AndroidRuntime(679):  at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-04 10:36:31.240: E/AndroidRuntime(679):  at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
01-04 10:36:31.240: E/AndroidRuntime(679):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
01-04 10:36:31.240: E/AndroidRuntime(679):  ... 11 more
01-04 10:37:23.619: W/dalvikvm(720): Unable to resolve superclass of Lcom/example/MapsActivity; (10)
01-04 10:37:23.659: W/dalvikvm(720): Link of class 'Lcom/example/MapsActivity;' failed
01-04 10:37:23.659: D/AndroidRuntime(720): Shutting down VM
01-04 10:37:23.669: W/dalvikvm(720): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
01-04 10:37:23.699: E/AndroidRuntime(720): FATAL EXCEPTION: main
01-04 10:37:23.699: E/AndroidRuntime(720): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example/com.example.MapsActivity}: java.lang.ClassNotFoundException: com.example.MapsActivity
01-04 10:37:23.699: E/AndroidRuntime(720):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
01-04 10:37:23.699: E/AndroidRuntime(720):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
01-04 10:37:23.699: E/AndroidRuntime(720):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
01-04 10:37:23.699: E/AndroidRuntime(720):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
01-04 10:37:23.699: E/AndroidRuntime(720):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-04 10:37:23.699: E/AndroidRuntime(720):  at android.os.Looper.loop(Looper.java:137)
01-04 10:37:23.699: E/AndroidRuntime(720):  at android.app.ActivityThread.main(ActivityThread.java:4424)
01-04 10:37:23.699: E/AndroidRuntime(720):  at java.lang.reflect.Method.invokeNative(Native Method)
01-04 10:37:23.699: E/AndroidRuntime(720):  at java.lang.reflect.Method.invoke(Method.java:511)
01-04 10:37:23.699: E/AndroidRuntime(720):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-04 10:37:23.699: E/AndroidRuntime(720):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-04 10:37:23.699: E/AndroidRuntime(720):  at dalvik.system.NativeStart.main(Native Method)
01-04 10:37:23.699: E/AndroidRuntime(720): Caused by: java.lang.ClassNotFoundException: com.example.MapsActivity
01-04 10:37:23.699: E/AndroidRuntime(720):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
01-04 10:37:23.699: E/AndroidRuntime(720):  at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-04 10:37:23.699: E/AndroidRuntime(720):  at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-04 10:37:23.699: E/AndroidRuntime(720):  at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
01-04 10:37:23.699: E/AndroidRuntime(720):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
01-04 10:37:23.699: E/AndroidRuntime(720):  ... 11 more

Output screen:

             google map view screen shot 

Upvotes: 0

Views: 2496

Answers (5)

Harsh Dev Chandel
Harsh Dev Chandel

Reputation: 763

the error class not found exception is when actitvity is not declared in manifest if you have declared it and then also error comes please please check you may have included a jar file twice in your project

Upvotes: 0

Yugandhar Babu
Yugandhar Babu

Reputation: 10349

I think problem with your API key only. Any how check the link below you will get an idea.

Displaying Google maps in Android Emulator

I found one thing in your manifest, you written

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

after </application> i think it may wrong

In manifest file write as below and try once

<application
<uses-library android:name="com.google.android.maps" />

New Answer

Please check this link, it may help you. Enable internet for Android Emulator

Upvotes: 1

Parag Chauhan
Parag Chauhan

Reputation: 35946

Your mentioned code is right But i have two doubt is that

1. Google MAP API

Ans .To get Google MAP API Here

2. Check Emulator's Internet. 

Ans . Open CMD D:\SOFTWARE\Android-SDK\android-sdk-2.2>emulator -avd avdname -dns-server 8.8.8.8

Upvotes: 0

Sourab Sharma
Sourab Sharma

Reputation: 2960

Move :

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

within the application tag. You have written outside the application tag in manifest file.

For your second problem: I am sure you have copied the map key from some where else. This is causing only blank screen on emulator. Try to generate your own Map Key following:

http://code.google.com/android/add-ons/google-apis/mapkey.html

Upvotes: 0

android
android

Reputation: 386

add google maps library in your manifest and it should work

Upvotes: 0

Related Questions