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

The Archive Base Latest Questions

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

I don’t know where to turn, i was following an android tutorial here and

  • 0

I don’t know where to turn, i was following an android tutorial here and upon the latest update i’m getting a runtime error and i’m really struggling to find the source of it!

What im aiming for is a small “orb” icon to appear on the screen in the lop left, that the player can drag and drop across the surface.

Now i’ve only made a few changes to the program since i last compiled it successfully. All of those were in the GameView class which you can see here: http://pastebin.com/zsYKFmuP. And i also created a brand new class called Orb which is here: http://pastebin.com/wQKqcVtV

If you have experience with android development then looking over my code shouldn’t be too troublesome however i thank anyone who takes the time to make any suggestion! All advice will be appreciated!

The logcat has this to say:

 FATAL EXCEPTION: main
 java.lang.RuntimeException: Unable to start activity ComponentInfo{biz.hireholly.tutorial/biz.hireholly.tutorial.MainActivity}: java.lang.NullPointerException
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
     at android.app.ActivityThread.access$1500(ActivityThread.java:121)
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
     at android.os.Handler.dispatchMessage(Handler.java:99)
     at android.os.Looper.loop(Looper.java:130)
     at android.app.ActivityThread.main(ActivityThread.java:3701)
     at java.lang.reflect.Method.invokeNative(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:507)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
     at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.NullPointerException
     at biz.hireholly.tutorial.models.Orb.<init>(Orb.java:13)
     at biz.hireholly.tutorial.GameView.<init>(GameView.java:34)
     at biz.hireholly.tutorial.MainActivity.onCreate(MainActivity.java:25)
     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
     ... 11 more

The relevant source from the Orb class:

public class Orb {

        private Bitmap bitmap;  //image
        private int x;  //x coord
        private int y;  //y coord
        private boolean touched; //if orb is touched/picked up
        //just to make things simpler to read
        int halfBmpX = bitmap.getWidth() /2; // <<<=== Line 13
        int halfBmpY = bitmap.getHeight() /2;
  • 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-27T00:59:48+00:00Added an answer on May 27, 2026 at 12:59 am

    Your Orb class attempts to initialize halfBmpX (and Y) from a null reference.

    That initialization should take place in the constructor after you have a valid Bitmap to initialize from.

    public Orb(Bitmap bmp, int x, int y) {
        this.bitmap = bmp;
        this.x = x;
        this.y = y;
        halfBmpX = bmp.getWidth() / 2;
        halfBmpY = bmp.getHeight() / 2;
    }
    

    Explanation: those initializations at the beginning of the class are run before the constructor runs, so bitmap doesn’t exist as anything other than a null reference.

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

Sidebar

Related Questions

Don't really know how to formulate the title, but it should be pretty obvious
Don't know what's wrong here, when I run the application it says Specified method
Don't know what to do with this error. How to add data in SQL
Don't know why I can't reply to people on here with only a small
Don't know why this conversion fails. SELECT CAST('32.999' AS INT) throws the error saying
Don't let below code scare you away . The question is really simple, only
Don't know how to google for such, but is there a way to query
I don't know when to add to a dataset a tableadapter or a query
Don't know if I worded the question right, but basically what I want to
(Don't know if this is strictly on-topic, but I don't see any better Stack

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.