Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6001169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:47:50+00:00 2026-05-23T00:47:50+00:00

For some reason this VERY simple program crashes when it reaches the getController() method.

  • 0

For some reason this VERY simple program crashes when it reaches the getController() method. Its almost like the debugger is trying to tell me something, but its all garble.Believe it or not there isn’t a clear explanation or exception given, ha. But it definitely blows up on this line. If I take it out of the code the app will run a basic map. I have tried everything imaginable and I can’t figure out the problem. Does anyone have any thoughts? Thanks in advance.

public class Main extends MapActivity {

MapView myMapView;
MapController mc;
GeoPoint point;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    double lon = -79.9;
    double lat = 40.4;

    myMapView = (MapView) findViewById(R.layout.main);

    point = new GeoPoint((int) (lat * 1E6), (int) (lon * 1E6));

    mc = myMapView.getController();
    mc.animateTo(point);
    mc.setZoom(13);

}
@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}

And the main.xml code:

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <com.google.android.maps.MapView
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:enabled="true" 
        android:clickable="true"
        android:apiKey="0SN6PntBTxgMIeekPQm2Of1gnlDiHmrTm8GG2xQ"
        ></com.google.android.maps.MapView>     
         </LinearLayout>

And Finally, the manifest.xml code:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.simplyDesign.BarCraw" android:versionCode="1"
    android:versionName="1.0">
    <uses-sdk android:minSdkVersion="4" />
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>

    <application android:icon="@drawable/icon" android:label="@string/app_name">

        <activity android:name=".Main" android:label="@string/app_name">
            <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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:47:51+00:00Added an answer on May 23, 2026 at 12:47 am

    You should give your MapView an android:id and feed it to findViewById(). In your code you search for a view with the Id of your whole layout. This can only return null… and give you a NullPointerException when invoking getController() on null.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a (very) simple Win32 GUI program, but for some reason
This is almost certainly a very silly question, but for some reason I'm having
This should be a very simple thing to have run, but for some reason
I'm guessing this is very simple, but for some reason I am unable to
This should be a very simple task, but for some reason I'm running into
This should be a very basic design question, but for some reason it doesn't
For some reason this program is saying that 'switch' is not defined. What is
For some reason, this very basic page shows up fine in Chrome, but not
http://jqueryui.com/demos/button/#default They are very simple to use, but for some reason my buttons are
This should be very simple, but its not working! I have this link on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.