googlesamples / unity-jar-resolver

Unity plugin which resolves Android & iOS dependencies and performs version management
Other
1.22k stars 339 forks source link

[Question] Unexpected dependency resolution #506

Closed dots-alberto-uriarte closed 2 years ago

dots-alberto-uriarte commented 2 years ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the question here:

Hi! Maybe I'm missing something or I don't understand something but it doesn't resolve the dependencies that I'm expecting. Using the artifact download script manually like this:

./gradlew -b "/Users/albertouriarte/Projects/unity-project/Temp/PlayServicesResolverGradle/PlayServicesResolver.scripts.download_artifacts.gradle" "-PPACKAGES_TO_COPY=com.google.android.gms:play-services-ads:20.5.0;com.google.ads.mediation:applovin:11.0.0.0;com.google.ads.mediation:facebook:6.8.0.0" "-PTARGET_DIR=/Users/albertouriarte/Projects/unity-project/Assets/Plugins/Android"

I got this results

ANDROID_HOME: /Applications/Unity/Hub/Editor/2019.4.35f1/PlaybackEngines/AndroidPlayer/SDK
MAVEN_REPOS: name=Google url=https://dl.google.com/dl/android/maven2/
MAVEN_REPOS: name=maven url=https://dl.google.com/dl/android/maven2/
MAVEN_REPOS: name=maven2 url=https://dl.google.com/dl/android/maven2/
MAVEN_REPOS: name=maven3 url=file:/Users/albertouriarte/Projects/unity-project/Library/PackageCache/com.google.firebase.analytics@7.2.0/Firebase/m2repository/
MAVEN_REPOS: name=maven4 url=file:/Users/albertouriarte/Projects/unity-project/Library/PackageCache/com.google.firebase.crashlytics@7.2.0/Firebase/m2repository/
MAVEN_REPOS: name=maven5 url=file:/Users/albertouriarte/Projects/unity-project/Library/PackageCache/com.google.firebase.messaging@7.2.0/Firebase/m2repository/
MAVEN_REPOS: name=maven6 url=file:/Users/albertouriarte/Projects/unity-project/Library/PackageCache/com.google.firebase.app@7.2.0/Firebase/m2repository/
MAVEN_REPOS: name=maven7 url=file:/Users/albertouriarte/Projects/unity-project/Assets/GooglePlayGames/Editor/m2repository/
MAVEN_REPOS: name=maven8 url=https://android-sdk.is.com/
MAVEN_REPOS: name=maven9 url=https://maven.google.com/
MAVEN_REPOS: name=maven10 url=https://repo.maven.apache.org/maven2/
MAVEN_REPOS: name=MavenLocal url=file:/Users/albertouriarte/.m2/repository/
MAVEN_REPOS: name=MavenRepo url=https://repo.maven.apache.org/maven2/
PACKAGES_TO_COPY: com.google.android.gms:play-services-ads:20.5.0
PACKAGES_TO_COPY: com.google.ads.mediation:applovin:11.0.0.0
PACKAGES_TO_COPY: com.google.ads.mediation:facebook:6.8.0.0
TARGET_DIR: /Users/albertouriarte/Projects/unity-project/Assets/Plugins/Android
Resolution attempt 1: packages [com.google.ads.mediation:applovin:11.0.0.0, com.google.android.gms:play-services-ads:20.5.0, com.google.ads.mediation:facebook:6.8.0.0]
com.google.android.gms:play-services-ads conflicting due to package(s):
- com.google.ads.mediation:applovin:11.0.0.0/com.google.android.gms:play-services-ads:20.5.0
- com.google.ads.mediation:facebook:6.8.0.0/com.google.android.gms:play-services-ads:20.4.0

.... [After some resolutions attempts]

Resolution attempt: 8, conflicts detected: false, updated packages: false
version locked packages: []
non-version locked packages: [com.google.android.gms:play-services-basement:17.6.0, com.google.ads.mediation:applovin:11+, com.google.android.gms:play-services-ads-identifier:17.0.0, androidx.browser:browser:1.0.0, com.google.android.gms:play-services-ads-base:20.6.0, com.google.android.gms:play-services-ads:+, com.google.android.gms:play-services-appset:16.0.0, androidx.core:core:1.0.0, com.google.android.gms:play-services-tasks:17.0.0, com.google.android.gms:play-services-ads-lite:20.6.0, com.google.ads.mediation:facebook:6+, androidx.collection:collection:1.0.0]

