Monzo 使用 CameraX 減少 9,000 行程式碼,並讓註冊流失率提升 5 倍
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Monzo 是專門提供數位和行動裝置的金融服務和應用程式,他們的使命是為所有人創造收益。為了註冊新客戶,Monzo 應用程式會擷取身分證明文件 (例如護照、駕照或身分證件) 的圖片,並拍攝自拍影片來證明身分證明文件適用於申請者。
具體措施
早期版本的 Monzo 應用程式使用 camera2 API。在某些裝置上,發生了隨機當機和奇怪的行為,導致 25% 的潛在顧客除了進行識別拍攝及自拍影片步驟以外,沒有繼續程序。
為解決這些挑戰,Monzo 開始採用 CameraX,這個 Jetpack 支援資料庫旨在簡化相機應用程式的開發作業,並實作其圖片和影片拍攝需求。Monzo 運用 CameraController
方法,使用 takePicture()
方法實作身分文件圖片擷取功能。他們在自拍影片時使用 startRecording()
和 stopRecording()
方法。他們想對註冊流程調整設計,並希望提供更直覺化的相機程式庫,以更具設計靈活性。
成果
推出 CameraX 後,Monzo 能夠簡化程式碼,讓程式碼更易於維護,並協助簡化開發作業。移至 CameraX 的當機情形已大幅減少,且不會再看到相機閃光燈的隨機啟動。這些做法都有助於降低註冊流程中的流失率,也改善了使用者意見回饋。
實作 CameraX 後,程式碼的簡化作業會減少將近 9,000 行程式碼,包括 6,000 行 UI 程式碼。除了讓程式碼更易於維護及簡化開發工作之外,CameraX 也有助於提升單元測試的程式碼涵蓋率。
重要的是,這對註冊流程的影響十分重要。隨著 CameraX 的推出和簡化流程設計異動,辨識圖片拍攝和自拍錄影的流失率從 25% 下降至約 5%。
「對我們來說,CameraX 的重點在於穩定性,並讓開發人員享有簡便的整合體驗。這是一款最適合我們的相片庫
只是想以簡單的方式拍照與影片不僅如此,CameraX 還協助我們簡化程式碼,同時改善使用者體驗。」Anastasios Morfopoulos—Android 開發人員 Monzo
開始使用
請參閱 CameraX 說明文件,瞭解如何在應用程式或遊戲中導入更完善且簡化的圖片擷取程式碼。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間: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."]]