> For the complete documentation index, see [llms.txt](https://regulaforensics.gitbook.io/android/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://regulaforensics.gitbook.io/android/migration-guide.md).

# Migration Guide

## Migrating from v5.4 to v5.5

#### Implementations

Changed names of Core packages. Take a look at the following page:

{% content-ref url="/pages/-LmuFJ9WqDTiIA0CxFj4" %}
[How to add the SDK to the project?](/android/how-to-add-the-sdk-to-the-project.md)
{% endcontent-ref %}

## Migrating from v5.3 to v5.4

Errors are returned as `DocumentReaderException` instead of `Throwable`.

## Migrating from v5.2 to v5.3

#### Custom settings

Use [`setCameraSize(int width, int height)`](/android/custom-settings.md#video-settings)  instead of [`setCameraSize(Camera.Size cameraSize)`](/android/custom-settings.md#video-settings).

#### Results

* Removed [`overallResult`](/android/results/description-of-results.md#results) from [`DocumentReaderResults`](/android/results/description-of-results.md#results). Use [`getOverallResult`](/android/results/description-of-results.md#results) instead.
* Removed `jsonResult` from [`DocumentReaderResults`](/android/results/description-of-results.md#results). Use [`rawResult`](/android/results/description-of-results.md#results) instead.

## Migrating from v5.1 to v5.2

Errors are returned as [Throwable](https://developer.android.com/reference/java/lang/Throwable) now.

The database has to be updated along with the SDK as it's a part of it.

## Migrating from v5.0 to v5.1

{% hint style="info" %}
If you build an app with AndroidX, you have to enable the Jetifier plugin that automatically migrates existing third-party libraries to use AndroidX. [See how](https://developer.android.com/jetpack/androidx/migrate).
{% endhint %}

#### Database

The database has to be updated along with the SDK as it's a part of it.

#### Show scanner

If the below error was encountered, make sure that the right context had been passed to the [`showScanner()`](/android/show-scanner.md) method, i.e. it has to be the context of the activity rather than the application.

```
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
```

#### Custom settings

Custom settings of the [Customization](/android/custom-settings.md#customization) and [Functionality](/android/custom-settings.md#functionality) class have to be set in the following way:

{% tabs %}
{% tab title="Java" %}

```java
DocumentReader.Instance().customization().edit().setStatus("Hello").applyImmediately(MainActivity.this);
DocumentReader.Instance().customization().edit().setShowHelpAnimation(true).apply();

DocumentReader.Instance().functionality().edit().setShowCaptureButton(true).apply();
DocumentReader.Instance().functionality().edit().setVideoCaptureMotionControl(true).apply();
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
DocumentReader.Instance().customization().edit().setStatus("Hello").applyImmediately(this@MainActivity)
DocumentReader.Instance().customization().edit().setShowHelpAnimation(true).apply()

DocumentReader.Instance().functionality().edit().setShowCaptureButton(true).apply()
DocumentReader.Instance().functionality().edit().setVideoCaptureMotionControl(true).apply()
```

{% endtab %}
{% endtabs %}

#### Completion

`DocumentReader.DocumentReaderCompletion` was changed to `IDocumentReaderCompletion`.

`DocumentReader.DocumentReaderInitCompletion` was changed to `IDocumentReaderInitCompletion`.

`DocumentReader.DocumentReaderPrepareCompletion` was changed to `IDocumentReaderPrepareCompletion`.

## Migrating from v4.2 to v5.0

#### Dependencies

Make sure that the new [`common`](https://maven.regulaforensics.com/RegulaDocumentReader/com/regula/documentreader/common/5.0.47/) library is added to the project and presented in the *External Libraries* list, otherwise, you may encounter the following errors:

```
/.../.gradle/caches/transforms-2/files-2.1/e8e5c59b760de91277d4b26b128becb5/res/layout/help_bt_device_fragment.xml:8: AAPT: error: resource dimen/reg_img_button_size (aka com.regula.documentreader:dimen/reg_img_button_size) not found.
/.../.gradle/caches/transforms-2/files-2.1/e8e5c59b760de91277d4b26b128becb5/res/layout/help_bt_device_fragment.xml:8: AAPT: error: resource dimen/reg_small_img_button_padding (aka com.regula.documentreader:dimen/reg_small_img_button_padding) not found.
/.../.gradle/caches/transforms-2/files-2.1/e8e5c59b760de91277d4b26b128becb5/res/layout/help_bt_device_fragment.xml:8: AAPT: error: resource drawable/reg_close (aka com.regula.documentreader:drawable/reg_close) not found.
/.../.gradle/caches/transforms-2/files-2.1/e8e5c59b760de91277d4b26b128becb5/res/layout/help_bt_device_fragment.xml:33: AAPT: error: resource style/PrimaryButton (aka com.regula.documentreader:style/PrimaryButton) not found. 
/.../.gradle/caches/transforms-2/files-2.1/e8e5c59b760de91277d4b26b128becb5/res/layout/help_bt_device_fragment.xml:40: AAPT: error: resource style/PrimaryButton (aka com.regula.documentreader:style/PrimaryButton) not found.
/.../.gradle/caches/transforms-2/files-2.1/e8e5c59b760de91277d4b26b128becb5/res/layout/help_bt_device_fragment.xml:47: AAPT: error: resource style/PrimaryButton (aka com.regula.documentreader:style/PrimaryButton) not found.
/.../.gradle/caches/transforms-2/files-2.1/e8e5c59b760de91277d4b26b128becb5/res/layout/reg_activity_capture.xml:118: AAPT: error: resource dimen/reg_img_button_size (aka com.regula.documentreader:dimen/reg_img_button_size) not found.
/.../.gradle/caches/transforms-2/files-2.1/e8e5c59b760de91277d4b26b128becb5/res/layout/reg_activity_capture.xml:118: AAPT: error: resource dimen/reg_small_img_button_padding (aka com.regula.documentreader:dimen/reg_small_img_button_padding) not found.
/.../.gradle/caches/transforms-2/files-2.1/e8e5c59b760de91277d4b26b128becb5/res/layout/reg_activity_capture.xml:118: AAPT: error: resource drawable/reg_flash_off (aka com.regula.documentreader:drawable/reg_flash_off) not found.
/.../.gradle/caches/transforms-2/files-2.1/e8e5c59b760de91277d4b26b128becb5/res/layout/reg_activity_capture.xml:132: AAPT: error: resource dimen/reg_img_button_size (aka com.regula.documentreader:dimen/reg_img_button_size) not found.
/.../.gradle/caches/transforms-2/files-2.1/e8e5c59b760de91277d4b26b128becb5/res/layout/reg_activity_capture.xml:132: AAPT: error: resource dimen/reg_small_img_button_padding (aka com.regula.documentreader:dimen/reg_small_img_button_padding) not found.
/.../.gradle/caches/transforms-2/files-2.1/e8e5c59b760de91277d4b26b128becb5/res/layout/reg_activity_capture.xml:132: AAPT: error: resource drawable/reg_camera_swap (aka com.regula.documentreader:drawable/reg_camera_swap) not found.
/.../.gradle/caches/transforms-2/files-2.1/e8e5c59b760de91277d4b26b128becb5/res/layout/reg_activity_capture.xml:143: AAPT: error: resource dimen/reg_img_button_size (aka com.regula.documentreader:dimen/reg_img_button_size) not found. 
/.../.gradle/caches/transforms-2/files-2.1/e8e5c59b760de91277d4b26b128becb5/res/layout/reg_activity_capture.xml:143: AAPT: error: resource drawable/reg_capture_activity_camera (aka com.regula.documentreader:drawable/reg_capture_activity_camera) not found.
/.../.gradle/caches/transforms-2/files-2.1/e8e5c59b760de91277d4b26b128becb5/res/layout/reg_activity_capture.xml:164: AAPT: error: resource dimen/reg_img_button_size (aka com.regula.documentreader:dimen/reg_img_button_size) not found.
```

#### Custom settings

[Custom settings](/android/custom-settings.md) should be declared in the following way:

{% tabs %}
{% tab title="Java" %}

```java
DocumentReader.Instance().processParams().scenario = "Mrz";

DocumentReader.Instance().customization().setShowResultStatusMessages(true);

DocumentReader.Instance().rfidScenario().setMrz(accessKey);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
DocumentReader.Instance().processParams().scenario = "Mrz"

DocumentReader.Instance().customization().isShowResultStatusMessages = true

DocumentReader.Instance().rfidScenario().setMrz(accessKey)
```

{% endtab %}
{% endtabs %}

#### Document Type Result

`documentType` is an array now that contains information about each page that has been read.

#### Text Result

Total text result status takes one of [`eCheckResult`](/android/enumerations/echeckresult.md) enum values instead of [`eRPRM_FieldVerificationResult`](/android/enumerations/erprm_fieldverificationresult.md).

#### Graphic Result

`GT_DOCUMENT_REAR` was removed and `GT_DOCUMENT_FRONT` was renamed to `GF_DOCUMENT_IMAGE` (see [`eGraphicFieldType`](/android/enumerations/egraphicfieldtype.md) enum). In order to get the appropriate document side you should use the new property `pageIndex`, which is available in [`DocumentReaderGraphicResult`](/android/results/description-of-results.md#graphic-result) class, e.g. pageIndex = 0 - it’s the first (front) side of the document, pageIndex = 1 - it’s the second (back) side of the document:

{% tabs %}
{% tab title="Java" %}

```java
// Get document side image (first page)
Bitmap documentImageFirstPage = results.getGraphicFieldImageByType(eGraphicFieldType.GF_DOCUMENT_IMAGE, -1, 0);
// Get document side image (second page)
Bitmap documentImageSecondPage = results.getGraphicFieldImageByType(eGraphicFieldType.GF_DOCUMENT_IMAGE, -1, 1);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
// Get document side image (first page)
val documentImageFirstPage = results.getGraphicFieldImageByType(eGraphicFieldType.GF_PORTRAIT, -1, 0)
// Get document side image (second page)
val documentImageSecondPage = results.getGraphicFieldImageByType(eGraphicFieldType.GF_DOCUMENT_IMAGE, -1, 0)
```

{% endtab %}
{% endtabs %}