> Task :copyPackages
Copied artifacts:
androidx.annotation.annotation-1.3.0.jar
androidx.annotation.annotation-experimental-1.1.0.aar
androidx.arch.core.core-common-2.1.0.jar
androidx.arch.core.core-runtime-2.1.0.aar
androidx.asynclayoutinflater.asynclayoutinflater-1.0.0.aar
androidx.browser.browser-1.0.0.aar
androidx.collection.collection-1.0.0.jar
androidx.coordinatorlayout.coordinatorlayout-1.0.0.aar
androidx.core.core-1.6.0.aar
androidx.core.core-1.6.0.aar
androidx.cursoradapter.cursoradapter-1.0.0.aar
androidx.customview.customview-1.0.0.aar
androidx.documentfile.documentfile-1.0.0.aar
androidx.drawerlayout.drawerlayout-1.0.0.aar
androidx.fragment.fragment-1.0.0.aar
androidx.interpolator.interpolator-1.0.0.aar
androidx.legacy.legacy-support-core-ui-1.0.0.aar
androidx.legacy.legacy-support-core-utils-1.0.0.aar
androidx.lifecycle.lifecycle-common-2.1.0.jar
androidx.lifecycle.lifecycle-livedata-2.1.0.aar
androidx.lifecycle.lifecycle-livedata-core-2.1.0.aar
androidx.lifecycle.lifecycle-runtime-2.1.0.aar
androidx.lifecycle.lifecycle-service-2.1.0.aar
androidx.lifecycle.lifecycle-viewmodel-2.0.0.aar
androidx.loader.loader-1.0.0.aar
androidx.localbroadcastmanager.localbroadcastmanager-1.0.0.aar
androidx.print.print-1.0.0.aar
androidx.room.room-common-2.2.5.jar
androidx.room.room-runtime-2.2.5.aar
androidx.slidingpanelayout.slidingpanelayout-1.0.0.aar
androidx.sqlite.sqlite-2.1.0.aar
androidx.sqlite.sqlite-framework-2.1.0.aar
androidx.startup.startup-runtime-1.0.0.aar
androidx.swiperefreshlayout.swiperefreshlayout-1.0.0.aar
androidx.tracing.tracing-1.0.0.aar
androidx.versionedparcelable.versionedparcelable-1.1.1.aar
androidx.viewpager.viewpager-1.0.0.aar
androidx.work.work-runtime-2.7.0.aar
com.applovin.applovin-sdk-11.2.1.aar
com.facebook.android.audience-network-sdk-6.8.0.aar
com.google.ads.mediation.applovin-11.2.1.0.aar
com.google.ads.mediation.facebook-6.8.0.0.aar
com.google.android.gms.play-services-ads-20.6.0.aar
com.google.android.gms.play-services-ads-base-20.6.0.aar
com.google.android.gms.play-services-ads-identifier-17.1.0.aar
com.google.android.gms.play-services-ads-lite-20.6.0.aar
com.google.android.gms.play-services-appset-16.0.0.aar
com.google.android.gms.play-services-base-17.6.0.aar
com.google.android.gms.play-services-basement-17.6.0.aar
com.google.android.gms.play-services-measurement-base-18.0.3.aar
com.google.android.gms.play-services-measurement-sdk-api-18.0.3.aar
com.google.android.gms.play-services-tasks-17.2.1.aar
com.google.android.ump.user-messaging-platform-1.0.0.aar
com.google.guava.listenablefuture-1.0.jar

Modified artifacts:
com.google.ads.mediation:applovin:11.0.0.0 --> com.google.ads.mediation:applovin:11+
com.google.ads.mediation:facebook:6.8.0.0 --> com.google.ads.mediation:facebook:6+
com.google.android.gms:play-services-ads:20.5.0 --> com.google.android.gms:play-services-ads:+

As you see, after a "conflict" between the mediation SDKs, it decides to download com.google.android.gms:play-services-ads:+ which ends downloading version 20.6.0, while I was expecting to respect the "upper bound" and use 20.5.0.

What am I doing wrong?

Thanks

google-oss-bot commented 2 years ago

This issue does not seem to follow the issue template. Make sure you provide all the required information.

