[Android] Unable to initialize androidx.lifecycle.ReportFragment on app launch

Capacitor Version

@capacitor/cli “^6.2.0”,
@capacitor/core: “^6.2.0”,
@capacitor/android: “^6.2.0”,
@capacitor/ios: “^6.2.0”,

Other API Details

NPM 10.9.2
Node.js 22.13.1

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

I’m trying to build a web :backhand_index_pointing_right: Android app with Capacitor and implement in-app purchases.

When I run the APK on an Android Studio Emulator, the app crashes immediately, and I see a Lifecycle issue in the Logcat output.

How can I fix this?

Already Tried

I’ve already tried the following, but the issue still persists:

I added the following lines to android/app/build.gradle:

:pushpin: android/app/build.gradle

dependencies {
    // Lifecycle dependencies
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0'
    implementation 'androidx.lifecycle:lifecycle-common-java8:2.7.0'
}

I also explicitly handled the Lifecycle in MainActivity.java like this:

:pushpin: MainActivity.java

import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;

public class MainActivity extends BridgeActivity implements LifecycleObserver {

    @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
    public void onCreateEvent() {
        Log.d("MainActivity", "App created");
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
    public void onResumeEvent() {
        Log.d("MainActivity", "App resumed");
    }
}

But the app is still crashing on the emulator. :sad_but_relieved_face:

Expected Behavior

I want the app to run properly on the emulator without crashing.

Project Reproduction

I dont have a public repo now

Additional Information

I generated the APK using the following commands in VSCode:

gradlew build  
gradlew assembleDebug  

Also, I’m using InAppPurchase2 for the in-app-purchase feature and installed the following library:
@awesome-cordova-plugins/in-app-purchase-2