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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:21:41+00:00 2026-06-17T22:21:41+00:00

I have a crash on an application that I can’t seem to work out.

  • 0

I have a crash on an application that I can’t seem to work out.

I get a bitmap from resource like so.

Bitmap bmp1 = BitmapFactory.decodeResource(getResources(), R.drawable.map_distance_tag);

Now this seems to have problems on a very small minority of devices when it comes to creating a bitmap from this bitmap. For example…

Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());

I get a NullPointerException when it creates the Bitmap on line 468 of the Bitmap class, thich I have had a look into and its when its setting the density scale of the new bitmap from its source bitmap.

// The new bitmap was created from a known bitmap source so assume that
467        // they use the same density scale
468        bitmap.setDensityScale(source.getDensityScale());

Now I can’t seem to recreate the problem but the fact I don’t get an exception when getWidth() is called on the original Bitmap tells me that the source isn’t null.

Here is the entire stack trace.

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my.app/com.my.app.recording.TrackingActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
at com.my.app.maps.MapFragment.createTabOverlay(MapFragment.java:663)
at com.my.app.maps.MapFragment.addMarkersForToolType(MapFragment.java:474)
at com.my.app.maps.MapFragment.onActivityCreated(MapFragment.java:405)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1468)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:931)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:551)
at com.my.app.recording.TrackingActivity.onStart(TrackingActivity.java:272)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1129)
at android.app.Activity.performStart(Activity.java:3781)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2636)
... 11 more

My Idea

Could it be something to do with me not including different bitmaps for different screen densities? All the Bitmaps supplied are for mdpi screens.

I notice there is also a BackStackRecord. Could this be crashing when the user presses back?

Thanks in advance

  • 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-17T22:21:42+00:00Added an answer on June 17, 2026 at 10:21 pm

    The source you point at in Bitmap.java:468 is from Android 1.5, and probably isn’t your issue.

    v1.5 Bitmap.java:468

    bitmap.setDensityScale(source.getDensityScale());
    

    v1.6-v2.2 Bitmap.java:468

    Bitmap bm = nativeCreate(null, 0, width, width, height, config.nativeInt, true);
    

    Line 468 in anything newer than 2.2 is either part of a javadoc block or an unrelated function, so I’m guessing you’re looking at the 1.6-2.2 version, not the one you’re trying to troubleshoot from.

    The only thing on that line I see that could really end up null is config. In your code, you use getConfig() to grab that from the current bitmap object. The docs for it show:

    public final Bitmap.Config getConfig ()

    Added in API level 1

    If the bitmap’s internal config is in one of the public formats, return that config, otherwise return null.

    So, it’s probably not finding a “public” format, and returning null, which passes to createBitmap(), and blows up your code.

    You can either use a static config all the time, like Bitmap.Config.ARGB_8888, or do the getConfig() on a previous line and null-check it. If null, then go to a fallback config like just mentioned.

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

Sidebar

Related Questions

I have a C++ networking application that accepts TCP connections from clients and then
I have crash logs from an iPhone Application in the App Store (retrieved via
I have a application that in iOS4.3 works perfectly well, but crash in iOS5
I have an application that can import an XML file through this terminal command
I have a bug. In WinForm .NET2.0 application my HeavyFunction can be called from
I have one crash in my iPhone application that does throw an NSException. The
I have a crash dump of an application that is supposedly leaking GDI. The
I have some code in my application that looks something like this: char *hash
I have an application and I am analyzing memory crash dumps of this software.
When I click Settings in my application's menu, app crash instantly. I don't have

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.