paulinon commented 2 years ago

Hi @dots-alberto-uriarte,

Thanks for reporting this issue. Could you provide a minimal, reproducible example of your project along with the complete steps to reproduce the issue so that we can identify what's causing this behavior?

dots-alberto-uriarte commented 2 years ago

Hi @paulinon,

It is happening in a very big and 8 year old LIVE product with many external SDKs so I was hoping that the example provided executing directly the download_artifacts.gradle was enough. If not I will need a while to prepare a minimal project to reproduce the error. Meanwhile can you please:

  1. Confirm that this is not the expected behaviour
  2. Can you point to other settings the download_artifacts.gradle is using besides the ones passed as argument?
dots-alberto-uriarte commented 2 years ago

I believe I'm facing the same problem as this one https://github.com/googlesamples/unity-jar-resolver/issues/444

paulinon commented 2 years ago

Hi @dots-alberto-uriarte,

Could you try this suggestion from the thread you provided and see if it resolves your issue?

Unfortunately, I don't have enough context to answer either question right now. A minimal, reproducible example would be helpful for this scenario.

chkuang-g commented 2 years ago

@dots-alberto-uriarte

  1. I think this is unfortunately the expected behavior and one limitation of EDM4U. download_artifacts.gradle tried its best to resolve the conflict, but it is just a way to resolve, which is a bit different from what Gradle does by default. For instance, when a conflict like this occurs
    - com.google.ads.mediation:applovin:11.0.0.0/com.google.android.gms:play-services-ads:20.5.0
    - com.google.ads.mediation:facebook:6.8.0.0/com.google.android.gms:play-services-ads:20.4.0

    It would try to change deps to applovin:11.0.0.+ and facebook:6.8.0.+ and resolve again. If failed, it tries applovin:11.0.+ and facebook:6.8.+, so forth and so on until no conflict occurs. I think Gradle, or what Unity Gradle project does, would just bump up play-services-ads to 20.5.0 and assume everything would just work perfectly, which can be most of the case.

  2. Other than the arguments, you can also set Gradle properties. You can find the documentation here, and how EDM4U use it here.

I am wondering why you need to run download_artifacts.gradle manually but I guess you may be using a very old version of Unity and EDM4U did not work well to you. Here are some recommendation for you.

We have not update download_artifacts.gradle for quite awhile since Unity's Gradle project, along with Custom Gradle Template, usually works better for most of people. We do have this https://github.com/googlesamples/unity-jar-resolver/issues/444 to look into this but we have very little resources lately. Please upvote and comment what you need in that thread.

Let us know if this helps.

Shawn

dots-alberto-uriarte commented 2 years ago

Hi,

Thanks for reply and your time! I really appreciate the feedback

I am wondering why you need to run download_artifacts.gradle manually but I guess you may be using a very old version of Unity and EDM4U did not work well to you.

I don't "need". Our project was not using the Custom Gradle Template, so Force Resolve was running the download_artifacts.gradle. I noticed that in the logs, so I ended running it manually to do faster iterations on how to solve the problem.

✅ Yes, this workaround solved the problem. Thanks!

  • If you cannot use Unity or Custom Gradle Template, perhaps try to lower the version of com.google.ads.mediation:applovin:11.0.0.0 and com.google.android.gms:play-services-ads:20.5.0 and see if you can find the versions with no conflict. I would also recommend you to consult with Google Ads team and see what is the best combination.

I'm afraid this is not a valid option since even if I find a valid combination, there is no guarantee that the maven POD will never been updated with another dependency. I know, it's not likely but it can happen.

  • If you HAVE to pin to play-services-ads:20.5.0, try to use play-services-ads:[20.5.0], which means exact version.

Yes, I noticed that I can do that. But I wanted to avoid any changes to exported .unitypackages since next person upgrading SDKs may forgot to do this step.

paulinon commented 2 years ago

Glad to hear that your problem has been solved, @dots-alberto-uriarte. That being said, I'll be closing this for now. You may refer to #444 if there's anything you need.

manwithsteelnerves commented 2 years ago
  • If you HAVE to pin to play-services-ads:20.5.0, try to use play-services-ads:[20.5.0], which means exact version.

@chkuang-g What happens in this case if another plugin specifies 20.8.0 in their dependencies xml file? Will it halt the resolution with an error.