IAP 4.12.0 - Solutions to Android build issues

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.

1 Like

This kind of problem easily solved with git dependency since EDM4U git was UPM compatible

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

2 Likes

In Step 1, it says remove MDR if you have both. But Step 2 and 3 both rely on using Mobile Dependency Resolver? Or am I missing something?

1 Like

Good catch, this should be External Dependency Manager.
I’ve updated it in my post.

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

when i try to build, i receive this error

Pls help, i stuck this for days

These new errors don’t seem related to the IAP package, but I found this here that might be able to help you:

In short, try setting the minSdkVersion to 24. If that doesn’t work, try to set minifyEnabled to true in debug.

If that doesn’t, could you share your dependencies so we can reproduce it?

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:

As u can see, no aar file was resolved, while it supposed to be like this

so i think the problem is the EDM4U not resolving any file.
I’m using:

  • unity 2022.3.42f1 with iap 4.12.2
  • firebase analystics + database 12.2.0
  • GoogleMobileAds-v9.2.0

I tried creating a blank project with the above packages and the same problem occur

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

I’m using:

  • unity 2022.3.42f1 with iap 4.12.2
  • firebase analystics + database 12.2.0
  • GoogleMobileAds-v9.2.0

I tried creating a blank project with the above packages and the same problem occur

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 finally managed to get the build done… i deleted iap package then add it back… now it working …

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)

https://discussions.unity.com/t/after-updating-iap-to-4-12-2-an-error-occurs-in-android-build/1502616/15

try this solution.

When we update some sdk and libraries try to follow each steps which is inside video.

2 Likes

This worked for me, I did what they say in the 2 videos.

1 Like