Map API - activity crashes on launch

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

Map API - activity crashes on launch

Postby unexpected62 » Tue Apr 06, 2010 9:20 am

Hi,

I am using the Android Map API for the first time to embed a map in my application. I have done a lot of searching and most tutorials line up, and I have followed everything as far as I can tell very accurately, but still when my activity with the map launches, it crashes instantly.

My class with the map is not my main class, it launches when a button is pressed. Initially the app is fine, and when I hit the button that starts my activity with the map, it crashes. Lets call that activity, "MoreInfo".

So, my "More Info" extends com.google.android.maps.MapActivity, and imports that same thing as well. I also import com.google.android.maps.MapView, and android.os.Bundle. What is strange to me is that com.google.android.maps.MapActivity and MapView are yellow underlined, saying they are not used. This is technically true because I have nothing interacting with them programatically as of yet.

The MoreInfo.xml file for the GUI, has this LinearLayout embedded into a RelativeLayout

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
  2.  
  3.                android:id = "@+id/show_on_map"
  4.  
  5.                android:orientation="vertical"
  6.  
  7.                android:layout_width="310dip"
  8.  
  9.                android:layout_height="240dip"
  10.  
  11.                android:layout_below = "@+id/location_box"
  12.  
  13.            >
  14.  
  15.                 <com.google.android.maps.MapView
  16.  
  17.                    android:id="@+id/mapview1"
  18.  
  19.                    android:layout_width="fill_parent"
  20.  
  21.                    android:layout_height="fill_parent"
  22.  
  23.                    android:enabled="true"
  24.  
  25.                    android:clickable="true"
  26.  
  27.                     android:apiKey="0QgcCar5Krn4WHy3D3XIIOtCXu8UkYTFR3XYNug"
  28.  
  29.                />
  30.  
  31.             </LinearLayout>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4
My Android Manifest has these uses-permissions above the <application> tag:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <uses-permission  android:name="android.permission.ACCESS_COARSE_LOCATION"/>
  3.  
  4.     <uses-permission  android:name="android.permission.ACCESS_FINE_LOCATION" />
  5.  
  6.     <uses-permission android:name="android.permission.INTERNET"  />
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
And again in the manifest I have

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <uses-library android:name="com.google.android.maps"  />
Parsed in 0.000 seconds, using GeSHi 1.0.8.4
inside of the <application> tag.

I got my API key correctly, I think my XML is ok, I imported everything correctly, I have the API checked in the project properties, and my Manifest looks good...

Why does my app's MoreInfo Force Close on launch?
unexpected62
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Apr 06, 2010 9:16 am

Top

Postby damninggodson » Fri Apr 09, 2010 11:49 am

ur class should extends MapActivity instead of Activity. is this the problem?

show me ur source code plz~
damninggodson
Developer
Developer
 
Posts: 36
Joined: Thu Mar 25, 2010 3:36 am

Postby unexpected62 » Fri Apr 09, 2010 6:54 pm

Aren't I supposed to extend MapActivity? Without that I get errors.
unexpected62
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Apr 06, 2010 9:16 am

Postby damninggodson » Sun Apr 11, 2010 4:44 am

then show me ur snippet or source code plz
damninggodson
Developer
Developer
 
Posts: 36
Joined: Thu Mar 25, 2010 3:36 am

Postby unexpected62 » Sun Apr 18, 2010 1:02 am

Ok, I have the activity launching. I made it its own activity instead of being embedded.

Now I get force closes, if I "do too much" on the map. Like, if I scroll around a lot, toggle satellite view too much, etc. It's very strange. The error is coming not from my code, but the various overlay and mapactivity classes through google... is there anything I can do about this?
unexpected62
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Apr 06, 2010 9:16 am

Postby JKumar » Thu May 13, 2010 10:38 am

HI,

You are required to check your app as All the Map API and others have gone through a lot test testing and compilation and then it got released and so its silly blaming the API.

I would suggest you to recreate the AVD, apiKey and use the same project you created, you will definitely get the success.
Hope the suggestion helps you
Keep posting .It makes us better to understand Android
User avatar
JKumar
Experienced Developer
Experienced Developer
 
