1. Download our Official Android App: Forums for Android!

Apps Google MapView tutorial Problem

Discussion in 'Android Development' started by babyboss, Dec 12, 2010.

  1. babyboss

    babyboss Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    6
    Joined:
    Dec 11, 2010

    Dec 11, 2010
    6
    0
    5
    I got the following error from LogCat after run the first part of google mapview tutorial from android developer.

    Code (Text):
    1. 12-13 00:20:12.828: ERROR/AndroidRuntime(521): java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
    2. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at dalvik.system.DexFile.defineClass(Native Method)
    3. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:209)
    4. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:203)
    5. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
    6. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
    7. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
    8. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
    9. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    10. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    11. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    12. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at android.os.Handler.dispatchMessage(Handler.java:99)
    13. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at android.os.Looper.loop(Looper.java:123)
    14. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at android.app.ActivityThread.main(ActivityThread.java:4627)
    15. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at java.lang.reflect.Method.invokeNative(Native Method)
    16. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at java.lang.reflect.Method.invoke(Method.java:521)
    17. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    18. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    19. 12-13 00:20:12.828: ERROR/AndroidRuntime(521):     at dalvik.system.NativeStart.main(Native Method)
    20.  
    -----------------------------------------------------------------------
    Mainfest.xml
    Code (Text):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest xmlns:android="[URL]http://schemas.android.com/apk/res/android[/URL]"
    3.       package="com.example.hellogooglemap"
    4.       android:versionCode="1"
    5.       android:versionName="1.0">
    6.     <application android:icon="@drawable/icon" android:label="@string/app_name">    
    7.      <uses-library android:name="com.google.android.maps" />
    8.         <activity android:name=".HelloGoogleMap"
    9.                   android:label="@string/app_name"
    10.                   android:theme="@android:style/Theme.NoTitleBar">
    11.             <intent-filter>
    12.                 <action android:name="android.intent.action.MAIN" />
    13.                 <category android:name="android.intent.category.LAUNCHER" />
    14.             </intent-filter>
    15.         </activity>
    16.     </application>
    17.  <uses-permission android:name="android.permission.INTERNET" />
    18. </manifest>
    /layout/main.xml
    Code (Text):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <com.google.android.maps.MapView
    3.     xmlns:android="[URL]http://schemas.android.com/apk/res/android[/URL]"
    4.     android:id="@+id/mapview"
    5.     android:layout_width="fill_parent"
    6.     android:layout_height="fill_parent"
    7.     android:clickable="true"
    8.     android:apiKey="Your API Key"
    9. />
    10.  
    HelloGoogleMap.java
    Code (Text):
    1.  
    2. package com.example.hellogooglemap;
    3. import android.os.Bundle;
    4. import com.google.android.maps.MapActivity;
    5. import com.google.android.maps.MapView;
    6. public class HelloGoogleMap extends MapActivity {
    7.     /** Called when the activity is first created. */
    8.     @Override
    9.     public void onCreate(Bundle savedInstanceState) {
    10.         super.onCreate(savedInstanceState);
    11.         setContentView(R.layout.main);
    12.  
    13.         MapView mapView = (MapView) findViewById(R.id.mapview);
    14.         mapView.setBuiltInZoomControls(true);
    15.     }
    16.     @Override
    17.     protected boolean isRouteDisplayed() {
    18.         return false;
    19.     }
    20. }
     

    Advertisement

  2. miXer

    miXer Android Enthusiast
    Rank:
    None
    Points:
    53
    Posts:
    313
    Joined:
    Aug 12, 2010

    Aug 12, 2010
    313
    51
    53
    Norway
    I have done one of those Maps tutorials too, and the differences that i can see is:
    - You are missing two permissions in your manifest: ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION
    - In my main.xml i have the com.google.android.maps.MapView inside a LinearLayout
     
  3. babyboss

    babyboss Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    6
    Joined:
    Dec 11, 2010

    Dec 11, 2010
    6
    0
    5
    I have done modification accordingly, but still get the exactly same error as above. Could you send me a working version code? or make an attachment? Thank you.
     
  4. miXer

    miXer Android Enthusiast
    Rank:
    None
    Points:
    53
    Posts:
    313
    Joined:
    Aug 12, 2010

    Aug 12, 2010
    313
    51
    53
    Norway
    Here is my eclipse project.
     

    Attached Files:

  5. babyboss

    babyboss Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    6
    Joined:
    Dec 11, 2010

    Dec 11, 2010
    6
    0
    5
    First of all, thank you very much for the attachment. It works, and it doesn't show me stopped unexpectedly error. However, I get blank google map page, which doesn't show anything like the following:
    [​IMG]


    By the way, I am in Asia region. Will that also be a factor?
     
  6. miXer

    miXer Android Enthusiast
    Rank:
    None
    Points:
    53
    Posts:
    313
    Joined:
    Aug 12, 2010

    Aug 12, 2010
    313
    51
    53
    Norway
    Have you added your own Google Maps API key i main.xml? Google it too find out how.
     
  7. babyboss

    babyboss Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    6
    Joined:
    Dec 11, 2010

    Dec 11, 2010
    6
    0
    5
    I did get the google MAPVIEW key, and inserted it into main.xml where you put "Your Google View Key"
     
  8. miXer

    miXer Android Enthusiast
    Rank:
    None
    Points:
    53
    Posts:
    313
    Joined:
    Aug 12, 2010

    Aug 12, 2010
    313
    51
    53
    Norway
    Then i dont know. For me it runs fine in Norway
     
    babyboss likes this.
  9. JamTheMan

    JamTheMan Well-Known Member
    Rank:
    None
    Points:
    38
    Posts:
    136
    Joined:
    Dec 16, 2010

    I had the same problems the first times I tried making an app using google maps, and realized the stupidest mistake. I didn't setup the emulator in AVD to be including Google API's, but a standard Android x.x. Rookie mistake, but easy to overlook.
     
    CirrusFlyer likes this.

Share This Page

Loading...