Error upgrading unity project from android Google Play Billing Library v3 to v4

I am originally using Unity 2021.1.22f1

I have made a cardboard vr app for android and I need to make an update to it. I am not using in app purchases or something similar, but I use the Play Asset Delivery package for unity in order to minimize the app size. I successfully built the app and it throws an error when I upload the app for internal testing and it will not proceed if this is not resolved.

We have detected that this app is using an unsupported version of Play Billing.
Please upgrade your Billing Library to version 4 or later to publish this app.

When I click the “learn more” button it redirects me to this link: Google Play Billing Library version deprecation  |  Google Play's billing system  |  Android Developers and the internal test button is greyed out.

It is saying that the Google Play Billing Library must be upgraded from version 3 to at least version 4.

Due to this forum thread Important update: Google Play Billing Library v5.1.0 I searched about the changelog in the unity versions Changelog | In App Purchasing | 4.4.1. In this changelog is written, that the “GooglePlay - Google Play Billing Library version 4.0.0” is added in IAP 4.4.0 and date 2022-07-11.

So I guessed that i had to upgrade the unity version. I downloaded Unity 2022.1.23f1 and built the same app with the current settings (Google Play Billing Library v3) and it was successfully built without errors.

I found a way to upgrade the library by downloading the unity package of Play Billing Library from this website Explore Google packages for Unity  |  Google for Developers even if it is saying version 3.2.4 . When I tried to build it a new error appeared:

Gradle Error: Colliding Attributes
The attribute
meta-data#com.google.android.play.billingclient.version@value=3.0.3
in :billing-4.0.0: collides with another value
(See the Console for details)

I tried updating the Play Asset Delivery package but there was no change in the error message.

I found this in my search for the bug Integration with Unity IAP 2.2.5 · Issue #37 · RevenueCat/purchases-unity · GitHub. In this link, the Google Play Billing Library is having a conflict with the same library inside the IAP and it suggest a code to bypass the IAP library. and tried it, but to no avail.

After trying this I guess that there is a Google Play Billing Library v3 in the Play Asset Delivery package that probably is needed to be bypassed.

If the Play Billing Library can be completely skipped it would be the best, because there is no billing function planned to be implemented in the app, but I mainly want to be able to upload it to the playstore.

This is the mainTemplate.gradle file:

// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN

// Android Resolver Repos Start
([rootProject] + (rootProject.subprojects as List)).each { project ->
   project.repositories {
       def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
       maven {
           url "https://maven.google.com"
       }
       maven {
           url "https://android-sdk.is.com/" // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:9
       }
       maven {
           url "https://maven.google.com/" // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:17, Assets/IronSource/Editor/IronSourceSDKDependencies.xml:25
       }
       mavenLocal()
       mavenCentral()
   }
}
// Android Resolver Repos End
apply plugin: 'com.android.library'
**APPLY_PLUGINS**

dependencies {
   implementation fileTree(dir: 'libs', include: ['*.jar'])
   implementation 'com.android.support:appcompat-v7:28.0.0'
   implementation 'com.android.support:support-v4:28.0.0'
   implementation 'com.google.android.gms:play-services-vision:15.0.2'
   implementation 'com.google.protobuf:protobuf-lite:3.0.0'
// Android Resolver Dependencies Start
   implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0' // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:17
   implementation 'com.google.android.gms:play-services-basement:17.2.1' // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:25
   implementation 'com.google.android.play:asset-delivery:2.0.0' // Assets/GooglePlayPlugins/com.google.play.assetdelivery/Editor/Dependencies.xml:3
   implementation 'com.google.android.play:core-common:2.0.0' // Assets/GooglePlayPlugins/com.google.play.core/Editor/Dependencies.xml:3
   implementation 'com.ironsource.sdk:mediationsdk:7.2.5' // Assets/IronSource/Editor/IronSourceSDKDependencies.xml:9
// Android Resolver Dependencies End
**DEPS**}

