# Getting a License for Android SDK

You can generate the trial license [here](https://ozforensics.com/developers/try_mobile_sdk) or contact us by [email](mailto:info@ozforensics.com) to get a productive license. To create the license, your `applicationId` (`bundle id`) is required.

To pass your license file to the SDK, call the `OzLivenessSDK.init` method with a list of `LicenseSources`. Use one of the following:

* `LicenseSource.LicenseAssetId` should contain a path to a license file called `forensics.license`, which has to be located in the project's res/raw folder.
* `LicenseSource.LicenseFilePath` should contain a file path to the place in the device's storage where the license file is located.

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

```kotlin
OzLivenessSDK.init(context,
    listOf(
        LicenseSource.LicenseAssetId(R.raw.your_license_name),
        LicenseSource.LicenseFilePath("absolute_path_to_your_license_file")
    ),
    object : StatusListener<LicensePayload> {
        override fun onSuccess(result: LicensePayload) { /*check the license payload*/ }
        override fun onError(error: OzException) { /*handle the exception */ }
    }
  )
```

{% endtab %}

{% tab title="Java" %}

```java
OzLivenessSDK.INSTANCE.getConfig().setBaseURL(BASE_URL);
OzLivenessSDK.INSTANCE.init(context,
    Arrays.asList(
        new LicenseSource.LicenseAssetId(R.raw.forensics),
        new LicenseSource.LicenseFilePath("absolute_path_to_your_license_file")
    ),
    new StatusListener<LicensePayload>() {
        @Override public void onStatusChanged(@Nullable String s) {}
        @Override public void onSuccess(LicensePayload licensePayload) { /*check the license payload*/ }
        @Override public void onError(@NonNull OzException e) { /*handle the exception */ }
    }
);
```

{% endtab %}
{% endtabs %}

In case of any license errors, the `onError` function is called. Use it to handle the exception as shown above. Otherwise, the system will return information about license. To check the license data manually, use the `getLicensePayload` method.

### Possible License Errors

<table><thead><tr><th width="347">Error message</th><th>What to Do</th></tr></thead><tbody><tr><td>License error. License at (your_URI) not found</td><td>The license file is missing. Please check its name and path to the file.</td></tr><tr><td>License error. Cannot parse license from (your_URI), invalid format</td><td>The license file is somehow damaged. Please email us the file.</td></tr><tr><td>License error. Bundle company.application.id is not in the list allowed by license (bundle.id1, bundle.id2)</td><td>The bundle (application) identifier you specified is missing in the allowed list. Please check the spelling, if it is correct, you need to get another license for your application.</td></tr><tr><td>License error. Current date yyyy-mm-dd hh:mm:ss is later than license expiration date yyyy-mm-dd hh:mm:ss</td><td>Your license has expired. Please contact us.</td></tr><tr><td>License is not initialized. Call 'OzLivenessSDK.init before using SDK</td><td>You haven't initialized the license. Call <code>OzLivenessSDK.init</code> with your license data as explained above.</td></tr></tbody></table>
