[Android] Build fails after upgrading In App Purchasing from 4.11.0 to 4.12.0

My Unity game builds for Android fine with In App Purchasing 4.11.0 but Google is saying I have 56 days remaining to update to Google Play Billing Library 6.0.1 or later which means updating to 4.12.0. However when I do that, it says “Gradle build failed: See the Console for details.”

The first error is this:

I’m not sure where the build.gradle file is ? Next …

My initial reaction is WTF ?? Why does nothing ever work when I build for Android ??

First error - build.gradle, malformed.
Second error states:
C:\Development\Unity 5\Yatzy\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\build.gradle has dependency issue.

What Unity version are you using and could you attach build.gradle file from second error?

I have a similar issue although I’m getting …/Gradle\unityLibrary\build.gradle’ line: 105

  • Where:
    Build file ‘D:\Personal work archive\Unity Projects\Rythm based game\EndlessRunner\Endless Runner\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\build.gradle’ line: 105

  • What went wrong:
    A problem occurred configuring project ‘:unityLibrary’.

Cannot change dependencies of dependency configuration ‘:unityLibrary:implementation’ after it has been included in dependency resolution.

Unity Version 2021.3.2f1

Here’s my gradle file although I’ve converted it to .txt since it doesn’t allow me to post with gradle extension

9932772–1437576–build.txt (4.5 KB)

build.gradle.txt (5.5 KB)

I was using Unity 2022.3.24f1 but I just upgraded to the latest 2022.3.39f1 and get the same error.

I have the same issue. Unity 2022.3.31, just upgrading the IAP purchase package to the latest breaks the build with this warning followed by a long and truncated exception and I don’t have a custom build.gradle file either.

Google Play is requiring the apps to use newer versions of IAP and will take down the apps if not updated by Aug 31. So if you are helping us, please do it a bit faster.

I have the very latest version of External Dependency Manager and Jetlifier is enabled.

The Exception
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Note: Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':launcher:checkReleaseDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class a.a.a found in modules jetified-com.android.installreferrer.installreferrer-2.2-runtime (:com.android.installreferrer.installreferrer-2.2:) and jetified-installreferrer-2.2-runtime (com.android.installreferrer:installreferrer:2.2)
     Duplicate class android.support.customtabs.ICustomTabsCallback found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.ICustomTabsCallback$Default found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.ICustomTabsCallback$Stub found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.ICustomTabsCallback$Stub$Proxy found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.ICustomTabsService found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.ICustomTabsService$Default found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.ICustomTabsService$Stub found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.ICustomTabsService$Stub$Proxy found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.IPostMessageService found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.IPostMessageService$Default found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.IPostMessageService$Stub found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.IPostMessageService$Stub$Proxy found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.trusted.ITrustedWebActivityCallback found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.trusted.ITrustedWebActivityCallback$Default found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.trusted.ITrustedWebActivityCallback$Stub found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.trusted.ITrustedWebActivityCallback$Stub$Proxy found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.trusted.ITrustedWebActivityService found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.trusted.ITrustedWebActivityService$Default found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.trusted.ITrustedWebActivityService$Stub found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.customtabs.trusted.ITrustedWebActivityService$Stub$Proxy found in modules browser-1.4.0-runtime (androidx.browser:browser:1.4.0) and jetified-androidx.browser.browser-1.4.0-runtime (:androidx.browser.browser-1.4.0:)
     Duplicate class android.support.v4.app.RemoteActionCompatParcelizer found in modules core-1.7.0-runtime (androidx.core:core:1.7.0) and jetified-androidx.core.core-1.7.0-runtime (:androidx.core.core-1.7.0:)
     Duplicate class android.support.v4.graphics.drawable.IconCompatParcelizer found in modules core-1.7.0-runtime (androidx.core:core:1.7.0) and jetified-androidx.core.core-1.7.0-runtime (:androidx.core.core-1.7.0:)
     Duplicate class android.support.v4.media.MediaBrowserCompat found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$CallbackHandler found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$ConnectionCallback found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$ConnectionCallback$ConnectionCallbackInternal found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$ConnectionCallback$StubApi21 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$CustomActionCallback found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$CustomActionResultReceiver found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$ItemCallback found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$ItemCallback$StubApi23 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$ItemReceiver found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImpl found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$1 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$2 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$3 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$4 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$5 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$6 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$7 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi23 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi26 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$1 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$2 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$3 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$4 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$5 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$6 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$MediaServiceConnection found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$MediaServiceConnection$1 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$MediaServiceConnection$2 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserServiceCallbackImpl found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaItem found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaItem$1 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$MediaItem$Flags found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$SearchCallback found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$SearchResultReceiver found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$ServiceBinderWrapper found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$Subscription found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$SubscriptionCallback found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$SubscriptionCallback$StubApi21 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompat$SubscriptionCallback$StubApi26 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompatApi21 found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompatApi21$ConnectionCallback found in modules jetified-androidx.media.media-1.0.0-runtime (:androidx.media.media-1.0.0:) and media-1.0.0-runtime (androidx.media:media:1.0.0)
     Duplicate class android.support.v4.media.MediaBrowserCompatApi21$Conne<message truncated>

