# Advanced setup & troubleshooting

### Multidex

If your project already uses several libraries, it is possible that by adding Didomi it reaches the limit of 64K references. In this case, it is necessary to enable multidex in your project: <https://developer.android.com/studio/build/multidex#groovy>

Example of error that can be caused by reaching the 64K limit:

```log
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':launcher:transformClassesWithDexBuilderForRelease'.
> com.android.build.api.transform.TransformException: java.lang.IllegalArgumentException: java.lang.IllegalArgumentException
```

{% tabs %}
{% tab title="build.gradle" %}

```
android {    
    defaultConfig {
        multiDexEnabled = true
    }
}
```

{% endtab %}
{% endtabs %}

### Languages

Didomi SDK supports the following [languages](https://developers.didomi.io/api-and-platform/introduction/translations#languages-supported)

Restricting the supported languages can reduce your application size.

{% tabs %}
{% tab title="build.gradle" %}

```groovy
android {
    defaultConfig {
        resourceConfigurations += ["en", "de", "fr", "es"]
    }
}
```

{% endtab %}

{% tab title="build.gradle.kts" %}

```kts
android {
    defaultConfig {
        resourceConfigurations += listOf("en", "de", "fr", "es")
    }
}
```

{% endtab %}
{% endtabs %}

Note that the Hebrew (`he`) language code is rewritten as `iw`, Indonesian (`id`) as `in`, and Yiddish (`yi`) as `ji` (see <https://developer.android.com/reference/java/util/Locale.html#legacy-language-codes> for more information).

For example: to add Hebrew language to the filtered list of language, you need to use `iw`.

{% hint style="warning" %}
**App bundles**

The Didomi SDK can be configured to restrict the languages it supports. If the user device language is not in the supported languages list, and app is distributed with Android App Bundles on the play store, it is possible that texts are removed from the downloaded app. In this case, all the texts will be displayed in english, except the custom texts.

To avoid this behavior, it is possible to either

* disable the splitting by language in App Bundle configuration.
* dynamically retrieve missing languages from Play Store through Install Manager, as described in Android developer doc: <https://developer.android.com/guide/playcore/feature-delivery/on-demand?hl=fr#lang_resources>
  {% endhint %}

#### Disable splitting by language

{% tabs %}
{% tab title="build.gradle" %}

```groovy
android {
    bundle {
        language {
            enableSplit = false
        }
    }
}
```

{% endtab %}
{% endtabs %}

#### Get missing language through Install Manager

{% tabs %}
{% tab title="SomeActivity.kt" %}

```kotlin
private lateinit var splitInstallManager: SplitInstallManager

override fun attachBaseContext(newBase: Context) {
    super.attachBaseContext(newBase)
    splitInstallManager = SplitInstallManagerFactory.create(newBase)
    SplitCompat.installActivity(this)
}

private fun onLanguageChanged(languageCode) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !splitInstallManager.installedLanguages.contains(languageCode)) {
        // Creates a request to download and install additional language resources.
        val request = SplitInstallRequest.newBuilder()
            // Uses the addLanguage() method to include needed language resources in the request.
            .addLanguage(Locale.forLanguageTag(languageCode))
            .build()

        // Submits the request to install the additional language resources.
        splitInstallManager
            .startInstall(request)
            .addOnFailureListener { (...) }
            .addOnCompleteListener { task ->
                if (task.isSuccessful) {
                    (...)
                    // Recreate activity so new language is available
                    recreate()
                }
            }
        return
    }
}
```

{% endtab %}
{% endtabs %}

### Zipline library

Didomi SDK uses the Zipline library (<https://github.com/cashapp/zipline>) to interpret local javascript code. Currently the Zipline dependency version is `1.18.0`.&#x20;

Since Didomi SDK version `2.36.0`, it is possible to exclude this library from the dependencies,. In this case the Didomi SDK will use a WebView instance to evaluate javascript.

You can exclude Zipline in the `build.gradle` file, when adding the Didomi dependency:

```
dependencies {
    implementation("io.didomi.sdk:android:X.XX.X") {
        exclude(group = "app.cash.zipline", module = "zipline")
    } 
}
```

At the moment, Didomi uses javascript for the following features:

* Didomi Consent String
* GPP
* GCM privacy signals

{% hint style="info" %}
Didomi SDK does not interpret remote javascript. All the javascript code is embedded with the SDK release.
{% endhint %}

#### Drawbacks

{% hint style="warning" %}
Excluding Zipline reduces the size of the Didomi SDK, however javascript operations will be less performant.
{% endhint %}

{% hint style="warning" %}
To support the Didomi javascript features, the device WebView version must be ≥ version 61.
{% endhint %}

{% hint style="warning" %}
Other uses of WebView from a different process in the same app can result in a crash. This can happen when a WebView is used in a Service or when using specific libraries.

More information about this crash and possible solutions can be found here: <https://stackoverflow.com/a/65423323>.
{% endhint %}
