This guide explains the process of integrating the OCR library of Nutrient for Android into your project. The OCR library is designed to work best with Android Studio(opens in a new tab) and the Gradle(opens in a new tab) build system. We recommend the latest stable Android Studio as the IDE and the latest stable Android Gradle plugin for development.

Setting up OCR

Below is a list of steps required to set up OCR.

Step 1 — Adding Nutrient and OCR to your project

You must first log in to the Nutrient Portal(opens in a new tab) before accessing the Maven repository.

  1. In your top-level build.gradle file, add the Nutrient Maven repository:

    allprojects {
    repositories {
    maven {
    url 'https://my.nutrient.io/maven/'
    }
    }
    }
  2. In your app-level build.gradle file, add the Nutrient and OCR dependencies:

    dependencies {
    implementation "io.nutrient:nutrient:{% $LATEST_VERSIONS.ANDROID %}"
    implementation "io.nutrient:nutrient-ocr:{% $LATEST_VERSIONS.ANDROID %}"
    }

Step 2 — Adding OCR language packs

For each supported language you want to perform OCR for, your app needs to contain a language pack. Each language pack has to be added as a dependency, either to your primary application module, or transitively — for example, by adding it to a dynamic feature APK module, which can be downloaded to a device on demand using Play Feature Delivery(opens in a new tab).

To add one or more OCR language packs to an Android module, specify them inside the dependencies block of that module:

dependencies {
// The language pack version has to match the Nutrient and OCR library versions.
final nutrient_version = '{% $LATEST_VERSIONS.ANDROID %}'
// Pick one or more language packs from this list.
api "io.nutrient:nutrient-ocr-croatian:$nutrient_version"
api "io.nutrient:nutrient-ocr-czech:$nutrient_version"
api "io.nutrient:nutrient-ocr-danish:$nutrient_version"
api "io.nutrient:nutrient-ocr-dutch:$nutrient_version"
api "io.nutrient:nutrient-ocr-english:$nutrient_version"
api "io.nutrient:nutrient-ocr-finnish:$nutrient_version"
api "io.nutrient:nutrient-ocr-french:$nutrient_version"
api "io.nutrient:nutrient-ocr-german:$nutrient_version"
api "io.nutrient:nutrient-ocr-indonesian:$nutrient_version"
api "io.nutrient:nutrient-ocr-italian:$nutrient_version"
api "io.nutrient:nutrient-ocr-malay:$nutrient_version"
api "io.nutrient:nutrient-ocr-norwegian:$nutrient_version"
api "io.nutrient:nutrient-ocr-polish:$nutrient_version"
api "io.nutrient:nutrient-ocr-portuguese:$nutrient_version"
api "io.nutrient:nutrient-ocr-serbian:$nutrient_version"
api "io.nutrient:nutrient-ocr-slovak:$nutrient_version"
api "io.nutrient:nutrient-ocr-slovenian:$nutrient_version"
api "io.nutrient:nutrient-ocr-spanish:$nutrient_version"
api "io.nutrient:nutrient-ocr-swedish:$nutrient_version"
api "io.nutrient:nutrient-ocr-turkish:$nutrient_version"
api "io.nutrient:nutrient-ocr-welsh:$nutrient_version"
}

When adding language packs transitively to submodules of your primary app module (for example, with Play Feature Delivery(opens in a new tab)), make sure to specify the language packs using the api configuration instead of implementation.

Catalog example

You can find a runnable OcrExample(opens in a new tab) inside our Catalog app, and it showcases the use of OCR. To try out the OCR example in action, check out the Catalog Getting Started(opens in a new tab) section.

Next steps

Check out our OCR usage guide to see how to use OCR inside your Android application with Java or Kotlin.