My app crashes during startup.
When I use logcat I get the error (reverse domain name deliberately obscured for security):
E FATAL EXCEPTION: main (Ask Gemini)
Process: co.uk.*****.provisioner, PID: 11384
java.lang.RuntimeException: Unable to create application co.uk.*****.provisioner.MainApplication: java.lang.IllegalStateException: DevelopmentClientController was initialized.
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7716)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2478)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:8919)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
Caused by: java.lang.IllegalStateException: DevelopmentClientController was initialized.
at expo.modules.devlauncher.DevLauncherController$Companion.initialize$expo_dev_launcher_debug(DevLauncherController.kt:404)
at expo.modules.devlauncher.DevLauncherController$Companion.initialize(DevLauncherController.kt:438)
at expo.modules.devlauncher.DevLauncherController$Companion.initialize$default(DevLauncherController.kt:437)
at expo.modules.devlauncher.DevLauncherPackageDelegate$createApplicationLifecycleListeners$1.onCreate(DevLauncherPackageDelegate.kt:36)
at expo.modules.ApplicationLifecycleDispatcher.onApplicationCreate(ApplicationLifecycleDispatcher.kt:20)
at co.uk.*****.provisioner.MainApplication.onCreate(MainApplication.kt:50)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1316)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7711)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2478)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:8919)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
2025-04-17 12:34:41.911 11384-11384 DevLauncher co.uk.*****.provisioner E DevLauncher tries to handle uncaught exception. (Ask Gemini)
java.lang.RuntimeException: Unable to create application co.uk.*****.provisioner.MainApplication: java.lang.IllegalStateException: DevelopmentClientController was initialized.
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7716)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2478)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:8919)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
Caused by: java.lang.IllegalStateException: DevelopmentClientController was initialized.
at expo.modules.devlauncher.DevLauncherController$Companion.initialize$expo_dev_launcher_debug(DevLauncherController.kt:404)
at expo.modules.devlauncher.DevLauncherController$Companion.initialize(DevLauncherController.kt:438)
at expo.modules.devlauncher.DevLauncherController$Companion.initialize$default(DevLauncherController.kt:437)
at expo.modules.devlauncher.DevLauncherPackageDelegate$createApplicationLifecycleListeners$1.onCreate(DevLauncherPackageDelegate.kt:36)
at expo.modules.ApplicationLifecycleDispatcher.onApplicationCreate(ApplicationLifecycleDispatcher.kt:20)
at co.uk.*****.provisioner.MainApplication.onCreate(MainApplication.kt:50)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1316)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7711)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2478)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:8919)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
GitHub Copilot says:
The error DevelopmentClientController was initialized means that somewhere during the app's startup, the Dev Launcher setup is happening twice. While the call ApplicationLifecycleDispatcher.onApplicationCreate(this) is standard, something it triggers, or perhaps another part of your native setup, is causing the duplicate initialization.
The crash log points to an issue within the Expo Dev Launcher's initialization process, which is triggered by:
// This line triggers Expo's setup, including the Dev Launcher
ApplicationLifecycleDispatcher.onApplicationCreate(this)
in your MainApplication.kt's onCreate method:
package co.uk.*****.provisioner
import android.app.Application
import android.content.res.Configuration
import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackage
import com.facebook.react.ReactHost
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.react.soloader.OpenSourceMergedSoMapping
import com.facebook.soloader.SoLoader
import expo.modules.ApplicationLifecycleDispatcher
import expo.modules.ReactNativeHostWrapper
class MainApplication : Application(), ReactApplication {
override val reactNativeHost: ReactNativeHost = ReactNativeHostWrapper(
this,
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> {
val packages = PackageList(this).packages
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages
}
override fun getJSMainModuleName(): String = ".expo/.virtual-metro-entry"
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
}
)
override val reactHost: ReactHost
get() = ReactNativeHostWrapper.createReactHost(applicationContext, reactNativeHost)
override fun onCreate() {
super.onCreate()
SoLoader.init(this, OpenSourceMergedSoMapping)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
}
ApplicationLifecycleDispatcher.onApplicationCreate(this)
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig)
}
}
I've searched through all files in my Android directory that may be relevant, but I haven't found anything that could be triggered by the suspect line in the code sample above. I also haven't found any other part of my native Android system that could cause the duplication.