In IAP 4.12.0, we updated to Google Play Billing Library 6 which introduced a new dependency which required us to support it.
Some Android build issues have been happening following this change. We have compiled a list of steps to take if you are experiencing these issues in order to resolve them.
If this still doesn’t solve your problem, make a post with a list of dependencies and Unity editor version your project uses so we can reproduce the issue and help you solve it.
1- Using EDM4U (External Dependency Manager for Unity)
Verify if your project contains both EDM4U and MDR (Mobile Dependency Resolver). If it has both, remove MDR.
In the Project Settings, under Player → Publishing Settings for Android, make sure both Custom Main Gradle Template and Custom Gradle Properties Template are enabled.
Enable Patch mainTemplate.gradle and Copy and patch settingsTemplate.gradle from 2022.2 by going in Assets → External Dependency Manager → Android Resolver → Settings. If you don’t have this option, update your External Dependency Manager.
Force resolve the dependencies by going in Assets → External Dependency Manager → Android Resolver → Force Resolve
2- If your project has Google Mobile Ads and you are receiving this error:
Cannot change dependencies of dependency configuration ‘:unityLibrary:implementation’ after it has been included in dependency resolution.
Disable the Remove property tag from GMA Android SDK in Assets → Google Mobile Ads → Settings…
3- If you get the following error:
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
Go in Unity → Settings → External Tools, then disable and reenable the Android JDK, SDK and NDK.
@Yannick_D can the post process scene attribute in UnityPurchasingEditor be removed. It slows down builds and even testing in play mode. The function is being called anyway pre build. Every scene that is built, the code is deserializing BillingMode.json.
Hello,
I followed your guide but whenever i click “force resolve”, nothing added into my android plugins folder, instead a new folder name GeneratedLocalRepo is created under Assert folder
I tried those setting too, didnt work.
When i said “whenever i click “force resolve”, nothing added into my android plugins folder”, it mean like this:
This is the correct behaviour of newer version of EDM4U utilizing gradle file. Which only resolved into specific folder instead of plugins folder. It also resolve only some plugin and actually download all of its dependency only when building android project. It make our project cleaner and easier to commit into version control
You should fix your project to cope with this new behaviour if you have been rely on the old version system
What I am saying is it’s not related to EDM4U or the force resolve system. It’s about the dependency chain that messed up. Some of plugin may utilize same dependency but difference version, most likely one that has the same name in both androidx (newer one we should use) and legacy android (older that we should be avoided)
If you keen on investigation I would recommend trying to isolate each combination into 3 projects
iap 4.12.2 with firebase
GoogleMobileAds-v9.2.0 with iap 4.12.2
GoogleMobileAds-v9.2.0 with firebase
and see which of combination was actually a problem
I’m using the same packages, tried every solution on the internet on 3 unity versions and nothing worked.
i think there is a conflict between googlemobile ads library and firebase library, what versions worked for you and had a successfull build?
See the following discussion link. I was able to successfully build.
Do what @unity_psBBuKYnBt2RIg and @Alkanov had posted there. I did both of what they recommended. I had to delete the “Library” folder too (when restarting Unity, the Library folder will be rebuilt)