Skip to content

Camera initialization fails when re-running the app without stopping it #176451

@giordy16

Description

@giordy16

Steps to reproduce

Run the official example. Then re-run the app without stopping it.
See #176288 (comment)

I guess has something to do with the migration from camera_android to camera_android_camerax, since with camera: 0.10.6 the problem doesn't happen.

Expected results

App shouldn't crash

Actual results

App crash

Code sample

official example

Logs

Logs
E/AndroidRuntime(11999): FATAL EXCEPTION: main
E/AndroidRuntime(11999): Process: com.lucagiordano.app.test.test_app, PID: 11999
E/AndroidRuntime(11999): java.lang.IllegalArgumentException: Unsupported value: 'io.flutter.plugins.camerax.ObserverProxyApi$ObserverImpl@dfca9e2' of type 'io.flutter.plugins.camerax.ObserverProxyApi$ObserverImpl'
E/AndroidRuntime(11999): 	at io.flutter.plugins.camerax.CameraXLibraryPigeonProxyApiBaseCodec.writeValue(CameraXLibrary.g.kt:971)
E/AndroidRuntime(11999): 	at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:277)
E/AndroidRuntime(11999): 	at io.flutter.plugins.camerax.CameraXLibraryPigeonCodec.writeValue(CameraXLibrary.g.kt:1369)
E/AndroidRuntime(11999): 	at io.flutter.plugins.camerax.CameraXLibraryPigeonProxyApiBaseCodec.writeValue(CameraXLibrary.g.kt:853)
E/AndroidRuntime(11999): 	at io.flutter.plugin.common.StandardMessageCodec.encodeMessage(StandardMessageCodec.java:76)
E/AndroidRuntime(11999): 	at io.flutter.plugin.common.BasicMessageChannel.send(BasicMessageChannel.java:107)
E/AndroidRuntime(11999): 	at io.flutter.plugins.camerax.PigeonApiObserver.onChanged(CameraXLibrary.g.kt:1900)
E/AndroidRuntime(11999): 	at io.flutter.plugins.camerax.ObserverProxyApi$ObserverImpl$1.run(ObserverProxyApi.java:32)
E/AndroidRuntime(11999): 	at android.app.Activity.runOnUiThread(Activity.java:7074)
E/AndroidRuntime(11999): 	at io.flutter.plugins.camerax.ProxyApiRegistrar.runOnMainThread(ProxyApiRegistrar.java:84)
E/AndroidRuntime(11999): 	at io.flutter.plugins.camerax.ObserverProxyApi$ObserverImpl.onChanged(ObserverProxyApi.java:28)
E/AndroidRuntime(11999): 	at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
E/AndroidRuntime(11999): 	at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
E/AndroidRuntime(11999): 	at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
E/AndroidRuntime(11999): 	at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
E/AndroidRuntime(11999): 	at androidx.camera.core.impl.utils.MappingRedirectableLiveData.redirectTo$lambda$2$lambda$0(LiveDataUtil.kt:93)
E/AndroidRuntime(11999): 	at androidx.camera.core.impl.utils.MappingRedirectableLiveData.$r8$lambda$V9EBonQFq1dAKwmRnh8LBc1iwpk(Unknown Source:0)
E/AndroidRuntime(11999): 	at androidx.camera.core.impl.utils.MappingRedirectableLiveData$$ExternalSyntheticLambda0.invoke(D8$$SyntheticClass:0)
E/AndroidRuntime(11999): 	at androidx.camera.core.impl.utils.MappingRedirectableLiveData.redirectTo$lambda$2$lambda$1(LiveDataUtil.kt:93)
E/AndroidRuntime(11999): 	at androidx.camera.core.impl.utils.MappingRedirectableLiveData.$r8$lambda$TCWj4oM3TKXgmbBeE1jMGz0gCa4(Unknown Source:0)
E/AndroidRuntime(11999): 	at androidx.camera.core.impl.utils.MappingRedirectableLiveData$$ExternalSyntheticLambda1.onChanged(D8$$SyntheticClass:0)
E/AndroidRuntime(11999): 	at androidx.lifecycle.MediatorLiveData$Source.onChanged(MediatorLiveData.java:171)
E/AndroidRuntime(11999): 	at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
E/AndroidRuntime(11999): 	at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
E/AndroidRuntime(11999): 	at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
E/AndroidRuntime(11999): 	at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
E/AndroidRuntime(11999): 	at androidx.lifecycle.LiveData$1.run(LiveData.java:93)
E/AndroidRuntime(11999): 	at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(11999): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(11999): 	at android.os.Looper.loop(Looper.java:233)
E/AndroidRuntime(11999): 	at android.app.ActivityThread.main(ActivityThread.java:8068)
E/AndroidRuntime(11999): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(11999): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
E/AndroidRuntime(11999): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)

Flutter Doctor output

Doctor output
lucagiordano@Lucas-MacBook-Pro test_app % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.35.5, on macOS 15.3.2 24D81 darwin-arm64, locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 36.1.0)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 16.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2025.1)
[✓] VS Code (version 1.104.2)
[✓] Connected device (5 available)
    ! Error: Browsing on the local area network for Hello Bob. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listd: examplesSample code and demosfound in release: 3.35Found to occur in 3.35found in release: 3.37Found to occur in 3.37has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versiont: hot reloadReloading code during "flutter run"team-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions