> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/android/get-started/faq/add-license.md).

# Add license keys

Add your production license key to Apryse Android SDK easily.

The Apryse library is automatically initialized if you have added a valid license key to your project's `AndroidManifest.xml` file. Alternatively, you can add the key by manually calling the static initialization methods. Before moving forward, please make sure you have [added the Apryse libraries to your project](/android/get-started/integration.md).

{% hint style="info" %}
**No trial license key required.**

The trial of Apryse Mobile SDK does not require a trial key. A commercial license key is required for use in a production environment. Please [contact sales](https://apryse.com/form/contact-sales) to purchase a commercial key or if you need any other license key assistance.
{% endhint %}

{% hint style="warning" %}
**Keep your license keys confidential.**

License keys are uniquely generated. Please make sure that it is not publicly available (e.g. in your public GitHub).
{% endhint %}

## Auto-initialize by adding a license key in AndroidManifest.xml

{% hint style="info" %}
**The Apryse Android SDK is auto-initialized only if there is a key defined in the AndroidManifest.xml file named pdftron\_license\_key. If you prefer to initialize Apryse manually, see the next section for more information.**
{% endhint %}

1. Find your `gradle.properties` file in the root folder of your project and add your license key:

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```sh
PDFTRON_LICENSE_KEY=INSERT_COMMERCIAL_LICENSE_KEY_HERE_AFTER_PURCHASE
```

{% endcode %}
{% endtab %}
{% endtabs %}

1. Then in your module's `build.gradle` file (usually located at `app/build.gradle`) add:

{% tabs %}
{% tab title="Groovy" %}
{% code lineNumbers="true" %}

```groovy
android {
    defaultConfig {
        // ...
        manifestPlaceholders = [pdftronLicenseKey:PDFTRON_LICENSE_KEY]
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

1. Add a placeholder for the license key to your project's `AndroidManifest.xml` file, inside the `<application>` tag:This tag will [inject a build variable containing your license key into the manifest file](https://developer.android.com/studio/build/manifest-build-variables.html).Next try [opening a document in an activity](/android/open-save-document/open/activity.md).

{% tabs %}
{% tab title="XML" %}
{% code lineNumbers="true" %}

```xml
<application ...>

    <!-- Add license key in meta-data tag here. This should be inside the application tag. -->
    <meta-data android:name="pdftron_license_key" android:value="${pdftronLicenseKey}"/>
        
</application>
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Disable auto-initialization

It's also possible to disable auto-initialization altogether by adding the following to the `<application>` tag in your project's `AndroidManifest.xml` file:

{% tabs %}
{% tab title="Groovy" %}
{% code lineNumbers="true" %}

```groovy
<provider
    xmlns:tools="http://schemas.android.com/tools"
    android:name="com.pdftron.pdfnet.PDFNetInitializer"
    android:authorities="${applicationId}.pdftron-pdfnet"
    tools:node="remove" />


<provider
    xmlns:tools="http://schemas.android.com/tools"
    android:name="com.pdftron.pdf.utils.PDFTronToolsInitializer"
    android:authorities="${applicationId}.pdftron-tools"
    tools:node="remove" />
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Manually initialize by adding a license key directly in your code

{% hint style="info" %}
**Please ensure that you do not have pdftron\_license\_key defined in your AndroidManifest.xml file, otherwise Apryse will be auto-initialized using this key.**
{% endhint %}

Depending on the [package you are using](/android/get-started/get-started.md), you will need to call different initialization methods. In your main application's or main activity's onCreate method (and before `setContentView` in your activity) call one of the following:

* \*\*Tools package:\*\*If you are using `com.pdftron:tools` dependency (i.e. using `implementation "com.pdftron:tools:11.0.0"` in your `app/build.gradle` file):

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
com.pdftron.pdf.utils.AppUtils.initializePDFNetApplication(getApplicationContext(), "Insert commercial license key here after purchase");
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
com.pdftron.pdf.utils.AppUtils.initializePDFNetApplication(applicationContext, "Insert commercial license key here after purchase")
```

{% endcode %}
{% endtab %}
{% endtabs %}

* \*\*Apryse package:\*\*If your application requires greater flexibility and you are using classes in the Apryse package directly, you can initialize using the following method instead:If you are also using a the Tools library (i.e. `com.pdftron:tools`) call:Please note that if you use `PDFNet.initialize`, you will have to set up the Apryse library manually (for more information see the [Apryse class documentation](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFNet.html)).

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
PDFNet.initialize(getApplicationContext(), R.raw.pdfnet, "Insert commercial license key here after purchase");
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
PDFNet.initialize(applicationContext, R.raw.pdfnet, "Insert commercial license key here after purchase")
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
```

{% endcode %}
{% endtab %}
{% endtabs %}

Next try [opening a document in an activity](/android/open-save-document/open.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/android/get-started/faq/add-license.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