Posts: 52
Joined: Thu May 13, 2010 8:17 am
Location: INDIA

Top

Re: Map API - activity crashes on launch

Postby st_141 » Tue Oct 19, 2010 7:10 am

My app has similar problems too. Please help me asap as I got a project submission tomorrow.

My map activity is as follows
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.healthcare.iFind;
  2.  
  3. import com.google.android.maps.MapActivity;
  4. import com.google.android.maps.MapView;
  5. import com.google.android.maps.MapView.LayoutParams;  
  6.  
  7. import android.os.Bundle;
  8. import android.view.View;
  9. import android.widget.LinearLayout;
  10.  
  11. public class MapsActivity extends MapActivity
  12. {    
  13.     MapView mapView;
  14.  
  15.     /** Called when the activity is first created. */
  16.     @Override
  17.     public void onCreate(Bundle savedInstanceState)
  18.     {
  19.         super.onCreate(savedInstanceState);
  20.         setContentView(R.layout.maps);
  21.  
  22.  
  23.         mapView = (MapView) findViewById(R.id.mapView);
  24.         LinearLayout zoomLayout = (LinearLayout)findViewById(R.id.zoom);  
  25.         View zoomView = mapView.getZoomControls();
  26.  
  27.         zoomLayout.addView(zoomView,
  28.             new LinearLayout.LayoutParams(
  29.                 LayoutParams.WRAP_CONTENT,
  30.                 LayoutParams.WRAP_CONTENT));
  31.         mapView.displayZoomControls(true);
  32.  
  33.     }
  34.  
  35.     @Override
  36.     protected boolean isRouteDisplayed() {
  37.         // TODO Auto-generated method stub
  38.         return false;
  39.     }
  40. }
  41.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


My AndroidManifest.xml file:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3.      package="com.healthcare.iFind"
  4.      android:versionCode="1"
  5.      android:versionName="1.0.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=".HomeScreen"
  9.                  android:label="@string/app_name">
  10.             <intent-filter>
  11.                 <action android:name="android.intent.action.MAIN" />
  12.                 <category android:name="android.intent.category.LAUNCHER" />
  13.             </intent-filter>
  14.         </activity>
  15.                 <activity android:name="MessageList"></activity>
  16.                 <activity android:name="RateDoctor"></activity>
  17.                 <activity android:name="RateQuiz"></activity>
  18.                 <activity android:name="DetailedDoctor"></activity>
  19.                 <activity android:name="DoctorProfile"></activity>
  20.                 <activity android:name=".MapsActivity"/>
  21.     </application>
  22.    
  23. My maplayout .xml file.
  24.     <uses-permission android:name="android.permission.INTERNET" />
  25.     <uses-permission android:name="android.permission.CALL_PHONE" />
  26.  
  27. </manifest>
Parsed in 0.005 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  <?xml version="1.0" encoding="utf-8"?>
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.    android:layout_width="fill_parent"
  4.    android:layout_height="fill_parent">
  5.  
  6.     <com.google.android.maps.MapView
  7.        android:id="@+id/mapView"
  8.        android:layout_width="fill_parent"
  9.        android:layout_height="fill_parent"
  10.        android:enabled="true"
  11.        android:clickable="true"
  12.        android:apiKey="mykey"
  13.        />
  14.      <LinearLayout android:id="@+id/zoom"
  15.        android:layout_width="wrap_content"
  16.        android:layout_height="wrap_content"
  17.        android:layout_alignParentBottom="true"
  18.        android:layout_centerHorizontal="true"
  19.        />
  20.  
  21. </RelativeLayout>
  22.  
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


My app crashes as soon as I launch this activity.

Please help me figure out the problem. I use Google API with Android 2.2 in Eclipse.

Also do let me know if we can geocode in google maps only using a given zipcode and address and no lat and long values.

Thanks in advance :)
st_141
Freshman
Freshman
 
Posts: 4
Joined: Wed Oct 06, 2010 1:27 am

Top

Return to Map Problems

Who is online

Users browsing this forum: Majestic-12 [Bot] and 2 guests