question

newuser-ce4871aa-703f-48a3-967c-ae9574ceea60 avatar image
newuser-ce4871aa-703f-48a3-967c-ae9574ceea60 asked ·

Android app crash is crashing when clients trying to call Context.getPackageName(), throw NullPointerException

Crash on some devices because of code injected by Amazon appstore.

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
       at com.amazon.android.framework.prompt.e.a(e.java)
       at com.amazon.android.framework.prompt.e.canHandleAction(e.java)
       at com.amazon.android.framework.prompt.SimplePrompt.filterActions(SimplePrompt.java)
       at com.amazon.android.framework.prompt.SimplePrompt.setUpButtons(SimplePrompt.java)
       at com.amazon.android.framework.prompt.SimplePrompt.createExtendedDialog(SimplePrompt.java)
       at com.amazon.android.framework.prompt.SimplePrompt.doCreate(SimplePrompt.java)
       at com.amazon.android.framework.prompt.Prompt.create(Prompt.java)
       at com.amazon.android.framework.prompt.PromptManagerImpl.onCreateDialog(PromptManagerImpl.java)
       at com.amazon.android.Kiwi.onCreateDialog(Kiwi.java)
       at android.app.Activity.createDialog(Activity.java:1074)
       at android.app.Activity.showDialog(Activity.java:3442)
       at android.app.Activity.showDialog(Activity.java:3400)
       at com.amazon.android.framework.prompt.Prompt.showDialog(Prompt.java)
       at com.amazon.android.framework.prompt.Prompt.show(Prompt.java)
       at com.amazon.android.framework.prompt.PromptManagerImpl.show(PromptManagerImpl.java)
       at com.amazon.android.framework.prompt.PromptManagerImpl.onResume(PromptManagerImpl.java)
       at com.amazon.android.framework.prompt.PromptManagerImpl.a(PromptManagerImpl.java)
       at com.amazon.android.framework.prompt.k.a(k.java)
       at com.amazon.android.m.e.a(e.java)
       at com.amazon.android.m.b.a(b.java)
       at com.amazon.android.framework.context.d.a(d.java)
       at com.amazon.android.framework.context.d.onResume(d.java)
       at com.amazon.android.Kiwi.onResume(Kiwi.java)
       at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1258)
       at android.app.Activity.performResume(Activity.java:6327)
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3096)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3138)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1388)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5421)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
android
1 comment
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Any progress/updates on this one? I've just faced a similar issue.

0 Likes 0 ·

1 Answer

Levon@Amazon avatar image
Levon@Amazon answered ·

Hi there,

Could you please share the actual code snippet you used when this exception was thrown?

I would recommend to try something like this:

getPackageManager().getPackageInfo(getPackageName(), 0).packageName

10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.