unity-jar-resolver icon indicating copy to clipboard operation
unity-jar-resolver copied to clipboard

[FR] Improve Android Resolver resolution and logging when conflicts occur without mainTemplate.gradle

Open rotter opened this issue 3 years ago • 19 comments

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2020.3.6f1
  • External Dependency Manager version: 1.2.165
  • Source you installed EDM4U: .unitypackage
  • Features in External Dependency Manager in use: Android
  • Plugins SDK in use: Firebase, Admob and Facebook Audience Network
  • Platform you are using the Unity editor on: Mac

[REQUIRED] Please describe the question here:

I'm a long time user of Jar Resolver (since 2018 or so), but never had to fiddle or understand its inner workings as it always worked fine for me. I always only used Google plugins (Firebase and Admob) and had no issues.

Recently I started using Facebook Audience Network but since a couple months I am having a problem which took me a while to find the root cause. This problem was causing a crash, after a while of debugging I noticed it was using a newer audience-network-sdk (6.5.0) than I was expecting (6.2.0), and for some reason this newer version has issues that are causing the crash that are unrelated to this post/repo. After more debugging I found out that EDM is changing the version to the latest version, and after narrowing it down a bit more I saw on the huge log that it says that there is a conflict, but I fail to understand what is this conflict, or how to solve it:

com.facebook.android:audience-network-sdk conflicting due to package(s):

  • com.facebook.android:audience-network-sdk:6.2.0
  • com.google.ads.mediation:facebook:6.2.0.0/com.facebook.android:audience-network-sdk:6.2.0

Then after a few resolve iterations it changes the version to "6+" and that's what causes the SDK version to change to 6.5.0 (which currently is the latest version). But the names are exactly the same (1st line "com.facebook.android:audience-network-sdk:6.2.0" vs the right side of the slash), I dont understand the root cause of this conflict.

There's a second conflict that follows exactly the same pattern: com.google.android.gms:play-services-ads conflicting due to package(s):

  • com.google.ads.mediation:facebook:6.2.0.0/com.google.android.gms:play-services-ads:19.5.0
  • com.google.android.gms:play-services-ads:19.5.0

Any help is appreciated, thanks in advance!

rotter avatar Jun 23 '21 01:06 rotter

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

google-oss-bot avatar Jun 23 '21 01:06 google-oss-bot

Hi @rotter,

In order to identify what's causing this behavior, could you provide a minimal, reproducible example of your project?

paulinon avatar Jun 24 '21 11:06 paulinon

