Mediated AdColony and Vungle conflict when making Gradle builds

462 views
Skip to first unread message

Clinton Blackmore

unread,
Mar 2, 2018, 1:18:48 AM3/2/18
to Google Mobile Ads SDK Developers
Summary

It appears that a dependancy used by AdColony under AdMob mediation conflicts with Vungle under AdMob mediation. The error I get is

Build failure: com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/unity/mediation/vungle/BuildConfig; See the Console for details.

or 

Build failure: com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/unity/mediation/vungle/BuildConfig.class See the Console for details.

depending upon the version of Unity.

Incidentally, if there is a better place for me to report issues like this, please let me know.

Here is my setup:

    Game Engine: Unity 2017.3.0p4 (similar steps were tried with 5.6.2p1 and 2017.2.1f1, with roughly the same result)
    Plugin: Google Mobile Ads Unity Plugin, v 3.11.1
    Version of Mobile Ads SDK: com.google.android.gms.play-services-ads-11.8.0
    Model, OS, OS version: Samsung Galaxy Tab E Lite SM-T113, Android 4.4.4

    Version of AppLovin adapter: 1.1.0


Steps To Reproduce


We will reproduce the issue here. Note that as the end result doesn't build, we aren't going to bother with setting SDK keys or placement IDs or tweaking the Android manifest. Also note that some of these steps I'll do from the command-line on my Mac. I'm sure you can figure out equivalent ways to get the results with other tools/OSes.

1. Get the Hello World sample app running
- download the Google Mobile Ads Unity Plugin v3.11.1 releases, getting the zip and the unity package.
- extract; open the samples/HelloWorld project in Unity
- import the GoogleMobileAds.unitypackage

2. Make sure we are creating an gradle build for Android
- open up the MainScene
- first, from the menu, go to Assets -> Play Services Resolver -> Android Resolver -> Settings and click the 'Reset to defaults' button
- bring up the build settings dialog (File -> Build Settings) and switch to the Android platform
- click on the "Player Settings..." button
- under Other Settings -> Identification, change the package name. (ex. com.Company.ads_plus_gradle)
- under Publisher Settings -> Build, set the Build System to Gradle. [Interesting. This was not the default setting in the other versions of Unity.]
- if you make a build now, it will build properly

