Search Unity

Can't run Ads on Android.

Discussion in 'Unity Ads & User Acquisition' started by Cal_Mac, Jan 17, 2019.

  1. Cal_Mac

    Cal_Mac

    Joined:
    Feb 4, 2018
    Posts:
    22
    Hi,

    My Game is functioning correctly in Editor, but as soon as I build on Android the Ads never initialize. I've done some investigating and located the error in the Device logs. Any help would be great.

    Ever since I downloaded the Unity from Asset store from the guide from here: https://unity3d.com/services/ads/quick-start-guide

    I have had nothing but issues with it for Android. Any help from anyone would be amazing!


    [ICODE]01-17 15:40:32.624 14402 14432 I Unity   : (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
    01-17 15:40:32.624 14402 14432 I Unity :
    01-17 15:40:33.122 14402 14432 E Unity : Initializing Unity Monetization.
    01-17 15:40:33.122 14402 14432 E Unity :
    01-17 15:40:33.122 14402 14432 E Unity : (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
    01-17 15:40:33.122 14402 14432 E Unity :
    01-17 15:40:33.142 14402 14432 E Unity : AndroidJavaException: java.lang.ClassNotFoundException: com.unity3d.services.monetization.UnityMonetization
    01-17 15:40:33.142 14402 14432 E Unity : java.lang.ClassNotFoundException: com.unity3d.services.monetization.UnityMonetization
    01-17 15:40:33.142 14402 14432 E Unity : at java.lang.Class.classForName(Native Method)
    01-17 15:40:33.142 14402 14432 E Unity : at java.lang.Class.forName(Class.java:453)
    01-17 15:40:33.142 14402 14432 E Unity : at java.lang.Class.forName(Class.java:378)
    01-17 15:40:33.142 14402 14432 E Unity : at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    01-17 15:40:33.142 14402 14432 E Unity : at com.unity3d.player.UnityPlayer.c(Unknown Source:0)
    01-17 15:40:33.142 14402 14432 E Unity : at com.unity3d.player.UnityPlayer$e$2.queueIdle(Unknown Source:72)
    01-17 15:40:33.142 14402 14432 E Unity : at android.os.MessageQueue.next(MessageQueue.java:394)
    01-17 15:40:33.142 14402 14432 E Unity : at android.os.Looper.loop(Looper.java:142)
    01-17 15:40:33.142 14402 14432 E Unity : at com.unity3d.player.UnityPlayer$e.run(Unknown Source:32)
    01-17 15:40:33.142 14402 14432 E Unity : Caused by: java.lang.ClassNotFoundException: Didn't find class "com.unity3d.services.monetization.UnityMonetization" on path: DexPathList[[zip file "/data/app/com.CalMac.EDW-WeUEs9yy4sv1vmzqX5SaKQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.CalMac.EDW-WeUEs9yy4sv1vmzqX5SaKQ==/lib/arm, /data/app/com.CalMac.EDW-WeUEs9yy4sv1vmzqX5SaKQ==/ba
    [/ICODE]
     
  2. Cal_Mac

    Cal_Mac

    Joined:
    Feb 4, 2018
    Posts:
    22
    I had to remove UnityAds.aar from the imported Android folder to get things to work.. but nothing..

    If UnityAds.Aar is in my project then i get the following error...


    CommandInvokationFailure: Gradle build failed. 
    C:/Program Files/Java/jdk1.8.0_161\bin\java.exe -classpath "D:\_Program Files\_Unity\Unity Install\2018.3.0b4\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.6.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

    stderr[
    D8: Program type already present: com.unity3d.ads.BuildConfig

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':transformDexArchiveWithExternalLibsDexMergerForRelease'.
    > com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: D:\_Program Files\_Unity\MobileGame\Extreme Dog Walking\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\12.jar, D:\_Program Files\_Unity\MobileGame\Extreme Dog Walking\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\11.jar, D:\_Program Files\_Unity\MobileGame\Extreme Dog Walking\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\2.jar, D:\_Program Files\_Unity\MobileGame\Extreme Dog Walking\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\3.jar, D:\_Program Files\_Unity\MobileGame\Extreme Dog Walking\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\0.jar, D:\_Program Files\_Unity\MobileGame\Extreme Dog Walking\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\7.jar, D:\_Program Files\_Unity\MobileGame\Extreme Dog Walking\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\1.jar, D:\_Program Files\_Unity\MobileGame\Extreme Dog Walking\Temp\gradleOut\build\intermediates\transforms\dexBuilder\release\8.jar
    Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
    Program type already present: com.unity3d.ads.BuildConfig
     
  3. Cal_Mac

    Cal_Mac

    Joined:
    Feb 4, 2018
    Posts:
    22
    Hold on folks, I think I have it. I enabled Ads via the services and also imported Unity Monetization, Why? I do not know. I need a rubber duck. Please Ignore me, if anyone else gets caught out with this i hope my message helps..
     
  4. DenisasK

    DenisasK

    Unity Technologies

    Joined:
    Oct 13, 2016
    Posts:
    89
    @Cal_Mac
    Hello, please, turn off ads from a service window. Also, remove Ads package from Package Manager and use a package(Unity Monetization 3.0) downloaded from AssetStore. It should fix your issue.
     
  5. Cal_Mac

    Cal_Mac

    Joined:
    Feb 4, 2018
    Posts:
    22
    Hey, Thanks for getting back to me! I eventually solved the problem by getting rid of Unity Monetization 3.0 altogether, it would crash my android device(with the service option off). It seems to be working correctly now and I am using Ads from the service window as directed by the Unity Quick start guide. If this is wrong please let me know.

    I hope this is helpful feedback as a first timer at integrating adverts I found the guides quite contradicting not explaining you should use one method or the other. Then again perhaps I read them wrong. Cheers!
     
    Zaine7673 likes this.
  6. Zaine7673

    Zaine7673

    Joined:
    Feb 15, 2018
    Posts:
    238
    I actually agree with you. I thought the guides were not very helpful for anyone starting off with unity ads .the distinction between unity ads and monetization needs to be made very clear which it currently is not.

    Ive finally managed to get the test ads to show in the editor but they still dont appear on the android device.

    Since ive updated to the new unity 2018 ive been getting errors every single time i import a new sdk. Even from unity plugins. Remote settings gave me a bunch of errors .
     
  7. Zaine7673

    Zaine7673

    Joined:
    Feb 15, 2018
    Posts:
    238

    Hey buddy, would you mind telling me how you managed to get this error report? Looks like its off the device??
     
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Zaine7673 likes this.