Getting started
Sample Project
If you prefer sample projects over documentation, check out our Docutain SDK Android Sample on Github.
Docutain SDK Dependencies
The Docutain SDK for Android is distributed through Maven repositories, so make sure you have added mavenCentral()
in your settings.gradle
file:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
If you are using old syntax for specifying repositories, make sure that mavenCentral()
is added in your top level build.gradle
file:
allprojects {
repositories {
google()
mavenCentral()
}
}
Afterwards, you can add dependencies to your build.gradle
file:
def docutainSdkVersion = '1.7.0.3'
//For Document Scanner components
implementation("de.docutain:Docutain-SDK-UI:$docutainSdkVersion")
//For Data Extraction and OCR (Text Recognition) components
implementation("de.docutain:Docutain-SDK-DataExtraction:$docutainSdkVersion")
CompileSdk
The compileSdk
of your app needs to be set to 34
or greater. Note that updating the compileSdk
(which allows newer APIs to be used) can be done seperately from updating targetSdk
and minSdk
. So this should have no negative impact on your app.
Android Gradle Plugin
To run the Docutain SDK on Android, your projects needs to have AGP (Android Gradle Plugin) Version 8.0.2
or higher.
If you are currently using an AGP version lower than 8.0.2, you need to upgrade to at least 8.0.2. We recommend to do this with Android Studio. Open the native Android project of your Flutter project with Android Studio and use the AGP Upgrade Assistant.
More details on upgrading AGP
When upgrading AGP version, you might get an error similar to the following:
Starting with AGP version 8, each project needs to define a namespace. The Docutain SDK already supports this, but you might use some other 3rd party dependencies that have not been upgraded to using namespaces yet.
You can upgrade all your packages to the latest version in the build.gradle
and see if this solves the issue.
If not, you need to add the highlighted part to your project's build.gradle
:
allprojects {
repositories {
google()
mavenCentral()
}
subprojects {
afterEvaluate { project ->
if (project.hasProperty('android')) {
project.android {
if (namespace == null) {
namespace project.group
}
}
}
}
}
}
Camera Permission
If you want to use the Document Scanner, declare the following permission in your AndroidManifest.xml
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera"/>
Runtime permission for camera is handled automatically by the Docutain SDK.
Memory settings
Your application will work with high-resolution images. To avoid OutOfMemoryError exceptions it is highly recommended to set android:largeHeap="true"
in the <application>
element of your AndroidManifest.xml
file.
<application android:largeHeap="true" ...>
...
</application>