// Android Resolver Exclusions Start
android {
  packagingOptions {
     exclude ('/lib/armeabi/*' + '*')
     exclude ('/lib/armeabi-v7a/*' + '*')
     exclude ('/lib/mips/*' + '*')
     exclude ('/lib/mips64/*' + '*')
     exclude ('/lib/x86/*' + '*')
     exclude ('/lib/x86_64/*' + '*')
  }
}
// Android Resolver Exclusions End
android {
   aaptOptions {
       noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
       ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
   }

   compileSdkVersion **APIVERSION**
   buildToolsVersion '**BUILDTOOLS**'

   compileOptions {
       sourceCompatibility JavaVersion.VERSION_1_8
       targetCompatibility JavaVersion.VERSION_1_8
   }

   defaultConfig {
       minSdkVersion **MINSDKVERSION**
       targetSdkVersion **TARGETSDKVERSION**
       ndk {
           abiFilters **ABIFILTERS**
       }
       versionCode **VERSIONCODE**
       versionName '**VERSIONNAME**'
       consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
   }

   lintOptions {
       abortOnError false
   }
**PACKAGING_OPTIONS**
}**REPOSITORIES**
**IL_CPP_BUILD_SETUP**
**SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**

Hello,
This seems to be an issue related to Play Asset Delivery, but I’ve found this that might solve your issue:
https://github.com/google/play-unity-plugins/issues/187#issuecomment-1256839097

By downloading it from their archive, the Google Billing Library seems to not be included:

Thank you for the fast reply. I am trying to implement it now, but it seems to have billing library conflicts, I suspect from the previous version. I will try to clean it up and reply afterwards.

I am trying to implement the play asset delivery from the archive. So I first tried to replace the package with simple drag and drop. Then after it threw errors I reverted and deleted the previous package and then installed the new one. Still errors. Then I tried disabling/enabling R8 but still no use. I also deleted the Library which broke some other things on it’s regeneration and I reverted and deleted the ‘Library/Bee/Android’ folder and let it regenerate. Still the same errors.
BuildToAllPlatforms is a script I made that builds the project for different platforms. In it I raise the bundle version, pass the scenes I want it to build and I pass it in one variable to a custom function in AppBundlePublisher.cs . This function is a copy of the Build() function in the same script with the exception of having a variable. I made this in order to make things easier but I do not think this modification is at fault here. In the second and third errors I see some overlaps in the schemas and I thought that there are some files holding old information, but I do not know where to start.
These errors are these:

> Configure project :launcher
WARNING: The option setting ‘android.enableR8=true’ is deprecated.
It will be removed in version 5.0 of the Android Gradle plugin.
You will no longer be able to disable R8
> Task :launcher:preBuild UP-TO-DATE
> Task :unityLibrary:preBuild UP-TO-DATE
> Task :launcher:preReleaseBuild UP-TO-DATE
> Task :unityLibrary:preReleaseBuild UP-TO-DATE
> Task :launcher:generateReleaseResValues UP-TO-DATE
> Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
> Task :launcher:compileReleaseRenderscript NO-SOURCE
> Task :launcher:generateReleaseResources UP-TO-DATE
> Task :unityLibrary:generateReleaseResValues UP-TO-DATE
> Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
> Task :unityLibrary:generateReleaseResources UP-TO-DATE
> Task :unityLibrary:packageReleaseResources UP-TO-DATE
> Task :launcher:createReleaseCompatibleScreenManifests
> Task :unityLibrary:extractDeepLinksRelease UP-TO-DATE
> Task :unityLibrary:compileReleaseLibraryResources
> Task :unityLibrary:processReleaseManifest
> Task :unityLibrary:generateReleaseBuildConfig
> Task :unityLibrary:compileReleaseAidl NO-SOURCE
> Task :unityLibrary:javaPreCompileRelease
> Task :unityLibrary:mergeReleaseShaders
> Task :unityLibrary:compileReleaseShaders NO-SOURCE
> Task :unityLibrary:generateReleaseAssets UP-TO-DATE
> Task :launcher:extractDeepLinksRelease UP-TO-DATE
> Task :launcher:processReleaseManifest
> Task :launcher:checkReleaseDuplicateClasses FAILED
> Task :launcher:mergeReleaseResources
> Task :unityLibrary:packageReleaseAssets
> Task :unityLibrary:parseReleaseLocalResources
16 actionable tasks: 11 executed, 5 up-to-date
UnityEditor.BuildPipeline:BuildPlayer (UnityEditor.BuildPlayerOptions)
Google.Android.AppBundle.Editor.Internal.BuildTools.AndroidBuilder:Build (UnityEditor.BuildPlayerOptions) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/BuildTools/AndroidBuilder.cs:178)
Google.Android.AppBundle.Editor.Internal.BuildTools.AppBundleBuilder:BuildAndroidPlayer (UnityEditor.BuildPlayerOptions) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/BuildTools/AppBundleBuilder.cs:179)
Google.Android.AppBundle.Editor.Internal.AppBundlePublisher:Build (Google.Android.AppBundle.Editor.Internal.BuildTools.AppBundleBuilder,Google.Android.AppBundle.Editor.Internal.AppBundlePublisher/AppBundleBuildSettings) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/AppBundlePublisher.cs:199)
Google.Android.AppBundle.Editor.Internal.AppBundlePublisher:CustomBuild (string) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/AppBundlePublisher.cs:163)
BuildToAllPlatforms:AndroidBuildProcess () (at Assets/Editor/BuildToAllPlatforms.cs:220)
BuildToAllPlatforms:BuildGameForAndroid () (at Assets/Editor/BuildToAllPlatforms.cs:66)

Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: unexpected element (uri:“”, local:“base-extension”). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ‘:launcher:checkReleaseDuplicateClasses’.
> 1 exception was raised by workers:
java.lang.RuntimeException: Duplicate class com.google.android.gms.common.api.internal.zza found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.api.internal.zzb found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.api.internal.zzc found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.api.internal.zzd found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.api.zza found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.api.zzb found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzb found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzc found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzd found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzf found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzg found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzk found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzl found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzm found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzn found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.zza found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)

