Monzo 利用 CameraX 缩减了 9,000 多行代码并使注册流程中的访问者流失率降低了 5 倍
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Monzo 是一家银行服务公司并提供了同名应用,仅在移动设备上提供数字金融服务。他们的使命是向每个人传授生财之道。为了完成新客户注册,Monzo 应用会拍摄身份证明文件(例如护照、驾照或身份证)的图片,并拍摄自拍视频来证明身份证明文件属于申请者。
策略
Monzo 应用的早期版本使用了 camera2 API。在某些设备上会随机发生崩溃和异常行为,这导致 25% 的潜在客户无法继续进行身份证明拍摄和自拍视频步骤。
为了应对这些挑战,Monzo 转为采用 CameraX。这是一个 Jetpack 支持库,旨在简化相机应用的开发,以满足他们的图片和视频拍摄要求。通过 CameraController
,Monzo 使用 takePicture()
方法实现了身份证明文件的图片拍摄。对于自拍视频,他们则使用了 startRecording()
和 stopRecording()
方法。他们希望从设计上更改注册流程,并希望相机库更为简洁,从而赋予他们更多设计灵活性。
成果
引入 CameraX 使 Monzo 得以简化代码,使代码更具可维护性,并且有助于简化开发。迁移到 CameraX 后,崩溃次数大幅减少,并且没有再出现相机闪光灯随机激活的现象。所有这些措施都有助于降低注册流程中的访问者流失率,并且获得了更多用户的正面反馈。
受益于 CameraX 的代码简化使得代码行数减少了约 9,000 行,其中包括 6,000 行界面代码。CameraX 的使用不仅使代码更易于维护、简化了开发工作,而且还提高了单元测试中的代码覆盖率。
重要的是,这对注册流程带来了非常大的影响。随着 CameraX 的引入以及流程设计的简化,身份证明图片拍摄和自拍视频录制流程中的访问者流失率从 25% 下降到了 5% 左右。
“对于我们来说,CameraX 的引入完全是为了提高稳定性,并为我们的开发者提供了轻松的集成体验。这个库给我们带来了非常理想的效果 - 我们只希望能够轻松拍摄图片和视频。CameraX 让我们实现了这个目标,而且我们的代码得到了简化,用户体验也得到了提升。”Anastasios Morfopoulos – Monzo 的 Android 开发者
开始使用
请查看 CameraX 文档,了解如何为应用或游戏引入更强大且经过简化的图片拍摄代码。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Monzo reduced over 9,000 lines of code and improved registration dropout by 5x with CameraX\n\nMonzo is a banking service and app offering digital and mobile-only financial\nservices. Their mission is to make money work for everyone. To sign up new\ncustomers, the Monzo app captures images of an identification document (such as\npassport, driving license, or ID card) and takes a selfie video to prove that\nthe identification documents are for the applicant.\n\nWhat they did\n-------------\n\nEarly versions of the\n[Monzo](https://play.google.com/store/apps/details?id=co.uk.getmondo)\napp used camera2 APIs. Random crashes and odd behaviors on some devices led to\n25% of potential customers not proceeding beyond the identification capture and\nselfie video steps.\n\nTo address these challenges, Monzo turned to CameraX, a Jetpack support library\ndesigned to make camera app development easier, to implement their image and\nvideo capture requirements. Using\n[`CameraController`](/reference/androidx/camera/view/CameraController), Monzo implemented\nthe identification document image capture using the\n[`takePicture()`](/reference/androidx/camera/view/CameraController#takePicture(androidx.camera.core.ImageCapture.OutputFileOptions,%20java.util.concurrent.Executor,%20androidx.camera.core.ImageCapture.OnImageSavedCallback))\nmethod. For the selfie video, they used the\n[`startRecording()`](/reference/androidx/camera/view/CameraController#startRecording(androidx.camera.view.video.OutputFileOptions,%20java.util.concurrent.Executor,%20androidx.camera.view.video.OnVideoSavedCallback))\nand\n[`stopRecording()`](/reference/androidx/camera/view/CameraController#stopRecording())\nmethods. They wanted to make design changes to the sign-up flow and wanted a\nmore straightforward camera library that would give them more design\nflexibility.\n\nResults\n-------\n\nIntroducing CameraX enabled Monzo to simplify their code, making it more\nmaintainable, and has helped simplify development. The move to CameraX has\ngreatly reduced crashes and they are no longer seeing random activations of the\ncamera flash. All of this has contributed to a reduction in the drop-off rate in\nthe sign-up flow and has improved user feedback.\n\nThe simplification in code resulting from implementing CameraX reduced almost\n9,000 lines of code, including 6,000 lines of UI code. In addition to making\nthe code easier to maintain and simplifying development, CameraX also led to\nbetter code coverage in unit tests.\n\nImportantly, the impact on the sign-up flow was significant. With the\nintroduction of CameraX and the simplified flow design changes, the dropout rate\nfrom identification image capture and selfie video recording dropped from 25% to\naround 5%.\n\n\"For us, CameraX was all about stability and having an easy integration\nexperience for our developers. It was the perfect library for us---we just\nwanted a simple way to take pictures and videos. CameraX has given us that, plus\nour code is simpler and the user experience better.\" *Anastasios\nMorfopoulos---Android developer, Monzo*\n\nGet started\n-----------\n\nCheck out the [CameraX documentation](/training/camerax) to learn how to\nintroduce more robust and simplified image capture code to your app or game."]]