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

  • Home
  • SEARCH
  • 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 7072573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:49:30+00:00 2026-05-28T05:49:30+00:00

i had followed exactly same procedure on google’s tutorial: http://developer.android.com/guide/tutorials/views/hello-mapview.html …while i got force

  • 0

i had followed exactly same procedure on google’s tutorial:
http://developer.android.com/guide/tutorials/views/hello-mapview.html

…while i got “force close”

here’s my code:

public class TrainstationActivity extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    findViews();
    mapview.setBuiltInZoomControls(true);
}

  private MapView mapview;
  LinearLayout linearLayout;

}
private void findViews() {
    mapview=(MapView)findViewById(R.id.map);
}
@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}
}

the outcome with “null pointer exception” in logcat

here the log cat:

01-10 20:09:31.564: D/dalvikvm(789): GC_CONCURRENT freed 1161K, 54% free 3151K/6727K, external 1625K/2137K, paused 4ms+4ms
01-10 20:09:31.824: D/dalvikvm(789): GC_CONCURRENT freed 531K, 51% free 3311K/6727K, external 1625K/2137K, paused 4ms+7ms
01-10 20:09:32.034: D/AndroidRuntime(789): Shutting down VM
01-10 20:09:32.034: W/dalvikvm(789): threadid=1: thread exiting with uncaught exception (group=0x40015560)
01-10 20:09:32.044: E/AndroidRuntime(789): FATAL EXCEPTION: main
01-10 20:09:32.044: E/AndroidRuntime(789): java.lang.RuntimeException: Unable to start activity ComponentInfo{trian.station/trian.station.TrainstationActivity}: java.lang.NullPointerException
01-10 20:09:32.044: E/AndroidRuntime(789):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
01-10 20:09:32.044: E/AndroidRuntime(789):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-10 20:09:32.044: E/AndroidRuntime(789):  at  android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-10 20:09:32.044: E/AndroidRuntime(789):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-10 20:09:32.044: E/AndroidRuntime(789):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-10 20:09:32.044: E/AndroidRuntime(789):  at android.os.Looper.loop(Looper.java:130)
01-10 20:09:32.044: E/AndroidRuntime(789):  at android.app.ActivityThread.main(ActivityThread.java:3683)
01-10 20:09:32.044: E/AndroidRuntime(789):  at java.lang.reflect.Method.invokeNative(Native Method)
01-10 20:09:32.044: E/AndroidRuntime(789):  at java.lang.reflect.Method.invoke(Method.java:507)
01-10 20:09:32.044: E/AndroidRuntime(789):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-10 20:09:32.044: E/AndroidRuntime(789):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-10 20:09:32.044: E/AndroidRuntime(789):  at dalvik.system.NativeStart.main(Native Method)
01-10 20:09:32.044: E/AndroidRuntime(789): Caused by: java.lang.NullPointerException
01-10 20:09:32.044: E/AndroidRuntime(789):  at trian.station.TrainstationActivity.onCreate(TrainstationActivity.java:18)
01-10 20:09:32.044: E/AndroidRuntime(789):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-10 20:09:32.044: E/AndroidRuntime(789):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
01-10 20:09:32.044: E/AndroidRuntime(789):  ... 11 more
01-10 20:09:33.934: D/dalvikvm(789): GC_CONCURRENT freed 830K, 54% free 3098K/6727K, external 1641K/2137K, paused 3ms+5ms

main.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/map"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:apiKey="********"
    android:clickable="true"
    />
<!--<LinearLayout android:id="@+id/zoom"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    />
-->

manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.demo.android.trainstation"
  android:versionCode="1"
  android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
    <uses-library android:name="com.google.android.maps" />
    <activity android:name=".TrainStation"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>
<uses-sdk android:minSdkVersion="5" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>

could sb teach me what had i mistaken?

P.S.
without mapview.setBuiltInZoomControls(true);
this line , could run map correctly

  • 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-28T05:49:31+00:00Added an answer on May 28, 2026 at 5:49 am

    You need to move “mapview=(MapView)findViewById(R.id.map);” to be inside of your onCreate(). You dont need to have the call to findViews().

    I am doing a project with a map as well and this is how mine looks.

    Your manifest and .xml files look correct to me so hopefully this helps you.

    public class GoogleMap extends MapActivity{
    @Override
    public void onCreate(Bundle savedInstanceState){    
        super.onCreate(savedInstanceState);    
        setContentView(R.layout.map);
    
        MapView mapView = (MapView) findViewById(R.id.mapview);    
        mapView.setBuiltInZoomControls(true);
    
         }//End onCreate();
    
    @Override
    protected boolean isRouteDisplayed() 
    {    
        return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've followed the instructions from http://www.lucidimagination.com/blog/2009/03/09/nutch-solr/ Had solr up and running before that, could
I recently implemented Authlogic to my project for authentication. I followed http://railscasts.com/episodes/160-authlogic and had
Followed this tutorial on getting autocomplete for CI to work with Eclipse http://taggedzi.com/articles/display/autocomplete-eclipse-codeigniter-2 -
I have followed this tutorial: http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12 fully, and after seing that I had issues
I've followed the steps outlined in http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx to enable source debugging of the .NET
I followed this tutorial exactly and received the following error after trying to upload
I had a production app on Heroku - productionapp.heroku.com So, I followed the steps
I followed the official docs on https setup located here: https://help.ubuntu.com/6.06/ubuntu/serverguide/C/httpd.html#https-configuration I had to
Hi I have followed a tutorial to create and event list in wordpress using
I thought I had correctly followed the recommendations in this question for checking undefined

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.