How can I fix the first error? I also encountered it. I am using the version 2023.2.19

I started a new project, downloaded and installed all packages from the previous project and copied and pasted everything from my old project’s asset folder and that somehow fixed the issue for me. Old project was 2021.3.2f1 and new was 2022.3.37f1. No idea what caused the issue or how it got fixed for me.

That didn’t work for me unfortunately.

I don’t know if this will help anyone, but desperate times call for desperate measures.
I removed Unity’s IAP package completely and instead installed VoxelBusters Cross Platform IAP plugin.

Nothing else worked. Deleting Resolved Android Libraries, deleting gradle and Unity package caches, upgrading and downgrading Unity.

Also, deleting the Android Libraries does work, meaning the build succeeds but your app will crash in runtime.

I hope this gets resolved soon by Unity.

Hi all,
The build issue is mostly probable to be related to your project itself due to dependencies set in your grade file
To help further we will require the dependency list with packages version and the editor info used
As a starter, I would recommend to update packages to latest, have your project in a clean environment (deleting the Library folder can also do the trick), try to force resolve with the Android resolver, recheck the mainTemplate.gradle file, then build

Hope this will help!

All cases might be different, and it can take some time to understand the issue itself
We are glad to help but again, this is project-specific

No it doesn’t help at all because we’ve tried all that.

This is the error I get:

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘C:\Development\Unity 5\Yatzy\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\build.gradle’ line: 103

  • What went wrong:
    A problem occurred configuring project ‘:unityLibrary’.

Cannot change dependencies of dependency configuration ‘:unityLibrary:implementation’ after it has been included in dependency resolution.

and this is the build.gradle file that Unity created:

build.gradle.txt (5.5 KB)

The error is at line 103:

98: apply from: 'GoogleMobileAdsPlugin.androidlib\\packaging_options.gradle'
99: apply from: 'GoogleMobileAdsPlugin.androidlib\\validate_dependencies.gradle'
100: // Dependencies for "com.unity.purchasing". This section is automatically generated.
101: afterEvaluate {
102:     dependencies {
103:         implementation 'com.android.billingclient:billing:6.2.1'
104:     }
105: }
106: // End of dependencies for "com.unity.purchasing".

I hope you can make sense of this 'cos I’m no expert with Android builds. I just expect it all to work!

I think you’re linking to a different type of problem. It’s not the same error as on this thread and suggests that Facebook SDK and Unity In App Purchasing SDKs don’t play well together. I’ve just removed the Facebook SDK from my project, forced resolve, checked the build.gradle file to make sure all the Facebook references were gone and I still got the same error so it doesn’t look like this issue has anything to do with Facebook SDK.

You are right, there is another case that doesn’t mention Facebook SDK. Make sure to vote it so that the IAP team prioritize it accordingly:

“A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable“ from your link isn’t the same error we’re getting. Our error is:

  • A problem occurred configuring project ‘:unityLibrary’.

Cannot change dependencies of dependency configuration ‘:unityLibrary:implementation’ after it has been included in dependency resolution.

Anybody found a solution for this ? I had many plugins in my project working fine with In App Purchasing 4.11.0

e.g

Firebase (Auth, Analytics, RemoteConfig, Database, Functions)
Applovin MAX Mediation with (Admob, Unity Ads, Iron Source, Vungle)

But just as i upgraded to 4.12.x i have started to get build errors.

Google Play is asking us to update our billing library, which we have to do.

Anyone has a solution for this ?

The following error occurred in my project.
A problem occurred configuring project ':unityLibrary'.

I added the following to android in mainTemplate.gradle and the build was successful.
namespace "com.unity3d.player.UnityPlayerActivity"

I didn’t know why this solved the problem, so I came to this discussion.
Is my problem the same as yours?
I’m sorry if I’m wrong.

Unfortunately that didn’t fix the build error in my project. I wasn’t really sure where to add your line. I already have this in my mainTemplate.gradle file:

// Android Resolver Exclusions Start
android {
	namespace "com.unity3d.player"
namespace "com.unity3d.player.UnityPlayerActivity"
  packagingOptions {
      exclude ('/lib/armeabi/*' + '*')
      exclude ('/lib/mips/*' + '*')
      exclude ('/lib/mips64/*' + '*')
      exclude ('/lib/x86/*' + '*')
      exclude ('/lib/x86_64/*' + '*')
  }
}

so I added it there without any success. I also tried adding it here to and this didn’t help

android {
    ndkPath "**NDKPATH**"
    namespace "com.unity3d.player.UnityPlayerActivity"
    compileSdkVersion **APIVERSION**
    buildToolsVersion '**BUILDTOOLS**'

Can you share your mainTemplate.gradle file so I can see exactly where to add the line ?

I was just trying your second way of writing it.
I thought it was the same error because the version of com.unity.purchasing was automatically updated from 4.11.0 to 4.12.0 and the error message was similar, but I’m sorry I couldn’t be of any help.
The version I’m using is 6000.0.11f1.