Thanks @paulinon for the response. I have made the following steps to reproduce, which is pretty simple and I believe safer (for both of us) than me sending a project, but if you still prefer the project I can send it, let me know.

  1. Created an empty project on Unity (selected 2D template but dont think it makes any difference)
  2. Switched to Android
  3. Imported FAN 6.2.0 ( https://developers.facebook.com/resources/audience-network-unity-sdk-6.2.0.zip )
  4. Ran Force Resolve and it worked (downloaded version 6.2.0)
  5. Imported FAN-AdMob mediation 3.1.0 ( https://dl.google.com/googleadmobadssdk/mediation/unity/facebook/FacebookUnityAdapter-3.1.0.zip )
  6. Ran Force Resolve and it gave the conflicts mentioned and ended up downloading the latest FAN version (6.5.0) which is the undesired effect

Is something mis-configured on Facebook's FAN side? Or on Google's Mediation plugin side? Or is it a problem with jar resolver?

Obs: just found out by chance someone else with the same problem: https://forum.unity.com/threads/solved-gradle-is-not-building-after-importing-facebook-sdk-with-admob-mediation.1102282/

rotter avatar Jun 30 '21 17:06 rotter

Thanks for providing more information, @rotter. While I try to do these steps, could you try if using 1.2.166 of the resolver makes any difference?

paulinon avatar Jul 01 '21 12:07 paulinon

I have just downloaded the latest version and tried again, same problem (did a Reimport All and also Delete Resolved Libraries to be sure).

The only difference I noticed from the scenario I reported yesterday is that now it is now downloading Audience Network version 6.5.1 (instead of 6.5.0), but I would guess Facebook released a new version yesterday night.

rotter avatar Jul 01 '21 12:07 rotter

Hi @rotter,

I've tried the steps you've given, but I wasn't able to replicate your issue. The version of the FAN SDK remained at version 6.2.0, and I encountered no conflicts after the last Force Resolve. It would be great if you could provide a minimal, reproducible example of your project so that we can narrow down the cause of your issue.

Additionally, could you confirm if performing these steps in a new project produces the same issue?

paulinon avatar Jul 01 '21 15:07 paulinon

Hi @paulinon ! Thanks for trying it. I did those steps on a new project which I created specifically to test it, and I havent changed any setting of this newly created project.

Maybe it's related to the OS (Mac), or to my Unity version (2020.3.6f)? Or maybe it's related to my local files/local repo (Im not sure how it works)? In any case I will send you the link to the project zip via private message.

rotter avatar Jul 01 '21 15:07 rotter

@paulinon

Ok, I dont know how to send a pm, it's probably not possible. Here goes the link. Deleted.

rotter avatar Jul 01 '21 15:07 rotter

I've downloaded it. You may now break the link.

paulinon avatar Jul 01 '21 16:07 paulinon

Hi @rotter,

I wasn't able to replicate your issue even with your project. Could you try using the latest version of the Unity Editor (2020.3.13f1 for LTS) and see if it makes a difference?

paulinon avatar Jul 02 '21 09:07 paulinon

Hey again @paulinon ! I have just downloaded 2020.3.13f and migrated the project to it, did a Reimport All, then Delete Libs, then Force Resolve, same conflicts and same result (downloaded com.facebook.android.audience-network-sdk-6.5.1 ). Some possibilities:

  • the OS (I use Mac)
  • local files/local repo external to the project but maybe shared among projects
  • some setting on my Unity (not on the project, which is a new project with default and untouched settings)

rotter avatar Jul 02 '21 23:07 rotter

Yesterday I tried on an employee's computer, which is an older ~2012 Mac on an older OSX version (Catalina), sent him the same ZIP and he had the same result as me (conflicts, then downloaded FAN 6.5.1). Also, he probably runs on default Unity settings, so I doubt it's related to Unity settings. That leaves only the OS from my original possibilities/suspicions (unless we both have some problem on our local files/repo), and unfortunately I dont have any Windows machine to test.

rotter avatar Jul 10 '21 12:07 rotter

@stewartmiles can you shed any light here please? Anyone? Thanks :)

rotter avatar Jul 20 '21 11:07 rotter

I haven't worked on this project for quite a while. @chkuang-g is likely the best person to take a look. Looking at the original message it sounds like the package conflict resolution logic is wrong when the same package is pulled in from different paths of the dependency graph.

stewartmiles avatar Jul 20 '21 15:07 stewartmiles

Hi @stewartmiles!

Sorry for the long wait. I think there is an internal bug similar to this b/191478283.

To unblock you right now, I recommend you to turn ON Custom Gradle Template, a.k.a. mainTemplate.gradle. In that case, Unity will use Gradle to resolve dependency for you instead of having EDM4U doing such for you. If you are using Firebase and is using Unity 2020, also turn on Custom Gradle Property Template (to enable AndroidX and Jetifier) and Minify (to trim down unused symbols so that you do not need to use multi-dex). See the following picture.

Screen Shot 2021-07-21 at 11 35 09 AM

This should theoretically unblock you. Let me see if I can reproduce the issue from my end.

chkuang-g avatar Jul 21 '21 22:07 chkuang-g

Modified artifacts:
com.android.support:support-annotations:28.0.0 --> androidx.annotation:annotation:1.0.0
com.facebook.android:audience-network-sdk:6.2.0 --> com.facebook.android:audience-network-sdk:+
com.google.ads.mediation:facebook:6.2.0.0 --> com.google.ads.mediation:facebook:+

Alright, I did get this. Let me dig a bit more.

chkuang-g avatar Jul 21 '21 23:07 chkuang-g

Judge by the log, I think the main conflict is play-services-basement since FAN depends on 11.0.4 while Admob mediation depends on 17.0.0, 17.3.0. Since this is major version difference, I guess the gradle script in EDM4U ended up change both com.facebook.android:audience-network-sdk and com.google.ads.mediation:facebook to +.

com.google.android.gms:play-services-basement conflicting due to package(s):
- com.facebook.android:audience-network-sdk:6.2.0/com.google.android.gms:play-services-basement:11.0.4
- com.google.ads.mediation:facebook:6.2.0.0/com.facebook.android:audience-network-sdk:6.2.0/com.google.android.gms:play-services-basement:11.0.4
- com.google.ads.mediation:facebook:6.2.0.0/com.google.android.gms:play-services-ads:19.5.0/com.google.android.gms:play-services-ads-identifier:17.0.0/com.google.android.gms:play-services-basement:17.0.0
- com.google.ads.mediation:facebook:6.2.0.0/com.google.android.gms:play-services-ads:19.5.0/com.google.android.gms:play-services-ads-lite:[19.5.0]/com.google.android.gms:play-services-basement:17.3.0
- com.google.ads.mediation:facebook:6.2.0.0/com.google.android.gms:play-services-ads:19.5.0/com.google.android.gms:play-services-ads-lite:[19.5.0]/com.google.android.gms:play-services-measurement-sdk-api:17.2.0/com.google.android.gms:play-services-basement:17.0.0
- com.google.ads.mediation:facebook:6.2.0.0/com.google.android.gms:play-services-ads:19.5.0/com.google.android.gms:play-services-ads-lite:[19.5.0]/com.google.android.gms:play-services-measurement-sdk-api:17.2.0/com.google.android.gms:play-services-measurement-base:[17.2.0]/com.google.android.gms:play-services-basement:17.0.0
- com.google.ads.mediation:facebook:6.2.0.0/com.google.android.gms:play-services-ads:19.5.0/com.google.android.gms:play-services-basement:17.3.0
- com.google.ads.mediation:facebook:6.2.0.0/com.google.android.gms:play-services-ads:19.5.0/com.google.android.gms:play-services-gass:[19.5.0]/com.google.android.gms:play-services-ads-identifier:17.0.0/com.google.android.gms:play-services-basement:17.0.0
- com.google.ads.mediation:facebook:6.2.0.0/com.google.android.gms:play-services-ads:19.5.0/com.google.android.gms:play-services-gass:[19.5.0]/com.google.android.gms:play-services-ads-lite:[19.5.0]/com.google.android.gms:play-services-basement:17.3.0
- com.google.ads.mediation:facebook:6.2.0.0/com.google.android.gms:play-services-ads:19.5.0/com.google.android.gms:play-services-gass:[19.5.0]/com.google.android.gms:play-services-ads-lite:[19.5.0]/com.google.android.gms:play-services-measurement-sdk-api:17.2.0/com.google.android.gms:play-services-basement:17.0.0
- com.google.ads.mediation:facebook:6.2.0.0/com.google.android.gms:play-services-ads:19.5.0/com.google.android.gms:play-services-gass:[19.5.0]/com.google.android.gms:play-services-ads-lite:[19.5.0]/com.google.android.gms:play-services-measurement-sdk-api:17.2.0/com.google.android.gms:play-services-measurement-base:[17.2.0]/com.google.android.gms:play-services-basement:17.0.0
- com.google.ads.mediation:facebook:6.2.0.0/com.google.android.gms:play-services-ads:19.5.0/com.google.android.gms:play-services-gass:[19.5.0]/com.google.android.gms:play-services-basement:17.3.0
- com.google.ads.mediation:facebook:6.2.0.0/com.google.android.gms:play-services-ads:19.5.0/com.google.android.gms:play-services-gass:[19.5.0]/com.google.android.gms:play-services-tasks:17.1.0/com.google.android.gms:play-services-basement:17.3.0

Based on what the Admob team found out in b/191478283#comment24, what I recommended in https://github.com/googlesamples/unity-jar-resolver/issues/444#issuecomment-884549348 should work for you.

I think there are a couple of actions items for your reporting:

  1. It is really hard to learn there is a conflict during resolution. First, tracking the true cause of the conflict is only available through verbose logging and the verbose log is really long. Second, EDM4U report Resolution Succeeded even if there is some conflicts. Perhaps it should have three types of result: Resolution Succeeded with no conflict, Resolution succeeded with initial conflict with package A, B and C, and Resolution failed due to conflict with package A, B and C.
  2. EDM4U log conflicts for some packages where there is no conflict at all, which is confusing. Ex.
    com.facebook.android:audience-network-sdk conflicting due to package(s):
    - com.facebook.android:audience-network-sdk:6.2.0 
    - com.google.ads.mediation:facebook:6.2.0.0/com.facebook.android:audience-network-sdk:6.2.0   
    
  3. Understand why EDM4U gradle script failed while mainTemplate.gradle succeeded and potentially improve the resolution logic while mainTemplate.gradle is not in use.

Let me change the title a bit and change this to a feature request.

Let us know if this helps.

chkuang-g avatar Jul 22 '21 18:07 chkuang-g

Hi @rotter,

Could you confirm if turning on the Custom Gradle Template is helpful for your use case?

paulinon avatar Oct 20 '21 14:10 paulinon

In my case turning on the Custom Gradle Template worked 😄

If download_artifacts.gradle is not able to resolve dependencies properly (or it doesn't have an option to define the strategy), maybe you should consider the option to remove it from the project and enforce the use of Custom Gradle Template.

dots-alberto-uriarte avatar Mar 15 '22 20:03 dots-alberto-uriarte