> For the complete documentation index, see [llms.txt](https://docs.licensespring.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.licensespring.com/sdks/android-sdk/sdk-initialization.md).

# SDK Initialization

The SDK behaves as a singleton — initialize it only once and reuse it. As soon as you initialize the SDK, it will contact the LicenseSpring server to check if there is an existing license for the current device / product combination.

If a license is available, it will be immediately accessible as a License object. During initialization the `LicenseManager` will try to read the license information from the specified license file and validate it with the license server. If successful, `LicenseManager.getCurrent()` will return a `License` object with detailed license information.

{% hint style="info" %}
The `LicenseManager` takes two arguments for initialization: `LicenseSpringConfiguration` and the application context. The application context is used to save license files to internal app storage.
{% endhint %}

{% hint style="info" %}
The SDK has a hardware key generator based on the Secure Android ID. If the Secure Android ID is null, a UUID will be used as the hardware key.
{% endhint %}

{% hint style="warning" %}
At minimum, you must provide three parameters to initialize the SDK:

* `apiKey` — your company API key
* `productCode` — a two-letter string identifying the product (application)
* `sharedKey` — company-specific encryption key used when signing requests

All of these values are available in the LicenseSpring web platform under the "SDK integration" section.
{% endhint %}

{% stepper %}
{% step %}

### Build configuration

Create a `LicenseSpringConfiguration` with the required values (and optional app metadata):

{% code title="LicenseSpringConfiguration initialization" %}

```java
LicenseSpringConfiguration configuration = LicenseSpringConfiguration.builder()
    .apiKey("api_key")
    .productCode("product_code")
    .sharedKey("shared-key")
    .appName("My application")
    .appVersion("1.0.0")
    .build();
```

{% endcode %}
{% endstep %}

{% step %}

### Initialize LicenseManager

Get the singleton instance and initialize it with the configuration and application context:

{% code title="LicenseManager initialization" %}

```java
LicenseManager manager = LicenseManager.getInstance();
manager.initialize(configuration, getApplicationContext());
```

{% endcode %}

After initialization, the SDK will attempt to read and validate any existing license; if present, it will be exposed via `LicenseManager.getCurrent()`.
{% endstep %}
{% endstepper %}


---

# 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.licensespring.com/sdks/android-sdk/sdk-initialization.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.