3. Import the Vungle Adapter
- download GoogleMobileAdsVungleMediation-1.0.0.zip, extract it, and import the package into your project 
- (again, note we aren't doing any setup)
- if you build and run, it still compiles and will serve test ads from AdMob

4. Import the AdColony Adapter
- download the GoogleMobileAdsAdCoplonyMediation-1.0.0.zip file, extract it, and import the package into your project
- if you build it now, you'll get a error during compilation:

Build failure: com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/unity/mediation/vungle/BuildConfig; See the Console for details.

[Interesting. The error I got in previous versions of Unity was: "Build failure: com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/unity/mediation/vungle/BuildConfig.class See the Console for details."]

The console doesn't actually tell us much, but the error that starts "CommandInvokationFailure: Gradle build failed." does give us a command-line to work with for the next step in which we do diagnosis. You'll want to copy and keep it handy. In my case, the command is: 

/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/bin/java -classpath "/Applications/Unities/2017.3.0p4/PlaybackEngines/AndroidPlayer/Tools/gradle/lib/gradle-launcher-4.0.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m" "assembleRelease"


I finally came to realize that the error message is telling me that there are two sources of the com/google/unity/mediation/vungle/BuildConfig.class, and it could not pack the second copy into a zip file without stomping all over the first copy, which would be bad. (Apparently the internal build process that Unity used to use doesn't care).


5. Export a Gradle Build for Analysis
- from the build settings window, tick the 'Export Project' box, and hit the "Export" button, and choose a folder.
- go to that folder in a Terminal (or Console, or Powershell, adapting as necessary), in my case, `cd ~/Downloads/Export/HelloWorld/`
- after hours of debugging, I found that the command Unity offered us runs grandle and then passes in a parameter, namely "assembleRelease". (Note that if you import the project into AndroidStudio, you could run ./gradlew and run the gradle wrapper, instead of typing in this monstrous command).
- we will run gradle with that command ("assembleRelease"), but tell it to give us tons of debugging information ("--debug") and save the info to a file (" > build_results.txt")

/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/bin/java -classpath "/Applications/Unities/2017.3.0p4/PlaybackEngines/AndroidPlayer/Tools/gradle/lib/gradle-launcher-4.0.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m" "assembleRelease" --debug > build_results.txt

Now we can search the build_results.txt file for 'com/google/unity/mediation/vungle/BuildConfig.class'. One way to do that, with a bit of context, is to run:

cat build_results.txt | grep -C3 'com/google/unity/mediation/vungle/BuildConfig.class'

The output differs depending upon the version of Unity. I got the following with 2017.3.0p4:

22:58:04.433 [INFO] [org.gradle.api.Project] AndroidBuilder::preDexLibraryNoCache /Users/clinton/Downloads/Export/HelloWorld/GoogleMobileAdsAdColonyMediation/build/intermediates/bundles/default/classes.jar

22:58:04.433 [INFO] [org.gradle.api.Project] Dexing in-process : /Users/clinton/Downloads/Export/HelloWorld/GoogleMobileAdsAdColonyMediation/build/intermediates/bundles/default/classes.jar

22:58:04.510 [INFO] [com.android.build.gradle.internal.ApplicationTaskManager] processing archive /Users/clinton/Downloads/Export/HelloWorld/GoogleMobileAdsAdColonyMediation/build/intermediates/bundles/default/classes.jar...

22:58:04.510 [INFO] [com.android.build.gradle.internal.ApplicationTaskManager] processing com/google/unity/mediation/vungle/BuildConfig.class...

22:58:04.510 [DEBUG] [org.gradle.api.Project] writing classes.dex; size 788...

22:58:04.511 [INFO] [org.gradle.api.Project] Dexing /Users/clinton/Downloads/Export/HelloWorld/GoogleMobileAdsAdColonyMediation/build/intermediates/bundles/default/classes.jar took 74.15 ms.

22:58:04.511 [INFO] [com.android.build.gradle.internal.ApplicationTaskManager] predex called for /Users/clinton/Downloads/Export/HelloWorld/GoogleMobileAdsPlugin/build/intermediates/bundles/default/classes.jar

--

--

22:58:04.670 [INFO] [org.gradle.api.Project] AndroidBuilder::preDexLibraryNoCache /Users/clinton/Downloads/Export/HelloWorld/libs/vungle-extras-library.jar

22:58:04.671 [INFO] [org.gradle.api.Project] Dexing in-process : /Users/clinton/Downloads/Export/HelloWorld/libs/vungle-extras-library.jar

22:58:04.766 [INFO] [com.android.build.gradle.internal.ApplicationTaskManager] processing archive /Users/clinton/Downloads/Export/HelloWorld/libs/vungle-extras-library.jar...

22:58:04.766 [INFO] [com.android.build.gradle.internal.ApplicationTaskManager] processing com/google/unity/mediation/vungle/BuildConfig.class...

22:58:04.766 [INFO] [com.android.build.gradle.internal.ApplicationTaskManager] processing com/google/unity/mediation/vungle/VungleUnityExtrasBuilder.class...

22:58:04.766 [INFO] [com.android.build.gradle.internal.ApplicationTaskManager] processing com/google/unity/mediation/vungle/VungleUnityInterstitialExtrasBuilder.class...

22:58:04.766 [INFO] [com.android.build.gradle.internal.ApplicationTaskManager] processing com/google/unity/mediation/vungle/VungleUnityRewardedVideoExtrasBuilder.class...



This tells me that gradle was getting the com/google/unity/mediation/vungle/BuildConfig.class from GoogleMobileAdsAdColonyMediation/build/intermediates/bundles/default/classes.jar and  libs/vungle-extras-library.jar.

(When I ran this with a previous version of Unity, I didn't need any context; the results were:

21:24:30.808 [DEBUG] [com.android.build.gradle.internal.transforms.JarMerger] addJar(/Users/clinton/Development/AdMob/Export/AdMob Mediation Test App/libs/vungle-extras-library.jar): entry com/google/unity/mediation/vungle/BuildConfig.class
21:24:31.954 [DEBUG] [com.android.build.gradle.internal.transforms.JarMerger] addJar(/Users/clinton/Development/AdMob/Export/AdMob Mediation Test App/build/intermediates/exploded-aar/AdMob Mediation Test App/GoogleMobileAdsAdColonyMediation/unspecified/jars/classes.jar): entry com/google/unity/mediation/vungle/BuildConfig.class
)


Going back to my project, it is easy to find the vungle-extras-library.jar, which seems like a reasonable place for a file named com/google/unity/mediation/vungle/BuildConfig.class. As for the other file, well, I don't know where exactly it is from. It is clearly related to GoogleMobileAdsAdColonyMediation, and I have reason to think that the Play Services Resolver found some sort of dependency for it, and exploded it. This is not at all where a file named com/google/unity/mediation/vungle/BuildConfig.class belongs!


6. The Hacky Work-Around

I'm hoping you can help me with a real fix. It appears that something that comes with, or plays a supporting role for, the ad colony adapter conflicts with a vungle file.

I am able, now that I've identified it, to open the vungle-extra-library.jar (which is just a zip file) and remove the BuildConfig.class and recompress it, and then everything builds, but this is a workaround and not a solution.

Thank you for your time.
Clinton Blackmore

mobileadssdk-a...@google.com

unread,
Mar 2, 2018, 3:54:23 AM3/2/18
to Clinton Blackmore, Google Mobile Ads SDK Developers
Hi Clinton,

Kindly note that issues with the official Google Mobile Ads Unity Plugin can also be raised on their Issue Tracker

However, thank you for the wonderfully crafted and detailed report. I can confirm that I can see the exact same behavior on my end. Let me raise this to the rest of the team for additional investigation and get back to you once I have their official insights.

Regards,
Joshua Lagonera
Mobile Ads SDK Team

--

---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-admob-ads-sdk/88c29d79-9683-44a0-9ebd-b7b9fe1f4f34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Clinton Blackmore

unread,
Mar 2, 2018, 10:04:50 AM3/2/18
to mobileadssdk-a...@google.com, Google Mobile Ads SDK Developers
Thank you, Joshua.

Clinton

To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads...@googlegroups.com.

To post to this group, send email to google-adm...@googlegroups.com.

mobileadssdk-a...@google.com

unread,
Mar 15, 2018, 2:14:30 AM3/15/18
to Clinton Blackmore, Google Mobile Ads SDK Developers
Hi Clinton,

I have just received word that a fix has been provided for this issue. However, we are not able to say when this fix will be released. I would suggest that you regularly monitor our official Unity Plugin, as well as our official Vungle and AdColony Unity Mediation Plugins for any updates.

Thank you for your patience and for reporting this issue to us. 

Regards,
Joshua Lagonera
Mobile Ads SDK Team

On 03/02/18 23:04:07 clinton....@gmail.com wrote:
Thank you, Joshua.

Clinton

To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.

To post to this group, send email to google-admob-ads-sdk@googlegroups.com.

Clinton Blackmore

unread,
Mar 15, 2018, 8:45:17 AM3/15/18
to mobileadssdk-a...@google.com, Google Mobile Ads SDK Developers
Wonderful.

Thank you, Joshua.

Clinton Blackmore

On Thu, Mar 15, 2018 at 12:14 AM <mobileadssdk-a...@google.com> wrote:
Hi Clinton,

I have just received word that a fix has been provided for this issue. However, we are not able to say when this fix will be released. I would suggest that you regularly monitor our official Unity Plugin, as well as our official Vungle and AdColony Unity Mediation Plugins for any updates.

Thank you for your patience and for reporting this issue to us. 

Regards,
Joshua Lagonera
Mobile Ads SDK Team

On 03/02/18 23:04:07 clinton....@gmail.com wrote:
Thank you, Joshua.

Clinton

To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads...@googlegroups.com.

To post to this group, send email to google-adm...@googlegroups.com.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages