ViewRootImpl.handleWindowFocusChanged View.findFocus() on a null object reference - android

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findFocus()' on a null object reference
at android.view.ViewRootImpl.handleWindowFocusChanged(ViewRootImpl.java:3472)
at android.view.ViewRootImpl.access$1100(ViewRootImpl.java:205)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:5267)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:268)
at android.app.ActivityThread.main(ActivityThread.java:8023)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:635)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
mView.findFocus()
mView is DecorView

Related

my app crashes when i try to set default drawable as MenuItem Icon inside Glide's onLoadFailed method

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.util.SparseArray.valueAt(int)' on a null object reference
at android.graphics.drawable.DrawableContainer$DrawableContainerState.createAllFutures(DrawableContainer.java:879)
at android.graphics.drawable.DrawableContainer$DrawableContainerState.getOpacity(DrawableContainer.java:1163)
at android.graphics.drawable.DrawableContainer.getOpacity(DrawableContainer.java:434)
at android.widget.ImageView.isOpaque(ImageView.java:1645)
at android.view.View.invalidateInternal(View.java:18603)
at android.view.View.invalidate(View.java:18582)
at android.view.View.invalidate(View.java:18564)
at android.widget.ImageView.setImageDrawable(ImageView.java:599)
at androidx.appcompat.widget.AppCompatImageView.setImageDrawable(AppCompatImageView.java:104)
at com.google.android.material.bottomnavigation.BottomNavigationItemView.setIcon(BottomNavigationItemView.java:408)
at com.google.android.material.bottomnavigation.BottomNavigationItemView.initialize(BottomNavigationItemView.java:146)
at com.google.android.material.bottomnavigation.BottomNavigationMenuView.updateMenuView(BottomNavigationMenuView.java:626)
at com.google.android.material.bottomnavigation.BottomNavigationPresenter.updateMenuView(BottomNavigationPresenter.java:69)
at androidx.appcompat.view.menu.MenuBuilder.dispatchPresenterUpdate(MenuBuilder.java:292)
at androidx.appcompat.view.menu.MenuBuilder.onItemsChanged(MenuBuilder.java:1063)
at androidx.appcompat.view.menu.MenuItemImpl.setIcon(MenuItemImpl.java:519)
at com.risor.ui.home.MainActivity$setUpProfileAvatar$1$onLoadFailed$1.run(MainActivity.kt:303)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7948)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:603)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

IWindowSession.java NullPointerException: Attempt to read from field 'int android.content.pm.ApplicationInfo.flags' on a null object reference

Fatal Exception: java.lang.NullPointerException: Attempt to read from field 'int android.content.pm.ApplicationInfo.flags' on a null object reference
at android.os.Parcel.createException(Parcel.java:1972)
at android.os.Parcel.readException(Parcel.java:1934)
at android.os.Parcel.readException(Parcel.java:1884)
at android.view.IWindowSession$Stub$Proxy.addToDisplay(IWindowSession.java:836)
at android.view.ViewRootImpl.setView(ViewRootImpl.java:926)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:390)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
at android.widget.Toast$TN.handleShow(Toast.java:525)
at android.widget.Toast$TN$1.handleMessage(Toast.java:429)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:226)
at android.app.ActivityThread.main(ActivityThread.java:7191)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:499)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942)
showing some fatal exception in IWindowSession.java line 836
android.view.IWindowSession$Stub$Proxy.addToDisplay please help to resolve it.

android:firebase-perf:NullPointException

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.internal.zzewh.zzb(com.google.android.gms.internal.zzewx)' on a null object reference
at com.google.android.gms.internal.zzevz.zza(Unknown Source:154)
at com.google.android.gms.internal.zzevz.zzb(Unknown Source:78)
at com.google.android.gms.internal.zzevz.zza(Unknown Source)
at com.google.android.gms.internal.zzewc.run(Unknown Source:6)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)

Unable to start Acitivity on miui9

I'm new to Android and currently I have a thorny problem.
My application is crashed on MIUI9(Android 7.1.1), but it's working good on other device(Android N). I don't know how did it happend.
Below is the log:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.*****.***.***/com.*****.***.***.SplashActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Thread android.os.Looper.getThread()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2740)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2801)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1548)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6365)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:791)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Thread android.os.Looper.getThread()' on a null object reference
at miui.util.AttributeResolver.bR(SourceFile:35)
at miui.util.AttributeResolver.resolveInt(SourceFile:145)
at miui.util.AttributeResolver.isUsingMiuiTheme(SourceFile:179)
at miui.os.Environment.isUsingMiui(SourceFile:108)
at android.view.ViewConfigurationInjector.get(ViewConfigurationInjector.java:18)
at android.view.ViewConfiguration.get(ViewConfiguration.java:369)
at android.view.View.<init>(View.java:4028)
at android.view.View.<init>(View.java:4154)
at android.view.ViewGroup.<init>(ViewGroup.java:579)
at android.view.ViewGroup.<init>(ViewGroup.java:575)
at android.view.ViewGroup.<init>(ViewGroup.java:571)
at android.view.ViewGroup.<init>(ViewGroup.java:567)
at android.widget.FrameLayout.<init>(FrameLayout.java:78)
at com.android.internal.policy.DecorView.<init>(DecorView.java:237)
at com.android.internal.policy.PhoneWindow.generateDecor(PhoneWindow.java:2283)
at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2621)
at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:2049)
at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:371)
at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:320)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:272)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:148)
at cn.droidlover.xdroidmvp.mvp.XActivity.onCreate(XActivity.java:42)
at com.*****.***.***.BaseActivity.onCreate(BaseActivity.java:48)
at com.*****.***.***.SplashActivity.onCreate(SplashActivity.java:49)
at android.app.Activity.performCreate(Activity.java:6861)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2693)

Null pointer exception when calling POSHandler.Instance in Xamarin Android project

I am trying to integrate following SDK into a Xamarin Android App: https://github.com/developermypos/myPOS-SDK-Android
If I try to get the POSHandler Instance I get following exception:
Java.Lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName():
Unhandled Exception:
Java.Lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
--- End of managed Java.Lang.NullPointerException stack trace ---
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
at android.widget.Toast.<init>(Toast.java:103)
at android.widget.Toast.makeText(Toast.java:256)
at eu.leupau.icardpossdk.POSHandler.setDefaultInfoListener(POSHandler.java:149)
at eu.leupau.icardpossdk.POSHandler.<init>(POSHandler.java:145)
at eu.leupau.icardpossdk.POSHandler.getInstance(POSHandler.java:127)
at md5b2d2fb169710eaa19162eaff312d3328.MainActivity.n_onCreate(Native Method)
at md5b2d2fb169710eaa19162eaff312d3328.MainActivity.onCreate(MainActivity.java:29)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
In the POSHandler.java file I found following function, which obviously causes the issue:
void setDefaultInfoListener()
{
final Toast toast = Toast.makeText(SDKApplication.getAppContext(), "", 1); // <-- **Exception**!
TextView textView = (TextView)toast.getView().findViewById(16908299);
if (textView != null) {
textView.setGravity(17);
}
My code:
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
private POSHandler _myPosHandler;
protected override void OnCreate ( Bundle bundle ) {
POSHandler.SetLanguage(Language.English);
POSHandler.SetDefaultReceiptConfig(POSHandler.ReceiptPrintOnlyMerchantCopy);
POSHandler.SetCurrency(Currency.Chf);
POSHandler.ConnectionType = ConnectionType.Bluetooth;
_myPosHandler = POSHandler.Instance; // <-- **EXCEPTION**
...
Any ideas what might be the issue?

Categories

Resources