Go to the documentation to learn how to Fix dependency resolution errors.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 6s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
UnityEditor.BuildPipeline:BuildPlayer (UnityEditor.BuildPlayerOptions)
Google.Android.AppBundle.Editor.Internal.BuildTools.AndroidBuilder:Build (UnityEditor.BuildPlayerOptions) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/BuildTools/AndroidBuilder.cs:178)
Google.Android.AppBundle.Editor.Internal.BuildTools.AppBundleBuilder:BuildAndroidPlayer (UnityEditor.BuildPlayerOptions) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/BuildTools/AppBundleBuilder.cs:179)
Google.Android.AppBundle.Editor.Internal.AppBundlePublisher:Build (Google.Android.AppBundle.Editor.Internal.BuildTools.AppBundleBuilder,Google.Android.AppBundle.Editor.Internal.AppBundlePublisher/AppBundleBuildSettings) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/AppBundlePublisher.cs:199)
Google.Android.AppBundle.Editor.Internal.AppBundlePublisher:CustomBuild (string) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/AppBundlePublisher.cs:163)
BuildToAllPlatforms:AndroidBuildProcess () (at Assets/Editor/BuildToAllPlatforms.cs:220)
BuildToAllPlatforms:BuildGameForAndroid () (at Assets/Editor/BuildToAllPlatforms.cs:66)

CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Hub\Editor\2022.1.23f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath “C:\Program Files\Unity\Hub\Editor\2022.1.23f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “bundleRelease”
stderr[
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: unexpected element (uri:“”, local:“base-extension”). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ‘:launcher:checkReleaseDuplicateClasses’.
> 1 exception was raised by workers:
java.lang.RuntimeException: Duplicate class com.google.android.gms.common.api.internal.zza found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.api.internal.zzb found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.api.internal.zzc found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.api.internal.zzd found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.api.zza found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.api.zzb found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzb found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzc found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzd found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzf found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzg found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzk found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzl found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzm found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.internal.zzn found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)
Duplicate class com.google.android.gms.common.zza found in modules jetified-play-services-base-15.0.1-runtime.jar (com.google.android.gms:play-services-base:15.0.1) and jetified-play-services-basement-16.0.1-runtime.jar (com.google.android.gms:play-services-basement:16.0.1)

