"Cannot Change Dependencies of Dependency Configuration" gradle error in Unity IAP 4.12.0

I upgraded Unity IAP to 4.12.0 on Unity 2021.3.36f1.

The following error occurs during the Gradle build.

The following code is found around line 224 on build.gradle

We use ExternalDependencyManager and custom mainTemplate.gradle file.

How can I resolve this issue?

Same here after upgrading to 4.12.0, Unity 2022.3.27f1

We have released 4.12.1-pre.1 which should solve the Android build issue.

If this still doesn’t work and you are using EDM4U, we recommend making sure the following settings are active:

  • Project Settings > Player > ā€œCustom Main Gradle Templateā€

  • Android Resolver Settings

  • ā€œPatch gradleTemplate.propertiesā€

  • ā€œCopy and patch settingsTemplate.gradle from 2022.2ā€

2 Likes

Thank you for replying!
Here is another solution.

I’ve added the following code in ā€œOnPreprocessBuildā€

SessionState.SetBool("SelfDeclaredAndroidDependenciesDisabled:com.unity.purchasing", true);

And created UnityIAPDependencies.xml file.

It seems OK.

7 Likes

OMG you save my life. god bless you

1 Like
  1. Is it iap 4.12.1.pre1 version?
  2. Where is OnPreprocessBuild?
    and Where should I create the UnityIAPDependencies.xml file?

Just looking at the code, it seems difficult to know where and how to apply it. Can you please explain in detail?

1 Like

Sorry for the late confirmation, please refer to this if you are still in trouble

  1. In my case, it was 4.12.1-pre.1, but the solution ā€œyuki_gotoā€ posted will also work on 4.12.0. (4.12.1-pre.1 is a version with certain dependencies deleted, and the above solution includes explicit dependencies on all problematic packages in 4.12.0.)

2-1. For OnPreprocessBuild, see this post at https://docs.unity3d.com/ScriptReference/Build.IPreprocessBuildWithReport.OnPreprocessBuild.html . It uses UnityEditor. It means that this class should be in the Assets/Editor folder (or you will encounter errors when building)

2-2. The UnityIAPDependencies.xml file, in my case, was put in Assets/Editor with the cs file containing the class for which OnPreprocessBuild was declared. I’m not sure if that’s the right way to do it. In my case, it was better to keep files together for similar purposes if there was no specific reason.

4 Likes

Same error with Unity IAP 4.12.1-pre.3 during the Gradle build.

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

1 Like

Thank you so much. i love you

Thank you for your response. Is it correct for the user to manually modify the OnPreprocessBuild file and create the UnityIAPDependencies.xml file using the provided instructions?

It seems safer to wait until the Unity IAP team resolves the Android Gradle build issues and releases a new version of IAP before building my project.

Because my game is currently live, I’m more worried about causing build errors by manually modifying various files, which would prevent me from updating the game for my users.

And honestly, I’m not even sure if I’m supposed to modify those files myself. This is an issue with the in-app purchase system provided by Unity.

I know the Unity IAP team is working hard under tight deadlines, but I hope they can release a bug-free, perfect version by Google’s final deadline in November.

This has worked for me so far, but I hope to see Unity officially fix it.

WORKED!!! Didnt build with and then added the files and built perfectly!

Thank you for explaining in detail. Following these steps, the build worked perfectly. In-app purchases and Google login are also functioning well. I’m just worried because I fixed it as instructed without fully understanding the root cause. I’m also concerned about potential issues in the future even though it works fine now. Still, everything is working well. Thank you.

the above mentioned soultion if fine for unity 2020.3.38f1.
but its not working properly in 2021.3.28f1.

Using Unity 2021.3.38f1 and Unity IAP version 4.12.1-pre.4 I’m getting this error:

I was Using Unity 2022.3.25f1 After Updating the InApp Purchasing to 4.12 my build was not processing I Followed these steps and my build is processed

Request to unity to release Bug free Releases for at least LTS versions of Unity

Got the same gradle error after upgrading to Unity IAP (In App Purchasing) 4.12.2. Tried with Unity 2022.3.37f1 & 2021.3.40f1, but the error still shows up.

* 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.

I also ensured the following settings are correct:
In Project Settings:

  • Custom Main Gradle Template is enabled
  • Custom Gradle Properties Template is enabled

In EDM4U Android Resolver settings:

  • Path AndroidManifest.xml is enabled
  • Use Jetifier is enabled
  • Path mainTemplate.gradle is enabled
  • Path gradleTemplate.properties is enabled
  • Copy and patch settingsTemplate.gradle from 2022.2 is enabled

I tried exporting to Android project, and noticed these lines are the root cause. Looks like it could potentially cause infinite gradle sync loop, which gradle decided to throw error instead. Removing these lines and then put it in the main dependencies works. Hence, I believe this could be a bug from Unity IAP plugin.

// Dependencies for "com.unity.purchasing". This section is automatically generated.
afterEvaluate {
    dependencies {
        implementation 'com.android.billingclient:billing:6.2.1'
    }
}
// End of dependencies for "com.unity.purchasing".

Found the solution! Thank you @samzgamz for pointing out that ā€œRemove Property Tagā€ setting in Admob SDK has to be unchecked to make it work.

4 Likes

i am using 2020.3.40 unity and using 4.12.2 and using admob 8.7.0 but got this issue

  • 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

can you please tell
which of unity InApp Purchasing version are you using
and which of admob sdk are you using

This works for me! Tks