@capacitor/inappbrowser crashes app on android

I have extra simple app that consists of one page.
Everything works ok on Web or Android.

When I just install InAppBrowser and try to run it on Android - app opens and instantly closes (real device or emulator - no diff) - even if I’m not use that code and imports for real.
So I do next steps:

  1. Installed capacitor/inappbrowser
  2. build/copy/sync
  3. up minSdkVersion to 26 (requirements)
  4. run app
npm install @capacitor/inappbrowser
npx cap sync

That’s all, build is successful but app not opened anymore.
If I remove inappbrowser depency and make sync & run - all works fine again.

How to find out what’s wrong with that?

P.S.
Gradle vars

    minSdkVersion = 26
    compileSdkVersion = 34
    targetSdkVersion = 34

JDK: openjdk-17
Tested devices: Android 11 (sdk 30)
Capacitor: 6.1.2

1 Like

I would think you should see an error in LogCat. I don’t know if minSdkVersion = 26 would cause an issue, but Capacitor 6 has that set to minSdkVersion = 22 (source).

Yep, but minSdkVersion = 26 is an InAppBrowser requirement (source)

logcat has only one error when application starts:

    Process: com.dev.minishop.app, PID: 9601
    java.lang.RuntimeException: Unable to get provider androidx.startup.InitializationProvider: androidx.startup.StartupException: androidx.startup.StartupException: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/lifecycle/ReportFragment$ActivityInitializationListener;
    	at android.app.ActivityThread.installProvider(ActivityThread.java:7244)
    	at android.app.ActivityThread.installContentProviders(ActivityThread.java:6780)
    	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6697)
    	at android.app.ActivityThread.access$1300(ActivityThread.java:237)
    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
    	at android.os.Handler.dispatchMessage(Handler.java:106)
    	at android.os.Looper.loop(Looper.java:223)
    	at android.app.ActivityThread.main(ActivityThread.java:7656)
    	at java.lang.reflect.Method.invoke(Native Method)
    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
    Caused by: androidx.startup.StartupException: androidx.startup.StartupException: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/lifecycle/ReportFragment$ActivityInitializationListener;
    	at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:187)
    	at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:238)
    	at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:206)
    	at androidx.startup.InitializationProvider.onCreate(InitializationProvider.java:45)
    	at android.content.ContentProvider.attachInfo(ContentProvider.java:2388)
    	at android.content.ContentProvider.attachInfo(ContentProvider.java:2358)
    	at android.app.ActivityThread.installProvider(ActivityThread.java:7239)
    	at android.app.ActivityThread.installContentProviders(ActivityThread.java:6780) 
    	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6697) 
    	at android.app.ActivityThread.access$1300(ActivityThread.java:237) 
    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913) 
    	at android.os.Handler.dispatchMessage(Handler.java:106) 
    	at android.os.Looper.loop(Looper.java:223) 
    	at android.app.ActivityThread.main(ActivityThread.java:7656) 
    	at java.lang.reflect.Method.invoke(Native Method) 
    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
    Caused by: androidx.startup.StartupException: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/lifecycle/ReportFragment$ActivityInitializationListener;
    	at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:187)
    	at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:173)
    	at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:238) 
    	at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:206) 
    	at androidx.startup.InitializationProvider.onCreate(InitializationProvider.java:45) 
    	at android.content.ContentProvider.attachInfo(ContentProvider.java:2388) 
    	at android.content.ContentProvider.attachInfo(ContentProvider.java:2358) 
    	at android.app.ActivityThread.installProvider(ActivityThread.java:7239) 
    	at android.app.ActivityThread.installContentProviders(ActivityThread.java:6780) 
    	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6697) 
    	at android.app.ActivityThread.access$1300(ActivityThread.java:237) 
    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913) 
    	at android.os.Handler.dispatchMessage(Handler.java:106) 
    	at android.os.Looper.loop(Looper.java:223) 
    	at android.app.ActivityThread.main(ActivityThread.java:7656) 
    	at java.lang.reflect.Method.invoke(Native Method) 
    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
    Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/lifecycle/ReportFragment$ActivityInitializationListener;
    	at androidx.lifecycle.ProcessLifecycleInitializer.create(ProcessLifecycleInitializer.kt:37)
    	at androidx.lifecycle.ProcessLifecycleInitializer.create(ProcessLifecycleInitializer.kt:25)
    	at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:180)
    	at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:173) 
    	at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:238) 
    	at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:206) 
    	at androidx.startup.InitializationProvider.onCreate(InitializationProvider.java:45) 
    	at android.content.ContentProvider.attachInfo(ContentProvider.java:2388) 
    	at android.content.ContentProvider.attachInfo(ContentProvider.java:2358) 
    	at android.app.ActivityThread.installProvider(ActivityThread.java:7239) 
    	at android.app.ActivityThread.installContentProviders(ActivityThread.java:6780) 
    	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6697) 
    	at android.app.ActivityThread.access$1300(ActivityThread.java:237) 
    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913) 
    	at android.os.Handler.dispatchMessage(Handler.java:106) 
    	at android.os.Looper.loop(Looper.java:223) 
    	at android.app.ActivityThread.main(ActivityThread.java:7656) 
    	at java.lang.reflect.Method.invoke(Native Method) 
    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
    Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.lifecycle.ReportFragment$ActivityInitializationListener" on path: DexPathList[[zip file "/data/app/~~Kdst-5Y3SOSAak-FDbc_fw==/com.dev.minishop.app-TLEytO-oZBYPR_kf1r8j3Q==/base.apk"],nativeLibraryDirectories=[/data/app/~~Kdst-5Y3SOSAak-FDbc_fw==/com.dev.minishop.app-TLEytO-oZBYPR_kf1r8j3Q==/lib/x86, /system/lib, /system_ext/lib]]
    	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    	at androidx.lifecycle.ProcessLifecycleInitializer.create(ProcessLifecycleInitializer.kt:37) 
    	at androidx.lifecycle.ProcessLifecycleInitializer.create(ProcessLifecycleInitializer.kt:25) 
    	at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:180) 
    	at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:173) 
    	at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:238) 
    	at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:206) 
    	at androidx.startup.InitializationProvider.onCreate(InitializationProvider.java:45) 
    	at android.content.ContentProvider.attachInfo(ContentProvider.java:2388) 
    	at android.content.ContentProvider.attachInfo(ContentProvider.java:2358) 
    	at android.app.ActivityThread.installProvider(ActivityThread.java:7239) 
    	at android.app.ActivityThread.installContentProviders(ActivityThread.java:6780) 
    	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6697) 
    	at android.app.ActivityThread.access$1300(ActivityThread.java:237) 
    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913) 
    	at android.os.Handler.dispatchMessage(Handler.java:106) 
    	at android.os.Looper.loop(Looper.java:223) 
    	at android.app.ActivityThread.main(ActivityThread.java:7656) 
    	at java.lang.reflect.Method.invoke(Native Method) 
    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) ```

I have the same problem.
Capacitor InAppBrowser is not working when running on android.

Already tried to reinstall npm packages, capacitor InAppBrowser V1.01 and 1.02.

In my case I am also using vite package manager.

* What went wrong:
Could not determine the dependencies of task ':capacitor-inappbrowser:compileDebugKotlin'.
> Unknown Kotlin JVM target: 23

Maybe it has to do with my Java JDK V23, which is not compatible? Does an older one have to be installed?

@wwilson Any news on this? could you solve it?

Edit:
In following post, it was mentioned, that certain java versions are not compatible with gradle versions:
Gradle - Java compatibility
Java copatibility matrix

Edit 2:
I tried installing Java JDK 17 as it is the supported version for gradle.
Then android can be deployed but app crashes when starting up.

Other Specs:

  • Android 14.0 SDK, API Level 34
  • Tried enabling “K2 mode” (beta) in Android Studio Kotlin Settings. Did not help
  • Capacitor 6.0.1
  • Capacitor InAppBrowser 1.02 (tested 1.01 as well).

Any ideas highly appreciated.

I have the exact same issue, it’s blocking for me. Without this plugin, did you find any alternative for opening an url within the AppView scope (Cookies sharing in particular) ?
It is required to make SSO work in my usecase.

Unfortunatly, I found no solution yet.
There is another capacitor browser but it does not work for my usecase:
https://capacitorjs.com/docs/apis/browser

Edit:
I think there is a solution here:
https://github.com/ionic-team/capacitor-os-inappbrowser/issues/30