Skip to main content

Troubleshooting

Support for Unity IDE 2022.X

The Unity Editor is version locked to a particular iteration of Gradle. It has been established that earlier iterations of the Unity Editor utilise earlier versions of Gradle, which are incompatible with the latest version of Google Mobile Ads and other networks.

In order to facilitate the ongoing utilisation of Unity 2022, a potential solution is hereby presented.

Manually update Gradle

Prerequisites Before continuing, ensure you have the following:

  • Download and install the latest stable version of Android Studio.
  • Optional: For details on building for Android, see Java versions in Android builds

Steps:

  1. Set Target API Level 34

    From the main menu open Edit > Project Settings > Player > Android > Other Settings and set the Target API Level to API Level 34 or higher.

    Android API Level

  2. Export to Android Studio

    Modify the Android build settings by selecting File (or Unity Editor on MacOS) > Build Settings and check Export Project:

    Export Project

  3. Open Android Studio:

    This section contains steps performed within Android Studio. Update Gradle JDK configuration Open the Gradle settings from File (or Android Studio on MacOS) > Settings > Build > Execution > Deployment > Build Tools > Gradle. Locate the Gradle JDK drop-down and set the Gradle JDK to use JDK 17 or later.

    Gradle JDK

    If you don't have JDK 17 installed, select the Download JDK options from the Gradle JDK menu bar and download a compatible version.

  4. Update the project-level build.gradle

    Set Gradle tools version to 8.1.1 or newer.

    plugins {
    id 'com.android.application' version '8.1.1' apply false
    id 'com.android.library' version '8.1.1' apply false
    }

    task clean(type: Delete) {
    delete rootProject.buildDir
    }
  5. Update /gradle/gradle-wrapper.properties

    distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
  6. Run the Android Project

    From Android Studio, run gradle sync, and run the project.

If you've updated to Unity versions between 6000.0.1f1 - 6000.0.44f1, you might encounter the following crash at runtime:

Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.datastore.preferences.PreferenceDataStoreDelegateKt"

Cause

This issue occurs due to an incompatibility with the Android Gradle Plugin (AGP) version bundled with these Unity versions. The SDK relies on AndroidX DataStore components which require a newer version of AGP than what's included in these Unity versions.

Solution

You have two options to resolve this issue:

  • Update Unity Engine (Recommended)

    Update to Unity version 6000.0.45f1 or higher, which includes a compatible version of AGP

  • Manually Update Gradle (If updating Unity is not possible)

    Follow the steps in the Manually update Gradle section above to update the AGP version manually after exporting your project