Go to the documentation to learn how to Fix dependency resolution errors.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 6s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
]
stdout[
> Configure project :launcher
WARNING: The option setting ‘android.enableR8=true’ is deprecated.
It will be removed in version 5.0 of the Android Gradle plugin.
You will no longer be able to disable R8
> Task :launcher:preBuild UP-TO-DATE
> Task :unityLibrary:preBuild UP-TO-DATE
> Task :launcher:preReleaseBuild UP-TO-DATE
> Task :unityLibrary:preReleaseBuild UP-TO-DATE
> Task :launcher:generateReleaseResValues UP-TO-DATE
> Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
> Task :launcher:compileReleaseRenderscript NO-SOURCE
> Task :launcher:generateReleaseResources UP-TO-DATE
> Task :unityLibrary:generateReleaseResValues UP-TO-DATE
> Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
> Task :unityLibrary:generateReleaseResources UP-TO-DATE
> Task :unityLibrary:packageReleaseResources UP-TO-DATE
> Task :launcher:createReleaseCompatibleScreenManifests
> Task :unityLibrary:extractDeepLinksRelease UP-TO-DATE
> Task :unityLibrary:compileReleaseLibraryResources
> Task :unityLibrary:processReleaseManifest
> Task :unityLibrary:generateReleaseBuildConfig
> Task :unityLibrary:compileReleaseAidl NO-SOURCE
> Task :unityLibrary:javaPreCompileRelease
> Task :unityLibrary:mergeReleaseShaders
> Task :unityLibrary:compileReleaseShaders NO-SOURCE
> Task :unityLibrary:generateReleaseAssets UP-TO-DATE
> Task :launcher:extractDeepLinksRelease UP-TO-DATE
> Task :launcher:processReleaseManifest
> Task :launcher:checkReleaseDuplicateClasses FAILED
> Task :launcher:mergeReleaseResources
> Task :unityLibrary:packageReleaseAssets
> Task :unityLibrary:parseReleaseLocalResources
16 actionable tasks: 11 executed, 5 up-to-date
]
exit code: 1

Build error: Build failed with 4 error(s)
UnityEngine.Debug:LogErrorFormat (string,object[ ])
Google.Android.AppBundle.Editor.Internal.BuildTools.BuildToolLogger:smile:isplayErrorDialog (string) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/BuildTools/BuildToolLogger.cs:95)
Google.Android.AppBundle.Editor.Internal.BuildTools.AndroidBuilder:Build (UnityEditor.BuildPlayerOptions) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/BuildTools/AndroidBuilder.cs:205)
Google.Android.AppBundle.Editor.Internal.BuildTools.AppBundleBuilder:BuildAndroidPlayer (UnityEditor.BuildPlayerOptions) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/BuildTools/AppBundleBuilder.cs:179)
Google.Android.AppBundle.Editor.Internal.AppBundlePublisher:Build (Google.Android.AppBundle.Editor.Internal.BuildTools.AppBundleBuilder,Google.Android.AppBundle.Editor.Internal.AppBundlePublisher/AppBundleBuildSettings) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/AppBundlePublisher.cs:199)
Google.Android.AppBundle.Editor.Internal.AppBundlePublisher:CustomBuild (string) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/AppBundlePublisher.cs:163)
BuildToAllPlatforms:AndroidBuildProcess () (at Assets/Editor/BuildToAllPlatforms.cs:220)
BuildToAllPlatforms:BuildGameForAndroid () (at Assets/Editor/BuildToAllPlatforms.cs:66)

Hi,
It seems that you have android dependencies conflicts between com.google.android.gms:play-services-base:15.0.1 and com.google.android.gms:play-services-basement:16.0.1.

Try to run Assets/External Dependency Manager/Android Resolver/Force Resolve.

If your project uses custom gradle main template, you can see where the dependency come from in the comments.

I found an incompatibility with unity 2022 so I went back to Unity 2021.1.22f1 to properly test, either way in order to test if the package does not have the billing library I do not need unity 2022. I resolved the rest and ran Assets/External Dependency Manager/Android Resolver/Force Resolve, but it had no result. I am showing the new first error message, because the other remained the same. The only difference is the underlined task:

