October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Mountain View desk5 min

Building an AI Receipt Scanner for Android with Kotlin and ML Kit

Build a Kotlin Android receipt scanner with CameraX and ML Kit OCR, then add a separate parsing and review layer for totals, dates, tax, and line items.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can build an Android receipt scanner by combining CameraX for image capture, ML Kit Text Recognition v2 for printed-text OCR, and your own parsing and review layer for receipt fields. ML Kit recognizes text; it does not decide reliably which amount is the total or which date is the purchase date. Design those as separate steps.

What the app needs to do

A useful scanner has four stages: get camera permission, show a preview and capture a readable image, run OCR, then interpret and review the resulting text. CameraX and ML Kit provide the camera and text-recognition building blocks. Receipt-specific field extraction—such as merchant, date, tax, total, and line items—is application logic you must add.

As an Amazon Associate I earn from qualifying purchases.

  1. Camera access: request runtime camera permission before opening the camera use cases.
  2. Capture: display a viewfinder and either analyze frames continuously or process a still image after capture.
  3. Recognize: pass the image, with the correct rotation, to ML Kit Text Recognition v2.
  4. Interpret and confirm: parse candidate receipt fields separately, preserve the raw recognized text, and let the user correct uncertain values.

Choose how to deliver the OCR model

ML Kit’s Android guide lists two Latin-script dependency options. Bundling makes the model available immediately but increases app size; using the Google Play Services version reduces app-size impact, but the model may need to download before the first successful recognition. The coordinates below are those shown in the official ML Kit guide when consulted and can change, so check that guide and your Android Gradle configuration before using them.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Option Dependency shown in the guide Trade-off
Bundled model com.google.mlkit:text-recognition:16.0.1 Larger app download; model is available immediately.
Google Play Services model com.google.android.gms:play-services-mlkit-text-recognition:19.0.1 Smaller app-size impact; first use can wait for a model download.

The ML Kit API requires Android API level 23 or higher. CameraX itself states API 21 as its minimum, but an app combining CameraX with this OCR API must meet ML Kit’s higher minimum. If you choose the unbundled option, account for the possibility that recognition is not ready on the first launch; the guide also documents an ocr manifest dependency declaration for install-time model download. Avoid copying dependency versions from the older 2020-06-17 Android codelab; its examples reflect that codelab’s era.

#1 Best Overall
Samsung Galaxy A17 5G Smart Phone 128GB US 1 Yr Manufacturer Warranty Black | Large AMOLED, High-Res Camera, Durable Design, Super Fast Charging, Expandable Storage, Circle to Search, 2025
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

Build the camera flow with CameraX

For a new camera app, Android recommends CameraX. Bind a Preview use case for the viewfinder and an ImageAnalysis use case when you want to run OCR on camera frames, associating the use cases with the camera lifecycle. Request permission before binding. The CameraX overview covers the camera architecture, while the ML Kit Analyzer guide recommends using CameraController with PreviewView when that integration fits your app. Its analyzer can handle coordinate transformations between analysis frames and the displayed preview, which is useful if you draw detected-text boxes over the viewfinder.

Live recognition or capture-then-process?

Approach Best fit Design consideration
Live ImageAnalysis On-screen guidance while the user positions a receipt. Limit work to keep the interface responsive. CameraX’s image analysis documentation describes a latest-frame behavior: when analysis is still running as another frame arrives, the buffered image is replaced with the latest one rather than accumulating an ever-growing queue.
Capture, then process a still A straightforward scanning flow where the user frames the receipt and taps a capture button. Run OCR on the captured image for the final result; this separates framing feedback from recognition of the image the user chose.

For a first version, capture-then-process is often simpler to reason about: the app needs to handle a single chosen image and can present the result for review. Add continuous analysis if immediate framing guidance is important to the experience.

Rank #2
Tracfone Motorola Moto G 2025, 64GB, Saphire Blue (Locked to
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Tracfone plan required, activating is easy, just 3 steps.
  • DISPLAY: Immersive viewing on a 6.7-inch super-bright 120Hz display with powerful stereo speakers and Bass Boost for cinematic entertainment.
  • CAMERA SYSTEM: Advanced 50MP Quad Pixel camera captures sharp, detailed photos and videos in any lighting condition
  • PERFORMANCE: Lightning-fast 5G connectivity paired with a powerful processor and RAM Boost for smooth multitasking.
  • BATTERY LIFE: Long-lasting 5000mAh battery with TurboPower charging technology delivers hours of power in minutes.

Send a correctly rotated image to ML Kit

The Kotlin flow in the ML Kit Android guide is to create a recognizer with TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS), create an InputImage, and call recognizer.process(image). When processing a CameraX ImageProxy, use its media image and the rotation reported by CameraX:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
val mediaImage = imageProxy.image
if (mediaImage != null) {
    val image = InputImage.fromMediaImage(
        mediaImage,
        imageProxy.imageInfo.rotationDegrees
    )
    recognizer.process(image)
        .addOnSuccessListener { result ->
            // Read recognized text from result.
        }
        .addOnFailureListener { error ->
            // Report or handle the recognition failure.
        }
        .addOnCompleteListener {
            imageProxy.close()
        }
}

