---
title: Android SDK configuration
description: >-
  The following configuration will require workspace key. You can get your
  workspace key in the Access Keys section of the Survicate panel.
source_url:
  html: 'https://developers.survicate.com/mobile-sdk/android/configuration/'
  md: 'https://developers.survicate.com/mobile-sdk/android/configuration.md'
---
# Android SDK configuration

The following configuration will require workspace key. You can get your workspace key in the [Access Keys section](https://panel.survicate.com/o/0/w/0/settings/access-keys) of the Survicate panel.

1. Configure your *workspace key* in `AndroidManifest.xml` file.
   Create meta-data: `com.survicate.surveys.workspaceKey`.

```xml title="AndroidManifest.xml"
<application
    android:name=".MyApp"
>
    <!-- ... -->
    <meta-data android:name="com.survicate.surveys.workspaceKey" android:value="YOUR_WORKSPACE_KEY"/>
</application>
```

As an alternative to the main way of specifying the Workspace Key, you can also use the `setWorkspaceKey()` method.

Important:
* Using `setWorkspaceKey()` method overrides the Workspace Key defined in the configuration.
* `setWorkspaceKey()` method must be used before `init()` method is called.

```kotlin title="Kotlin"
Survicate.setWorkspaceKey("your_workspace_key")
```

```java title="Java"
Survicate.setWorkspaceKey("your_workspace_key");
```

2. Initialize the SDK in your application class using `init()` method.
   If your project doesn't have a custom application class yet, you'll need to create one.
   Make sure that your custom application class is defined in `AndroidManifest.xml`.

```kotlin title="Kotlin"
import android.app.Application
import com.survicate.surveys.Survicate

class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()
        Survicate.init(this)
    }
}
```

```java title="Java"
import android.app.Application;
import com.survicate.surveys.Survicate;

public class MyApp extends Application {
  @Override public void onCreate() {
    super.onCreate();
    Survicate.init(this);
  }
}
```

**Enable debug messaging**

To enable debug logcat messages from the SDK, pass `true` as the second parameter to the `init()` method:

```kotlin title="Kotlin"
Survicate.init(this, true)
```

```java title="Java"
Survicate.init(this, true);
```

This is useful for development and debugging purposes. Make sure to disable it in production builds.

## ProGuard / R8

The SDK provides built-in proguard rules, so you don't have to specify them manually.

**Included rules**
```text
-keep @com.squareup.moshi.JsonQualifier class *
-keepattributes InnerClasses,Signature,RuntimeVisible*Annotations,EnclosingMethod
-keep public class com.survicate.surveys.entities.** { *; }
-keep public class com.survicate.surveys.infrastructure.network.** { *; }
-keep public class com.survicate.surveys.infrastructure.serialization.** { *; }
-keepclassmembers public class com.survicate.surveys.traits.UserTrait {
  <init>(...);
  <fields>;
}
-keepclassmembers public class com.survicate.surveys.IntegrationPayload{
  <init>(...);
  <fields>;
}
```

_The proguard rules listed above were applicable only up to SDK version 6.4.3. Starting from version 7.0.0, the Survicate Android SDK no longer uses any custom proguard rules. However, the SDK depends on [Coil](https://coil-kt.github.io/coil/) and [Kotlinx Serialization](https://github.com/Kotlin/kotlinx.serialization) libraries, which apply some rules by default._
