Search Unity

Question Android Studio - Failed to resolve the dependencies

Discussion in 'Unity Mediation' started by unicorntechgroup, Jan 23, 2022.

  1. unicorntechgroup

    unicorntechgroup

    Joined:
    Feb 11, 2021
    Posts:
    7
    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

    upload_2022-1-24_1-23-39.png

    Thanks
     
  2. jcGrenier

    jcGrenier

    Unity Technologies

    Joined:
    Feb 23, 2021
    Posts:
    145
    Hi @unicorntechgroup ,
    Can you make sure you did the following steps?
    upload_2022-1-24_12-31-19.png
    it seems like your gradle does not know where to fetch the dependencies.
     
  3. unicorntechgroup

    unicorntechgroup

    Joined:
    Feb 11, 2021
    Posts:
    7
    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
     
  4. unicorntechgroup

    unicorntechgroup

    Joined:
    Feb 11, 2021
    Posts:
    7
    Here's a screenshot of my build gradle file
     

    Attached Files:

  5. wisesm1

    wisesm1

    Unity Technologies

    Joined:
    Sep 15, 2017
    Posts:
    9
    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:
    gradle_screenshot.png
     
  6. unicorntechgroup

    unicorntechgroup

    Joined:
    Feb 11, 2021
    Posts:
    7
    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

    ssnew.png


    Here's my gradle code
    ssnew1.png
    + 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"
     
  7. wisesm1

    wisesm1

    Unity Technologies

    Joined:
    Sep 15, 2017
    Posts:
    9
    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/use...t.html#sub:centralized-repository-declaration

    Introduced in gradle 6.8 release in Jan of 2021: https://docs.gradle.org/6.8/release-notes.html

    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.
     
  8. unicorntechgroup

    unicorntechgroup

    Joined:
    Feb 11, 2021
    Posts:
    7
    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.
     
  9. unicorntechgroup

    unicorntechgroup

    Joined:
    Feb 11, 2021
    Posts:
    7
    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 app.png

    build.gradle (Module)
    build gradle module.png

    settings.gradle
    settings gradle.png
     
  10. wisesm1

    wisesm1

    Unity Technologies

    Joined:
    Sep 15, 2017
    Posts:
    9
    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: https://github.com/protocolbuffers/protobuf/tree/master/java
    Here is a stack overflow post with a similar problem: https://stackoverflow.com/questions/57019439/duplicate-class-in-protobuf-lite-and-protobuf-java

    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.
     
  11. wisesm1

    wisesm1

    Unity Technologies

    Joined:
    Sep 15, 2017
    Posts:
    9
    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.
     
  12. unicorntechgroup

    unicorntechgroup

    Joined:
    Feb 11, 2021
    Posts:
    7
    Thanks for updating, I will make this Thread as Solved once I implement the SDK 0.4.0 and test it.