This illustrates the essential frame and rotation handling; integrate it with your app’s chosen task-listener style and error reporting. In a live analyzer, close each proxy after the asynchronous task completes, including when recognition fails. Otherwise the camera analysis pipeline can stop receiving frames. The older codelab demonstrates this close-on-completion lifecycle pattern, but its dependency setup should not be treated as current.

Rank #3
Sale
Samsung Galaxy A17 5G Smart Phone 128GB, US 1 Yr Manufacturer Warranty Blue | Large AMOLED, High-Res Camera, Durable Design, Super Fast Charging, Expandable Storage, Circle to Search, 2025
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

Keep the recognizer for the lifetime of the component that uses it, then close or release it when that component is permanently finished, as described in the ML Kit guide. Also handle the case where an image proxy has no media image rather than attempting to create an InputImage from it.

Turn recognized text into receipt fields

ML Kit returns recognized text in a hierarchy of blocks, lines, elements, and symbols. That structure is useful for preserving layout and presenting results, but it is not a receipt schema. The OCR result alone does not establish which number is the grand total, whether a date is the transaction date, or how a line item should be paired with its price.

Rank #4
Sale
Samsung Galaxy S26 Ultra, Unlocked Android Smartphone, 512GB, Black
  • PRIVACY DISPLAY: Automatically hide your screen from those beside you. The built-in privacy display can be preset¹ to turn on when receiving notifications, typing passwords, or using specific apps
  • TYPE IT IN. TRANSFORM IT FAST: Enhance any shot in seconds on your smartphone by using Photo Assist² with Galaxy AI.³ Add objects, restore details, or apply new styles by simply typing or tapping
  • NIGHTS, CAPTURED CLEARLY: From gigs to city lights, record and capture moments after dark with clarity using Nightography so your photos and videos stay crisp and clear on your Samsung Galaxy
  • MAKE IT. EDIT IT. SHARE IT: Turn everyday moments into something personal with creative tools built right into your mobile phone, whether it’s a special contact photo, custom wallpaper, an invitation or more⁴
  • HELP THAT KEEPS UP: Stay in the moment while Now Nudge with Galaxy AI helps you respond faster and stay organized with smart suggestions⁵ that appear exactly when you need them on your phone

Build receipt understanding as a separate layer:

  • Retain the complete raw OCR text so a user can inspect what recognition found.
  • Extract candidate merchant, date, tax, total, and line-item values with receipt-specific rules of your own.
  • Use nearby labels and layout as evidence, but avoid treating a plausible-looking amount as certain when it could be a subtotal, tendered amount, or change.
  • Present ambiguous fields for user correction before saving or exporting structured data.

The official ML Kit material supports general text recognition and image-quality guidance; it does not provide a receipt parser or a receipt-level accuracy benchmark. Do not describe this design as guaranteed automatic extraction or quote a receipt-recognition percentage without a separate, relevant evaluation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Help users capture readable images

Image quality affects OCR. ML Kit’s image guidance says, “Ideally, each character should be at least 16×16 pixels.” This is a general OCR guideline, not a receipt-specific tested threshold. The guide also says accuracy generally does not improve once characters exceed 24×24 pixels. In practice, make the printed text occupy enough of the image, keep the camera focused, and ask for a recapture when the image is blurry. For live recognition, a smaller frame can reduce latency if the text remains sufficiently detailed.

Best Value
Tracfone Moto g Play 2024 Prepaid Phone with a 1-Yr Plan Included
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Activating is easy, just 3 steps.
  • ACTIVATION Promotion: Includes 1500 min, 1500 texts & 1500 MB Data + add more as you need it
  • CAMERA SYSTEM: 50MP Quad Pixel camera. Capture sharper, more vibrant photos day or night with 4x the light sensitivity.
  • PERFORMANCE: Blazing-fast Qualcomm performance. Get the speed you need for great entertainment with a Snapdragon 680 processor and 4GB of RAM.
  • 64GB built-in storage. Get plenty of room for photos, movies, songs, and apps. Made for US
  • Show a receipt-shaped framing guide so users know how to fill the preview.
  • Offer a retake when the captured image is visibly out of focus or the OCR result is incomplete.
  • Keep the original image or provide a review step if users need to verify uncertain text against the receipt.

Test the whole path on a device

Camera permission, preview behavior, focus, rotation, and model readiness all affect the actual scanning experience. The official Android codelab asks for a physical Android device; using one is particularly useful for checking real camera framing and image quality. The reviewed setup guidance does not call for a separate accessory or a particular phone model.

Test both successful and failure paths: permission denied, an image that is rotated, an out-of-focus receipt, a first launch before an unbundled model is ready, and a recognition task that fails. In live analysis, verify that the proxy is always closed so new frames continue to arrive. For the structured output, verify that uncertain totals and dates remain editable rather than silently becoming trusted data.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.