CommandInvokationFailure: Gradle build failed.
C:/Program Files/Java/jdk1.8.0_111\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2017.4.30f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.6.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "bundleRelease"
stderr[
D8: Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':transformDexArchiveWithExternalLibsDexMergerForRelease'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
C:\Users\Andy \Documents\Unity 2017.4.301\ Drone\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\0.jar,
C:\Users\Andy \Documents\Unity 2017.4.301\Drone\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\1.jar,
...repetitive entries truncated...the list goes all the way up to ...\release\135.jar
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiverHi Andy,
Thank you for reaching out to us, and for giving an extensive rundown of your concern.
My first guess on why this would happen would be the presence of duplicate classes from the different .unitypackages you are currently using on your project. I'll be able to assist you on this if you could provide me the details below (via Reply privately to author):
You may opt to not include the Library and Temp folders when sending your project folder in order to reduce overall size. You may also share the project via Google Drive (or any other file-sharing service of your preference), as long as it's done privately.
Regards,
Ziv Yves Sanchez
Mobile Ads SDK Team
Hi there,
Thank you for providing the requested details in private, as well as for giving additional context on your concern.
I can confirm that the Play Services Resolver tries to include AndroidX dependencies into the project whenever I imported the AdMob SDK unitypackage into it. While I was unable to determine why it does this (considering that version 3.13.1 of the AdMob SDK does not use AndroidX libraries yet), I was able to make an APK via simply excluding the AndroidX libraries from the build. Kindly see attached screenshot. I can confirm that the built APK then runs successfully on our test device, after setting up the App ID to be used by the AdMob SDK. Do note that this is the older (now deprecated) way of adding your AdMob App ID into your app; newer versions of the SDK has a different way of doing it.
A couple of additional notes here:
Hi Andy,
Thank you for attempting the solution I've suggested.
Could you kindly post the Logcat error logs that you've encountered after having tried the solution?
As for your concern with regard to the issue you're having on the AdMob SDK version 4.10.0: could you confirm if you have an internet connection on your test device? The code might treat the banner ad as having failed the initialization if there was no internet connection during that time.
Hi Andy,
Glad to hear that you've got most of your setup working.
It seems that you've got AdMob SDK working properly on your end, and only the Cross Platform Native Plugins (CPNP) is acting up at this point. Given that this is a third-party plugin, I'm afraid that we will not be able to provide any more insights on it. I would recommend that you contact the support channels for CPNP for further assistance on this.
stderr[
D8: Program type already present: android.support.v4.os.ResultReceiver$1
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':transformDexArchiveWithExternalLibsDexMergerForRelease'.
Yes, thank you. You may close my ticket. For the sanity of others who might run into this, here are my final notes: Thank you for your help.
Just wanted to make some notes for others as this has been resolve.On Unity 2017.4.301f running CPNP 15.7 everything worked fine. Added Google Ads 3.13.0 assuming it would work like SUko, but since we are in 2017, the resolver created duplicate class entries and caused build crashes.The error looked like this:stderr[
D8: Program type already present: android.support.v4.os.ResultReceiver$1
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':transformDexArchiveWithExternalLibsDexMergerForRelease'.Online solutions suggested:
- Resolving as a multidex error - not my issue
- Duplicate NDK installed on PC - 2 on system, removed NDK in Android Studio, kept NDKR18 but no effect.
- Use Gradle Experimental, allowed build, but app would crash on all devices.
We also attempted GoogleMobileAds support suggestion of disabling the AndroidX files for android builds in thread above, which allowed the build to succeed, but that disabled GooglePlay services from functioning.
So none of those were my issue.