Documentation

​
​

Development

User Acquisition

Monetization

Industry

  1. Unity In-App Purchasing

Troubleshooting In-App Purchasing 5.4.0 Android builds on Unity 2022.3

Solve an Android build failure when you use In-App Purchasing 5.4.0 on Unity 2022.3 LTS.
Read time 4 minutes
Last updated 2 months ago

In-App Purchasing (IAP) 5.4.0 is designed for Unity 6. To use IAP 5.4.0 with Unity 2022.3 LTS on Android, you need to adjust some project settings.
This page explains why the build fails on Unity 2022.3, how to recognize the errors, and the steps to build successfully. The steps are verified against Unity 2022.3.62f2, but they apply to Unity 2022.3 LTS in general.
Note
For new projects, and to avoid this configuration entirely, use Unity 6, where IAP 5.4.0 builds without changes. If you're staying on Unity 2022.3 for now, you can use this page to adopt IAP 5.4.0 today, and then you can plan a move to Unity 6 at your own pace.

Symptoms

Depending on your build settings, IAP 5.4.0 on Unity 2022.3 can fail during the Android build with one or more of the following errors. If you get these errors, apply the steps in the Resolution section.
  • A manifest merge error such as
    uses-sdk:minSdkVersion 22 cannot be smaller than version 23 declared in library [com.android.billingclient:billing:9.0.0]
    .
  • An R8 error during the minify step, for example
    R8: java.lang.NullPointerException
    with an origin of
    androidx.core
    (
    core-1.15.0-runtime.jar
    ).
  • A duplicate class failure from
    checkDebugDuplicateClasses
    or
    checkReleaseDuplicateClasses
    , involving either
    androidx.core
    /
    android.support.v4
    or
    kotlin-stdlib
    (for example
    Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt
    ).

Cause

IAP 5.4.0 depends on Google Play Billing Library 9.0.0, which in turn requires
androidx.core
1.15.0.
androidx.core
1.15.0 is built for Android Gradle Plugin 8 and later.
Unity 2022.3 LTS builds with Android Gradle Plugin 7.4.2 (Gradle 7.5.1). This older plugin and its R8 compiler can't process
androidx.core
1.15.0, which produces the R8 and duplicate class errors above. Google Play Billing Library 9.0.0 also requires a minimum Android API level of 23, which is higher than the Unity default.
The following steps keep IAP 5.4.0 and Google Play Billing Library 9.0.0 in place, and align the affected Android dependencies with versions the Unity 2022.3 toolchain can build.

Resolution

To build IAP 5.4.0 on Unity 2022.3, follow these steps:
  1. Set the minimum API level to 23 or higher
  2. Pin the Android dependencies with a custom Gradle template
  3. Build your project

Set the minimum API level to 23 or higher

  1. Go to Edit > Project Settings > Player > Android > Other Settings.
  2. Set Minimum API Level to Android 6.0 'Marshmallow' (API level 23) or higher.
This satisfies the minimum API level required by Google Play Billing Library 9.0.0.

Pin the Android dependencies with a custom Gradle template

  1. Go to Edit > Project Settings > Player > Android > Publishing Settings.
  2. Under Build, enable Custom Base Gradle Template. Unity creates the file at
    Assets/Plugins/Android/baseProjectTemplate.gradle
    .
  3. Open
    baseProjectTemplate.gradle
    and add the following block at the end of the file:
allprojects { configurations.all { resolutionStrategy { // androidx.core 1.15.0 requires Android Gradle Plugin 8; // pin to the last release compatible with the Unity 2022.3 toolchain. force 'androidx.core:core:1.13.1' force 'androidx.core:core-ktx:1.13.1' // Align the Kotlin standard library to a single version to avoid duplicate classes. force 'org.jetbrains.kotlin:kotlin-stdlib:1.8.22' force 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.22' force 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22' } }}
Keep Custom Base Gradle Template enabled. The dependency versions only apply while Unity builds with this template.

Build your project

Build for Android as usual (File > Build Settings > Android > Build). The build now completes past the minify and duplicate class checks.

Move to Unity 6

The steps above are a supported way to build IAP 5.4.0 on Unity 2022.3, but they hold two Android dependencies below the versions the package targets. Unity 6 ships Android Gradle Plugin 8 and later, so IAP 5.4.0 builds without any of these changes. If you're planning an engine upgrade, moving to Unity 6 removes the need for this configuration.

Copyright © 2026 Unity Technologies
LegalPrivacy PolicyCookiesDocumentation Terms of UseDo Not Sell or Share My Personal InformationYour Privacy Choices (Cookie Settings)

"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S and elsewhere (more info here). Other names or brands are trademarks of their respective owners.

Some pages are machine-translated for convenience, and may contain inaccuracies. In the event of conflicting information, the English version is authoritative.

  • On this page
    • Symptoms

    • Cause

    • Resolution

      • Set the minimum API level to 23 or higher

      • Pin the Android dependencies with a custom Gradle template

      • Build your project

    • Move to Unity 6

  • Additional resources
  • What's new in IAP v5
  • Upgrade from IAP v4 to v5
  • Set up IAP for platform-native stores

Report a problem with this page