Skip to content

[Crash] Fatal Exception: java.lang.NullPointerException Attempt to invoke virtual method 'boolean androidx.core.view.m1.o(int)' on a null object reference #2234

@winnievips

Description

@winnievips

Bug Report

Plugin(s)

@capacitor/keyboard: 6.1.0

Capacitor Version

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 6.1.2
  @capacitor/core: 6.1.2
  @capacitor/android: 6.1.2
  @capacitor/ios: 6.1.2

Installed Dependencies:

  @capacitor/cli: 6.1.0
  @capacitor/core: 6.1.0
  @capacitor/ios: 6.1.0
  @capacitor/android: 6.1.0

[success] iOS looking great! 👌
[success] Android looking great! 👌

Platform(s)

Android Devices
47% Honor
21% Vivo
11% Oppo
5% Oppo
16% Other

Android SDK
84% Android 14
11% Android 13
5% Android 10

Current Behavior

Getting this crash error in firebase.

Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'boolean androidx.core.view.m1.o(int)' on a null object reference

The log as below

com.capacitorjs.plugins.keyboard.Keyboard$1.onEnd (Keyboard.java:88)
androidx.core.view.WindowInsetsAnimationCompat$Impl30$ProxyCallback.onEnd (WindowInsetsAnimationCompat.java:1079)
android.view.View.dispatchWindowInsetsAnimationEnd (View.java:12517)
android.view.ViewGroup.dispatchWindowInsetsAnimationEnd (ViewGroup.java:7837)
android.view.ViewRootInsetsControllerHost.dispatchWindowInsetsAnimationEnd (ViewRootInsetsControllerHost.java:125)
android.view.InsetsController.dispatchAnimationEnd (InsetsController.java:2124)
android.view.InsetsController.cancelAnimation (InsetsController.java:1873)
android.view.InsetsController.cancelExistingControllers (InsetsController.java:1767)
android.view.InsetsController.cancelExistingAnimations (InsetsController.java:2062)
android.view.ViewRootImpl.dispatchDetachedFromWindow (ViewRootImpl.java:7534)
android.view.ViewRootImpl.doDie (ViewRootImpl.java:11368)
android.view.ViewRootImpl.die (ViewRootImpl.java:11327)
android.view.WindowManagerGlobal.removeViewLocked (WindowManagerGlobal.java:620)
android.view.WindowManagerGlobal.removeView (WindowManagerGlobal.java:547)
android.view.WindowManagerImpl.removeViewImmediate (WindowManagerImpl.java:251)
android.app.ActivityThread.handleDestroyActivity (ActivityThread.java:6688)
android.app.servertransaction.DestroyActivityItem.execute (DestroyActivityItem.java:47)
android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:45)
android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:194)
android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:106)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:3067)
android.os.Handler.dispatchMessage (Handler.java:117)
android.os.Looper.loopOnce (Looper.java:210)
android.os.Looper.loop (Looper.java:302)
android.app.ActivityThread.main (ActivityThread.java:9652)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:601)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1062)

Code Reproduction

import { Component, Injector, OnDestroy, OnInit } from '@angular/core';
import { Keyboard } from '@capacitor/keyboard';
import { Platform } from '@ionic/angular';

@Component({
  selector: 'checkout',
  templateUrl: './checkout.page.html',
  styleUrls: ['./checkout.page.scss'],
  animations: [],
})

export class CheckoutPage implements OnInit, OnDestroy {
  isApp: boolean;
  isKeyboardHidden: boolean = true;
  
  _platform: Platform;

  constructor(private _injector: Injector) {
    this._platform = this._injector.get<Platform>(Platform);
  }

  ngOnInit() {
    this.isApp = this._platform.is('capacitor');

    //to re-render the UI after keyboard close
    if (this.isApp) {
      Keyboard.addListener('keyboardWillShow', () => {
        this.isKeyboardHidden = false;
      });

      Keyboard.addListener('keyboardWillHide', () => {
        this.isKeyboardHidden = true;
      });
    }
  }

  ngOnDestroy() {
    if (this.isApp) {
      Keyboard.removeAllListeners();
    }
  }
}

Other Technical Details

Not all the android will have issue. but some of the devices.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions