Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Admob and Google Play not working together

Discussion in 'Android' started by madflanderz, Feb 9, 2014.

  1. madflanderz

    madflanderz

    Joined:
    Jul 20, 2012
    Posts:
    5
    I want to use this 2 plugins:

    Admob:
    https://code.google.com/p/google-mobile-dev/downloads/detail?name=UnityPlugin_Android_1.0.zip

    Google Play:
    https://github.com/playgameservices/play-games-plugin-for-unity

    Each plugin alone runs fine. But when i try to use them both then i got this error:

    Code (csharp):
    1.  
    2. Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
    3. /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/bin/java -Xmx1024M -Dcom.android.sdkmanager.toolsdir="/Users/lnmedia/Development/adt-bundle-mac-x86_64-20131030/sdk/tools" -Dfile.encoding=UTF8 -jar "/Applications/Unity/Unity.app/Contents/BuildTargetTools/AndroidPlayer/sdktools.jar" -
    4.  
    5. stderr[
    6.  
    7. UNEXPECTED TOP-LEVEL EXCEPTION:
    8. java.lang.IllegalArgumentException: already added: Lcom/google/ads/AdRequest$Gender;
    9.     at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
    10.     at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
    11.     at com.android.dx.command.dexer.Main.processClass(Main.java:685)
    12.  
    The problem is that the play-games library now contains also the AdMob classes. Is it possible somehow to delete the duplicate classes in the JAR file? Or is here anyone who have another solution and is using admob and play services together? I want to avoid to write my own plugin, i just want to use existing ones if possible.

    Thanks and have a nice day.
     
    IAmBurtBot and NickP_2 like this.
  2. madflanderz

    madflanderz

    Joined:
    Jul 20, 2012
    Posts:
    5
  3. mikhail111777

    mikhail111777

    Joined:
    Feb 8, 2013
    Posts:
    84
    AdMob is now a part of Google Play Game Services.
     
  4. Rustam-Ganeyev

    Rustam-Ganeyev

    Joined:
    Jul 18, 2011
    Posts:
    29
    could you share your repacked jar, please?
     
  5. Rustam-Ganeyev

    Rustam-Ganeyev

    Joined:
    Jul 18, 2011
    Posts:
    29
    I extracted google-play-services.jar and deleted ads folder. After that ads were ok, but playgameservices plugin started to send me weird exceptions:

    Code (csharp):
    1. 02-12 05:15:14.099: I/Unity(13953): [Play Games Plugin DLL] GHM creating GameHelper.
    2. 02-12 05:15:14.099: I/Unity(13953):  
    3. 02-12 05:15:14.099: I/Unity(13953): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 53)
    4. 02-12 05:15:14.309: I/Unity(13953): AndroidJavaException: java.lang.ClassNotFoundException: com.google.example.games.basegameutils.GameHelper
    5. 02-12 05:15:14.309: I/Unity(13953):   at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <filename unknown>:0
    6. 02-12 05:15:14.309: I/Unity(13953):   at UnityEngine.AndroidJNISafe.CallStaticObjectMethod (IntPtr clazz, IntPtr methodID, UnityEngine.jvalue[] args) [0x00000] in <filename unknown>:0
    7. 02-12 05:15:14.309: I/Unity(13953):   at UnityEngine.AndroidJavaObject._CallStatic[AndroidJavaObject] (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0

    I didn't delete GameHelper so it class must be there. Did anybody meet that strange behaviour?
     
  6. ariyalion

    ariyalion

    Joined:
    Feb 15, 2014
    Posts:
    19
    Hi I have hit the same issue.. Did you find a solution?
     
  7. friiky

    friiky

    Joined:
    Nov 10, 2013
    Posts:
    2
    hi,

    even if it is a little late. I had the same issue a few days ago. Here the repacked lib. (I had to add an empty .txt to the archiv, because I was not able to pack it in a .zip otherwise ;) )


    Regards
    Kalle
     

    Attached Files:

    • $lib.zip
      File size:
      1.2 MB
      Views:
      1,100
  8. izazhaque

    izazhaque

    Joined:
    Mar 29, 2014
    Posts:
    5
    Hi Kalle, i tried your zip but it din show leaderboards... so i made changes to my own play-services.jar file...
    Here is the file unzip and just replace default with this file in Assets\Plugins\Android\google-play-services_lib\libs and it will work.
     

    Attached Files:

    LuFIDA likes this.
  9. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,663
  10. izazhaque

    izazhaque

    Joined:
    Mar 29, 2014
    Posts:
    5

    Do as i say and it will work like a charm...
    Assuming you already have the proper unity plugins for admob and play services.
    1) Import both and do the required.
    2) Now go to Plugin and search for google-play-services.jar file
    3) Do not unzip google-play-services.jar goinside it using services like 7-zip or winrar.
    4) Go inside that and search for ads folder and delete it.(I am at office so m not sure of its Directory)
    5) Delete ads folder.
     
    GladGoblinGames likes this.
  11. Arpit Rastogi

    Arpit Rastogi

    Joined:
    Sep 2, 2014
    Posts:
    2
    Hi, i solved this problem.

    Implement admob unity plugin to sample project first which includes creating adactivity.jar file from eclipse. [Reference video :
    ]

    Now in your main project implement unity leaderboard official plugin first and make it working after adding the application id successfully. [https://github.com/playgameservices/play-games-plugin-for-unity]

    1. After implementing it, simply add GoogleMobileAdsDemoScript.cs in your Asset folder from sample admob project (e.g. HelloWorld from admob plugin example)

    2. Add GoogleMobileAds folder from sample admob project to Asset folder of working project

    3. Now add AndroidManifest file from sample project following folder C:..Project folder\Assets\Plugins\Android to the respective folder of your main project

    4. Add GoogleMobileAdsPlugin folder to C:..Project folder\Assets\Plugins\Android

    5. Now add adactivity.jar from your sample project's libs folder C:..Project folder\Assets\Plugins\Android\google-play-services_lib\libs to your main project respective libs folder.
    And it works that way. Hope it helps.
     
  12. hameed-ullah-jan

    hameed-ullah-jan

    Joined:
    Sep 24, 2014
    Posts:
    7
    Maybe it's too late to answer, I was facing the same issue, I created a plugin this plugin contains Facebook SDK+Admob+unityads +unity IAP, all of them work together, I've created this plugin in unity 5.6.0, but I've checked it, it is working fine in unity 2017 as well, there is a scene "DemoScene", just open it everything is implemented, unity ads, admob, facebook share with callback, unityIAP.

    Note: before importing the plugin kindly delete all the old plugins, also go to services and turn on unity ads.
    http://www.mediafire.com/file/ccvj7...UnityAds_Plugin_Hameed_Ullah_jan.unitypackage