Android Studio - Failed to resolve the dependencies

Hi,
I am trying to implement Unity Mediation in my Android Studio project but when I add the dependencies according to Unity documentation and start syncing, the Unity dependencies couldn’t sync which prevents me to initialize Unity Mediation SDK in my app.

I get this error while syncing gradle file

Thanks

Hi @unicorntechgroup ,
Can you make sure you did the following steps?


it seems like your gradle does not know where to fetch the dependencies.

Yes, but instead of allprojects I put it in the buildscript because there’s no allprojects in my app and it won’t let me to create one

Here’s a screenshot of my build gradle file

Hi @unicorntechgroup ,

Are you exporting an Android Studio from Unity or starting in Android Studio?

The screenshot for the build.gradle you provided is the root build.gradle. The buildscript section is used for gradle build tools. What you want to do is remove the jfrog definition from the buildscript section and create a new section called allprojects. The allprojects section is usually in an android studio project by default.

If starting directly from Android Studio, your project gradles should look roughly similar to this:

Thanks for your response,

My project is started in Android Studio but never found the “allprojects” section in my project. By manually adding the “allprojects” section it gives me this error and won’t let me sync

Here’s my gradle code

  • task clean(type: Delete) {delete rootProject.buildDir}

I tried removing “google()” and “mavenCentral()” from allprojects section then it gave me the same error for “maven” instead of “Google”

ah interesting. You mind sharing your settings.gradle?

You may be experiencing the following, which appears to be a new way to define and manage repositories as of gradle 6.8:
https://docs.gradle.org/current/userguide/dependency_management.html#sub:centralized-repository-declaration

Introduced in gradle 6.8 release in Jan of 2021: Gradle 6.8 Release Notes

Anecdotally, it seems the way to get around this (and use our documented method of repository management) is to remove the dependencyResolutionManagement from settings.gradle if you have it.

If you don’t want to change that^, you could follow along the instructions in the guides I pasted above. I will reach out to our documentation team to include a section on this new method of dependency management and get back to you ASAP.

Hey @wisesm1

Thanks for your solution, it worked (kind of). After moving my jfrog from “build.gradle” to “settings.gradle” the gradle synced and now I am able to import the UnityMediation class to my project but there’s a warning from Adcolony adapter

  • [Processor] Library ‘C:\Users\wasee.gradle\caches\modules-2\files-2.1\com.adcolony\sdk\4.6.5\818fbdf875a91af407c3faa9bfea044f05101168\sdk-4.6.5.aar’ contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway

Should I ignore this warning or it needs to be fixed? If yes, I would like to know how.

And by the way, I didn’t understand this part of your message, can you explain?

Again, Thanks a lot for your help.

Update on issue:
The gradle sync is now completely fine but when I run the app it gives me this error

  • Duplicate class com.google.protobuf.AbstractMessageLite found in modules jetified-protobuf-java-3.11.0 (com.google.protobuf:protobuf-java:3.11.0) and jetified-protobuf-javalite-3.17.2 (com.google.protobuf:protobuf-javalite:3.17.2)

I searched on the internet but couldn’t found a solution specific to my problem.
Here’s my Gradle Files

build.gradle (Project)

build.gradle (Module)

settings.gradle

Hi @unicorntechgroup ,

Glad you fixed the original issue! My suggestion was to remove the dependencyResolutionManagement block from settings.gradle, but it appears you can just as easily add your repositories to that as well.

Regarding the AdColony warning, I don’t think we’ve encountered it first-hand, but based on the message, it seems safe to ignore. Don’t take my word for that one. It may be better to see if others have encountered a similar warning in regards to AdColony.

Finally, regarding the protobuf library issue. This is a known issue that we will be addressing in our next release - 0.4.0 (which will be available within the next 3 weeks). I will update you in this thread when it is available.

The problem occurs when integrating the Unity Mediation SDK alongside the Firebase SDK - the transitive dependencies clash. The firebase sdk uses protobuf-javalite while the Mediation SDK uses protobuf-java-util. This becomes a problem because both libraries occupy com.google.protobuf package but have different library definitions: protobuf/java at main · protocolbuffers/protobuf · GitHub
Here is a stack overflow post with a similar problem: android - Duplicate class in protobuf lite and protobuf java - Stack Overflow

Let me know if this helps. In the meantime, you may be able to try the suggested fixes above. Worst case, you’ll be able to pull in our change in a few weeks in order to use both Firebase and Unity Mediation together.

Thanks for all of the feedback. We will get the update out as soon as possible.

hi @unicorntechgroup ,

We have made the Android release for Mediation SDK 0.4.0. Please feel free to pull in the latest changes and let me know how things go in regards to the protobuf library conflict.

Thanks for updating, I will make this Thread as Solved once I implement the SDK 0.4.0 and test it.