Skip to main content

Troubleshooting: Yandex SDK 7.14.1 Build Failure

Unity: 2021.x–2022.x | Appodeal SDK: 3.8.1

Issue Description

When adding Yandex SDK 7.14.1 in Unity 2021.x–2022.x, the Android build fails with D8 NullPointerException errors in AndroidX libraries due to version conflicts.

ERROR: D8 NullPointerException in appcompat-resources-1.7.0
ERROR: D8 NullPointerException in viewpager2-1.1.0
ERROR: D8 NullPointerException in appcompat-1.7.0

Solution

  1. In the Unity Editor, go to Assets/Plugins/Android and open mainTemplate.gradle.
  2. Inside the dependencies block, locate the Yandex SDK implementation and add exclusions, then declare compatible AndroidX versions:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

// Yandex SDK with AndroidX exclusions
implementation("com.yandex.android:mobileads:7.14.1") {
exclude group: 'androidx.appcompat', module: 'appcompat'
exclude group: 'androidx.viewpager2', module: 'viewpager2'
}

// Explicit compatible AndroidX versions
implementation "androidx.appcompat:appcompat:1.6.1"
implementation "androidx.viewpager2:viewpager2:1.0.0"

// ... other dependencies ...
}

Note: This change resolves the dexing errors by preventing Yandex SDK from pulling conflicting AndroidX library versions.