Is CameraX supported on a the Android emulator?

608 views
Skip to first unread message

Andrew Gable

unread,
May 22, 2019, 5:40:39 PM5/22/19
to Android CameraX Discussion Group
I am seeing a crash on my Pixel 3 API 28 emulator when running the CameraX Basic App here: https://github.com/android/camera/tree/master/CameraXBasic

2019-05-22 14:39:12.464 6777-6777/com.android.example.cameraxbasic E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.android.example.cameraxbasic, PID: 6777
    java.lang.ArithmeticException: divide by zero
        at androidx.camera.camera2.impl.SupportedSurfaceCombination.getAllPossibleSizeArrangements(SupportedSurfaceCombination.java:435)
        at androidx.camera.camera2.impl.SupportedSurfaceCombination.getSuggestedResolutions(SupportedSurfaceCombination.java:195)
        at androidx.camera.camera2.impl.Camera2DeviceSurfaceManager.getSuggestedResolutions(Camera2DeviceSurfaceManager.java:185)
        at androidx.camera.core.CameraX.calculateSuggestedResolutions(CameraX.java:449)
        at androidx.camera.core.CameraX.bindToLifecycle(CameraX.java:144)
        at com.android.example.cameraxbasic.fragments.CameraFragment.bindCameraUseCases(CameraFragment.kt:301)
        at com.android.example.cameraxbasic.fragments.CameraFragment.access$bindCameraUseCases(CameraFragment.kt:100)
        at com.android.example.cameraxbasic.fragments.CameraFragment$onViewCreated$1.run(CameraFragment.kt:234)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

I don't see the same error on a Pixel 2XL or Galaxy S8 physical device. Is CameraX currently supported on emulators?

James Fung

unread,
May 22, 2019, 6:53:40 PM5/22/19
to Android CameraX Discussion Group
Hi Andrew, 

This sounds like a similar issue spotted in the current build, with a fix now merged:

Issue:

If so, the fix will be in the next build.  Generally the emulator should work, in a sense its a 'device' to ensure compatibility with.

We're open to hearing more about how heavily the emulator is used by camera developers in their workflows to help balance priorities.

James Fung

unread,
May 22, 2019, 7:00:51 PM5/22/19
to Android CameraX Discussion Group
Here's the correct issue tracker link:
https://issuetracker.google.com/issues/132603284
Reply all
Reply to author
Forward
0 new messages