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 9065609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:32:44+00:00 2026-06-16T16:32:44+00:00

I am trying to use Android TMX Loader to load a game map. I

  • 0

I am trying to use Android TMX Loader to load a game map. I keep having problems that are/seem to be because of the file not being loaded. I used the example provided, and just substituted my file, but no matter what path I use, it won’t load. I either get a file not found exception, or a null pointer exception on the line(s) that load the file. I’ve verified that the assets are being put into the APK with WinRar, and they are indeed there…

Here’s my code:

ImageView mapView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    loadWorld("World.tmx");

    setContentView(R.layout.activity_main);
}

/*
 * public void displayMap() { Display display =
 * getWindowManager().getDefaultDisplay(); Point size = new Point();
 * display.getSize(size); int width = size.x; int height = size.y;
 * 
 * }
 */

public void loadWorld(String path) {
    // Start the parser, get back TMX data object
    TileMapData t = TMXLoader.readTMX(path, this);

    mapView = (ImageView) findViewById(R.id.MapImage);

    // Create a Bitmap from the tilemap data
    Bitmap mapImage = TMXLoader.createBitmap(t, this, 0, t.layers.size());

    // Set the imageview to show the map, if we have one
    if (mapImage != null) {
        mapView.setImageBitmap(mapImage);
    }
    // Map loading problem, inform the user.
    else {
        Toast errorMessage = Toast.makeText(getApplicationContext(),
                "Map could not be loaded", Toast.LENGTH_LONG);
        errorMessage.show();
    }
}

Here is the latest LogCat stack:

12-31 07:44:25.046: E/AndroidRuntime(18074): FATAL EXCEPTION: main
12-31 07:44:25.046: E/AndroidRuntime(18074): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fionaheiss.shovelshovel/com.fionaheiss.shovelshovel.DisplayMap}: java.lang.NullPointerException
12-31 07:44:25.046: E/AndroidRuntime(18074):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2006)
12-31 07:44:25.046: E/AndroidRuntime(18074):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2031)
12-31 07:44:25.046: E/AndroidRuntime(18074):    at android.app.ActivityThread.access$600(ActivityThread.java:126)
12-31 07:44:25.046: E/AndroidRuntime(18074):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1166)
12-31 07:44:25.046: E/AndroidRuntime(18074):    at android.os.Handler.dispatchMessage(Handler.java:99)
12-31 07:44:25.046: E/AndroidRuntime(18074):    at android.os.Looper.loop(Looper.java:137)
12-31 07:44:25.046: E/AndroidRuntime(18074):    at android.app.ActivityThread.main(ActivityThread.java:4486)
12-31 07:44:25.046: E/AndroidRuntime(18074):    at java.lang.reflect.Method.invokeNative(Native Method)
12-31 07:44:25.046: E/AndroidRuntime(18074):    at java.lang.reflect.Method.invoke(Method.java:511)
12-31 07:44:25.046: E/AndroidRuntime(18074):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-31 07:44:25.046: E/AndroidRuntime(18074):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-31 07:44:25.046: E/AndroidRuntime(18074):    at dalvik.system.NativeStart.main(Native Method)
12-31 07:44:25.046: E/AndroidRuntime(18074): Caused by: java.lang.NullPointerException
12-31 07:44:25.046: E/AndroidRuntime(18074):    at com.fionaheiss.shovelshovel.DisplayMap.loadWorld(DisplayMap.java:38)
12-31 07:44:25.046: E/AndroidRuntime(18074):    at com.fionaheiss.shovelshovel.DisplayMap.onCreate(DisplayMap.java:20)
12-31 07:44:25.046: E/AndroidRuntime(18074):    at android.app.Activity.performCreate(Activity.java:4635)
12-31 07:44:25.046: E/AndroidRuntime(18074):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
12-31 07:44:25.046: E/AndroidRuntime(18074):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1970)
12-31 07:44:25.046: E/AndroidRuntime(18074):    ... 11 more

What is it that’s going wrong? I can’t figure it out for the life of me.

Thank you so much for helping me!

  • 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-06-16T16:32:46+00:00Added an answer on June 16, 2026 at 4:32 pm

    here

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        loadWorld("World.tmx");  //<< here
    
        setContentView(R.layout.activity_main);
    }
    

    you are trying to find ImageView MapImage before adding layout to current Activity so change your code as:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
    
        setContentView(R.layout.activity_main);
    
        loadWorld("file:///android_asset/World.tmx");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to use the VertexArray with Android NDK for a project that already
I have an HTML app that I am trying to use on Android under
I'm trying to use the Android tutorial to build an app that loads a
I'am trying to use android-x86 instead standard android-emulator, because it's very FAST. Launched it
I'm trying to use the Google Maps API v2 in an android project that
I'm trying to use libxml2 with android ndk. When I run the make file,
I have been trying to use Android's AudioManager.setMicrophoneMute() without much success. That is, it
I'm trying to use Android annotations framework because it seems quite powerful. I'm quite
I'm trying to use Android GalleryView to implement a view that can scroll horizontally
I am trying to use the new android NDK plugin that comes with ADT

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.