skip to Main Content

I am developing an Android Game and for a week now, I have tried my best to implement AdMob with Mediation. It works fine in the Editor, but when I build, it throws the error mentioned below. I did try to implement multiple other plugins and they built successfully, but crashed on launch (also tried with just their sample app implementations in new projects).

After a lot of digging around, I have a hypothesis that Facebook needs some aars that Admob need, but cannot use the latest version of it (I have tried latest FB SDK versions to no avail as well). Here are some things I noticed:

  1. Notice that CustomTabs is present here. I tried deleting these classes but then build failed with another error

    Some conflicting dependencies were found.
    The following dependency versions were modified:
    com.android.support:appcompat-v7:25.3.1 –> com.android.support:appcompat-v7:27.0.2@aar
    com.android.support:cardview-v7:25.3.1 –> com.android.support:cardview-v7:27.0.2@aar
    com.android.support:customtabs:25.3.1 –> com.android.support:customtabs:27.0.2@aar
    com.android.support:support-v4:25.3.1 –> com.android.support:support-v4:27.0.2@aar

  2. This is the AndroidResolverDependencies.xml file in ProjectSettings Dir.

    com.android.support:appcompat-v7:25.3.1
    com.android.support:cardview-v7:25.3.1
    com.android.support:customtabs:25.3.1
    com.android.support:support-v4:25.3.1
    com.facebook.android:facebook-core:[5,6)
    com.facebook.android:facebook-login:[5,6)
    com.facebook.android:facebook-share:[5,6)
    com.google.ads.mediation:unity:3.1.0.0
    com.google.android.gms:play-services-ads:18.0.0
    com.parse.bolts:bolts-android:1.4.0
    com.unity3d.ads:unity-ads:3.1.0

    Assets/Plugins/Android/android.arch.core.common-1.0.0.jar
    Assets/Plugins/Android/android.arch.lifecycle.common-1.0.3.jar
    Assets/Plugins/Android/android.arch.lifecycle.runtime-1.0.3.aar
    Assets/Plugins/Android/androidx.annotation.annotation-1.0.0.jar
    Assets/Plugins/Android/androidx.arch.core.core-common-2.0.0.jar
    Assets/Plugins/Android/androidx.arch.core.core-runtime-2.0.0.aar
    Assets/Plugins/Android/androidx.asynclayoutinflater.asynclayoutinflater-1.0.0.aar
    Assets/Plugins/Android/androidx.browser.browser-1.0.0.aar
    Assets/Plugins/Android/androidx.collection.collection-1.0.0.jar
    Assets/Plugins/Android/androidx.coordinatorlayout.coordinatorlayout-1.0.0.aar
    Assets/Plugins/Android/androidx.core.core-1.0.0.aar
    Assets/Plugins/Android/androidx.cursoradapter.cursoradapter-1.0.0.aar
    Assets/Plugins/Android/androidx.customview.customview-1.0.0.aar
    Assets/Plugins/Android/androidx.documentfile.documentfile-1.0.0.aar
    Assets/Plugins/Android/androidx.drawerlayout.drawerlayout-1.0.0.aar
    Assets/Plugins/Android/androidx.fragment.fragment-1.0.0.aar
    Assets/Plugins/Android/androidx.interpolator.interpolator-1.0.0.aar
    Assets/Plugins/Android/androidx.legacy.legacy-support-core-ui-1.0.0.aar
    Assets/Plugins/Android/androidx.legacy.legacy-support-core-utils-1.0.0.aar
    Assets/Plugins/Android/androidx.lifecycle.lifecycle-common-2.0.0.jar
    Assets/Plugins/Android/androidx.lifecycle.lifecycle-livedata-2.0.0.aar
    Assets/Plugins/Android/androidx.lifecycle.lifecycle-livedata-core-2.0.0.aar
    Assets/Plugins/Android/androidx.lifecycle.lifecycle-runtime-2.0.0.aar
    Assets/Plugins/Android/androidx.lifecycle.lifecycle-viewmodel-2.0.0.aar
    Assets/Plugins/Android/androidx.loader.loader-1.0.0.aar
    Assets/Plugins/Android/androidx.localbroadcastmanager.localbroadcastmanager-1.0.0.aar
    Assets/Plugins/Android/androidx.print.print-1.0.0.aar
    Assets/Plugins/Android/androidx.slidingpanelayout.slidingpanelayout-1.0.0.aar
    Assets/Plugins/Android/androidx.swiperefreshlayout.swiperefreshlayout-1.0.0.aar
    Assets/Plugins/Android/androidx.versionedparcelable.versionedparcelable-1.0.0.aar
    Assets/Plugins/Android/androidx.viewpager.viewpager-1.0.0.aar
    Assets/Plugins/Android/com.android.support.animated-vector-drawable-27.0.2.aar
    Assets/Plugins/Android/com.android.support.appcompat-v7-27.0.2.aar
    Assets/Plugins/Android/com.android.support.cardview-v7-27.0.2.aar
    Assets/Plugins/Android/com.android.support.customtabs-27.0.2.aar
    Assets/Plugins/Android/com.android.support.support-annotations-27.0.2.jar
    Assets/Plugins/Android/com.android.support.support-compat-27.0.2.aar
    Assets/Plugins/Android/com.android.support.support-core-ui-27.0.2.aar
    Assets/Plugins/Android/com.android.support.support-core-utils-27.0.2.aar
    Assets/Plugins/Android/com.android.support.support-fragment-27.0.2.aar
    Assets/Plugins/Android/com.android.support.support-media-compat-27.0.2.aar
    Assets/Plugins/Android/com.android.support.support-v4-27.0.2.aar
    Assets/Plugins/Android/com.android.support.support-vector-drawable-27.0.2.aar
    Assets/Plugins/Android/com.facebook.android.facebook-common-5.1.0.aar
    Assets/Plugins/Android/com.facebook.android.facebook-core-5.1.0.aar
    Assets/Plugins/Android/com.facebook.android.facebook-login-5.1.0.aar
    Assets/Plugins/Android/com.facebook.android.facebook-share-5.1.0.aar
    Assets/Plugins/Android/com.google.ads.mediation.unity-3.1.0.0.aar
    Assets/Plugins/Android/com.google.android.gms.play-services-ads-18.0.0.aar
    Assets/Plugins/Android/com.google.android.gms.play-services-ads-base-18.0.0.aar
    Assets/Plugins/Android/com.google.android.gms.play-services-ads-identifier-17.0.0.aar
    Assets/Plugins/Android/com.google.android.gms.play-services-ads-lite-18.0.0.aar
    Assets/Plugins/Android/com.google.android.gms.play-services-basement-17.0.0.aar
    Assets/Plugins/Android/com.google.android.gms.play-services-gass-18.0.0.aar
    Assets/Plugins/Android/com.google.android.gms.play-services-measurement-base-17.0.0.aar
    Assets/Plugins/Android/com.google.android.gms.play-services-measurement-sdk-api-17.0.0.aar
    Assets/Plugins/Android/com.google.zxing.core-3.3.3.jar
    Assets/Plugins/Android/com.parse.bolts.bolts-android-1.4.0.jar
    Assets/Plugins/Android/com.parse.bolts.bolts-applinks-1.4.0.jar
    Assets/Plugins/Android/com.parse.bolts.bolts-tasks-1.4.0.jar
    Assets/Plugins/Android/com.unity3d.ads.unity-ads-3.1.0.aar

      <settings>
        <setting name="androidAbis" value="armeabi-v7a,x86" />
        <setting name="bundleId" value="com.pratyaksh.cosmicballs" />
        <setting name="explodeAars" value="True" />
        <setting name="gradleBuildEnabled" value="True" />
        <setting name="gradleTemplateEnabled" value="False" />
        <setting name="installAndroidPackages" value="True" />
        <setting name="packageDir" value="AssetsPluginsAndroid" />
        <setting name="patchAndroidManifest" value="True" />
        <setting name="patchMainTemplateGradle" value="True" />
        <setting name="projectExportEnabled" value="False" />
        <setting name="useJetifier" value="False" />
      </settings>
    </dependencies>
    
  3. Smaller Portions from error log

    CommandInvokationFailure: Gradle build failed.
    E:UnityEditor2019.1.0f2EditorDataPlaybackEnginesAndroidPlayer/ToolsOpenJDKWindowsbinjava.exe -classpath “E:UnityEditor2019.1.0f2EditorDataPlaybackEnginesAndroidPlayerToolsgradlelibgradle-launcher-4.6.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “assembleRelease”
    stderr[
    D8: Program type already present: android.support.customtabs.ICustomTabsCallback
    FAILURE: Build failed with an exception.

    • What went wrong:
      Execution failed for task ‘:transformDexArchiveWithExternalLibsDexMergerForRelease’.
      com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:

.
.
//SHORTENED FOR STACKOVERFLOW
.
.
.

:transformClassesWithDexBuilderForRelease
C:UsersTehBlindNutSack.gradlecachestransforms-1files-1.1facebook-android-wrapper-7.17.0.aar4bb1132b85935d425bf3b80edd9162a8jarsclasses.jar: D8: Interface com.facebook.applinks.AppLinkData$CompletionHandler not found. It’s needed to make sure desugaring of com.facebook.unity.FB$2 is correct. Desugaring will assume that this interface has no default method.
C:UsersTehBlindNutSack.gradlecachestransforms-1files-1.1facebook-android-wrapper-7.17.0.aar4bb1132b85935d425bf3b80edd9162a8jarsclasses.jar: D8: Type
com.facebook.applinks.AppLinkDatawas not found, it is required for default or static interface methods desugaring ofvoid com.facebook.unity.FB.FetchDeferredAppLinkData(java.lang.String)`
:transformDexArchiveWithExternalLibsDexMergerForRelease FAILED

Please, if someone could help me get it right, it would mean a world to me.
Sorry for bad formatting.

Edit: Steps to reproduce:
1. Create a new Unity(2019.1.0f2) Project with android build support
2. Add FB SDK
3. add GoogleMobileAds SDK
4. Build

3

Answers


  1. Chosen as BEST ANSWER

    I have a good news and a bad news.

    Bad news First: None of the above solutions worked for me.

    Good News: I installed 2019.1.08f and it threw the same error, but with a longer log. I went through the log and found the exact files causing the collision: androidx.browser.browser-1.0.0.aar and androidx.core.core-1.0.0.aar. I just went into them, opened Classes.jar and deleted Android directory in both the aars' jars.

    Build and Run...Voila. (At least for now).

    Will update here if another issue arises.

    Thank you Brian, for Taking the time to test it and answering the question.


  2. enter image description here

    I found solutions. there are library files duplicates, see directory and see library files make it as I did. Android and iOS library should be set for each platform.

    1. Download SDK from “https://developers.facebook.com/docs/unity/

    2. Open SDK directory. there are duplicates. So make a library for each platform.

    3. Set proper platform for iOS and Android.

    It works and I tested on Unity 2019.1.0f2. facebookSDK has problem with compile. they made trap.

    Login or Signup to reply.
  3. When you’re using GooglePlayResolver you’ll be getting new androidx. files. Which could be in conflict with com.android.support. files

    Try to do this:

    Assets -> GooglePlayResolver -> Android Resolver -> Settings -> Set Jetiffier On
    Force Resolve.
    

    Be sure to use the latest:
    https://github.com/googlesamples/unity-jar-resolver/releases/tag/v1.2.121

    Check this discussion for more info.
    https://github.com/googlesamples/unity-jar-resolver/issues/145

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search