> Configure project :launcher
WARNING: The option setting ‘android.enableR8=false’ is deprecated.
It will be removed in version 5.0 of the Android Gradle plugin.
You will no longer be able to disable R8
> Task :launcher:preBuild UP-TO-DATE
> Task :unityLibrary:preBuild UP-TO-DATE
> Task :launcher:preReleaseBuild UP-TO-DATE
> Task :unityLibrary:preReleaseBuild UP-TO-DATE
> Task :launcher:generateReleaseResValues UP-TO-DATE
> Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
> Task :launcher:compileReleaseRenderscript NO-SOURCE
> Task :launcher:generateReleaseResources UP-TO-DATE
> Task :unityLibrary:generateReleaseResValues UP-TO-DATE
> Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
> Task :unityLibrary:generateReleaseResources UP-TO-DATE
> Task :unityLibrary:packageReleaseResources UP-TO-DATE
> Task :launcher:createReleaseCompatibleScreenManifests
> Task :unityLibrary:extractDeepLinksRelease UP-TO-DATE
> Task :unityLibrary:compileReleaseLibraryResources UP-TO-DATE
> Task :unityLibrary:processReleaseManifest
> Task :unityLibrary:generateReleaseBuildConfig
> Task :unityLibrary:compileReleaseAidl NO-SOURCE
> Task :unityLibrary:parseReleaseLocalResources UP-TO-DATE
> Task :unityLibrary:javaPreCompileRelease
> Task :unityLibrary:mergeReleaseShaders
> Task :unityLibrary:compileReleaseShaders NO-SOURCE
> Task :unityLibrary:generateReleaseAssets UP-TO-DATE
> Task :launcher:extractDeepLinksRelease UP-TO-DATE
> Task :launcher:processReleaseManifest
> Task :launcher:checkReleaseDuplicateClasses FAILED
> Task :launcher:mergeReleaseResources
> Task :unityLibrary:packageReleaseAssets
> Task :unityLibrary:generateReleaseRFile
17 actionable tasks: 10 executed, 7 up-to-date
UnityEditor.BuildPipeline:BuildPlayer (UnityEditor.BuildPlayerOptions)
Google.Android.AppBundle.Editor.Internal.BuildTools.AndroidBuilder:Build (UnityEditor.BuildPlayerOptions) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/BuildTools/AndroidBuilder.cs:178)
Google.Android.AppBundle.Editor.Internal.BuildTools.AppBundleBuilder:BuildAndroidPlayer (UnityEditor.BuildPlayerOptions) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/BuildTools/AppBundleBuilder.cs:179)
Google.Android.AppBundle.Editor.Internal.AppBundlePublisher:Build (Google.Android.AppBundle.Editor.Internal.BuildTools.AppBundleBuilder,Google.Android.AppBundle.Editor.Internal.AppBundlePublisher/AppBundleBuildSettings) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/AppBundlePublisher.cs:199)
Google.Android.AppBundle.Editor.Internal.AppBundlePublisher:CustomBuild (string) (at Assets/GooglePlayPlugins/com.google.android.appbundle/Editor/Scripts/Internal/AppBundlePublisher.cs:163)
BuildToAllPlatforms:AndroidBuildProcess () (at Assets/Editor/BuildToAllPlatforms.cs:220)
BuildToAllPlatforms:BuildGameForAndroid () (at Assets/Editor/BuildToAllPlatforms.cs:66)

It seems that there is still a conflict between play-services-base:15.0.1 and play-services-basement:16.0.1.
You must check witch plugin is using them.
Normally you need to have the same version for both of them.

I managed to solve the issue. I had to experiment a little by exporting the project in an android studio project. I upgraded gradle, migrated to androidx and found the library responsible in the build.gradle from :unityLibrary and changed it from 15.0.1 to 16.0.1 and it still got the same error. When I put my mouse over the version it said that there is a newer version 20.1.3. So I replaced the previous version with this and it compiled successfully. When I build and signed from the android studio, it found problems on uploading regarding unity stuff (e.g. StreamingAssets files are compressed in APK when "Build App Bundle (Google Play)" option is used problem with capital letters), so it needed to be built from unity. Then I unchecked all the boxes from the custom files in Project Settings/Player/Build and it cleaned something, but when checked them again it failed with the same error. So I am not sure if this step helped at all.

[SOLUTION]
But then I found the settings from the previously mentioned build.gradle in the mainTemplate.gradle and copied some of the changes from the android studio gradle file. To be precise I changed the dependencies in comments to the ones without:

dependencies {
...
//implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
//implementation 'com.android.support:support-v4:28.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
//implementation 'com.google.android.gms:play-services-vision:15.0.2'
implementation 'com.google.android.gms:play-services-vision:20.1.3'
...

I also put the Android Resolver Exclusions part and the rest of android options in the same android category like this:

android {
packagingOptions {
exclude ('/lib/armeabi/*' + '*')
exclude ('/lib/armeabi-v7a/*' + '*')
exclude ('/lib/mips/*' + '*')
exclude ('/lib/mips64/*' + '*')
exclude ('/lib/x86/*' + '*')
exclude ('/lib/x86_64/*' + '*')
}

aaptOptions {
noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}

compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
}

lintOptions {
abortOnError false
}
**PACKAGING_OPTIONS**
}

Then it built without errors.

Коллизия библиотеки выставления счетов | Справочный центр Appodea - work for me