Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Admob Unity Package that work with Unity 3.2 above

Discussion in 'Android' started by MicroEyes, Mar 8, 2013.

?

Are you Satisfy with this Plugin Tutorial

  1. Yes

    66.7%
  2. No

    8.0%
  3. Not Completely

    25.3%
  1. Totalschaden

    Totalschaden

    Joined:
    Dec 14, 2013
    Posts:
    28
    No they don't.
     
  2. AndreasC

    AndreasC

    Joined:
    Feb 12, 2013
    Posts:
    31
    Hey !

    I'm having an issue with my publisher ID on Admob, what ID should I really put in into the Unity plugin ?
    I'm using the new Admob, and there are an ad unit ID and my publisher ID.
    My publisher ID starts with "pub-" and my ad unit ID starts of with "ca-app-pub-", which one should I use ?
    I tried both, neither worked.

    Thanks !
     
  3. Totalschaden

    Totalschaden

    Joined:
    Dec 14, 2013
    Posts:
    28
    You use it like xxx/xxx (pubID/adID) still i would not recomment using this "Plugin" before the call Device ID is removed.
     
  4. AndreasC

    AndreasC

    Joined:
    Feb 12, 2013
    Posts:
    31
    Tried putting "pubID/adID", still no luck.
     
  5. Totalschaden

    Totalschaden

    Joined:
    Dec 14, 2013
    Posts:
    28
    I just had another look into the Plugin, it seems the Testads do not work, so i think that you call the Device_ID because you think its used for the check for TestDeviceID to provide test Ads ? The check for test ads uses Android_ID not the Device ID.

    If that was the case please change it. This should help:
    String android_id = Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
    String deviceId = md5(android_id).toUpperCase();

    This should work without Read_Phone_State Permission, so you can remove that too.
     
  6. Totalschaden

    Totalschaden

    Joined:
    Dec 14, 2013
    Posts:
    28
    you should add it without the ca-app-pub, like 2351104815749318/2130441953 should work
     
  7. AndreasC

    AndreasC

    Joined:
    Feb 12, 2013
    Posts:
    31
    Done that, still there is no ad showing up.
    Thanks for the help btw.
     
  8. Totalschaden

    Totalschaden

    Joined:
    Dec 14, 2013
    Posts:
    28
    did you tryed it on the phone ? because on the engine they wont show up
     
  9. vARDAmir

    vARDAmir

    Joined:
    Jun 30, 2013
    Posts:
    38
    i'm using ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxx and it's work perfect

    p.s.
    my admob sdk version is 6.4.1
     
  10. AndreasC

    AndreasC

    Joined:
    Feb 12, 2013
    Posts:
    31
    Tried on a emulator, gonna try on my android device now.
     
  11. AndreasC

    AndreasC

    Joined:
    Feb 12, 2013
    Posts:
    31
    Alright, gonna try with that, thanks :).
     
  12. AndreasC

    AndreasC

    Joined:
    Feb 12, 2013
    Posts:
    31
    Thank you so much vARDAmir ! It worked :)
    Also thank you Totalschaden for the help :)
     
  13. vARDAmir

    vARDAmir

    Joined:
    Jun 30, 2013
    Posts:
    38
    you are welcome
    glad to hear that I was useful=)
     
  14. murat13

    murat13

    Joined:
    Feb 1, 2013
    Posts:
    6
    How i use Admob Interstitials with plugin?
     
  15. bobbylee

    bobbylee

    Joined:
    Aug 15, 2013
    Posts:
    42
    Thank you MicroEyes! and the others helping here.
    I spent 20 bucks on an asset that was harder to control and had less features.
    Had this up and running in no time!

    Unity 4.3.1f1 and GoogleAdMobAdsSdk-6.4.1.jar
     
    Last edited: Dec 19, 2013
  16. ABEMOS

    ABEMOS

    Joined:
    Sep 26, 2013
    Posts:
    5
    I still can not get the banner to hide/disable when loading a different scene!
    I am new to Unity so I appreciate all the help I have been getting here. Reading through this thread I was able to get my banners to show and everything. However, I want the banner to disappear when I go back to the main menu and I can not figure this out! any help will be greatly appreciated.
    Note: my code is all Javascript, so I am having trouble calling functions from the C# script of the banner. I also tried to Destroy the object on scene Load with no success, any suggestions?!
     
  17. vARDAmir

    vARDAmir

    Joined:
    Jun 30, 2013
    Posts:
    38
    Try to use "show/hide" function. I have no problems with it
     
  18. maungers

    maungers

    Joined:
    Dec 16, 2013
    Posts:
    32
    Good day. Thanks for the plug.

    Trying to use your plugin together with google-play-services-plugin https://github.com/playgameservices/play-games-plugin-for-unity

    There is a conflict google-play-services and GoogleAdMobAdsSdk-6.4.1.

    google-play-serves.jar is in the folder Assets \ Plugins \ Android \ google-play-services_libelibs
    GoogleAdMobAdsSdk-6.4.1.jar is in the folder Assetsepluginseandroid

    In the console says: Error building Player: CommandInvokationFailure: Unable to convert classes into dex format.

    The problem duplicating classes. Can I get around this? Can you adapt your plugin to work in conjunction with google-play-services.
     
  19. mntcarp

    mntcarp

    Joined:
    Dec 12, 2011
    Posts:
    25
    Hi everyone!
    First of all, I wanna thank MicroEyes for this plugin, it's really handy and useful for me. You'll definitely be on the credits, if I someday release the game I'm working on. :D
    Now I'm having an issue with testing the ad, when I test the game in the BlueStacks emulator the ad shows up, so I can click on it and then opens the webpage or whatever it is. But when I test the build in my device, it shows up fine, but it doesn't seem to respond to my touch. I'm a little lost here, if someone could help me, I appreciate it.
    Thank you all!

    PS: I'm using Unity 4.3 and already made the AndroidManifest change mentioned.
    PS2: Sorry for my English.

    EDIT: Nevermind. I rebuilded and reinstalled it and now it magically works. Thanks.
     
    Last edited: Jan 9, 2014
  20. Stn

    Stn

    Joined:
    Oct 29, 2013
    Posts:
    1
    thank MicroEyes this is a good plugin

    how can i know the player click the Ad or not
     
  21. przem997

    przem997

    Joined:
    Dec 10, 2012
    Posts:
    80
    This works perfectly with function "show, hide, disable, enable":
    AdvertisementHandler.HideAds();

    but how change position Ads when is running?
    AdvertisementHandler.Adv_Bottom(); - not works

    How change position from my script?
     
    Last edited: Jan 13, 2014
  22. christides11

    christides11

    Joined:
    May 19, 2012
    Posts:
    667
    I can confirm I'm having the same problem. It's a annoying one at that.
     
  23. eze_devarg

    eze_devarg

    Joined:
    Jan 21, 2014
    Posts:
    5
    my error is

    Exception: JNI: Init'd AndroidJavaClass with null ptr!
    UnityEngine.AndroidJavaClass..ctor (IntPtr jclass) (at C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Export/AndroidJavaImpl.cs:539)
    UnityEngine.AndroidJavaObject.get_JavaLangClass () (at C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Export/AndroidJavaImpl.cs:517)
    UnityEngine.AndroidJavaObject.FindClass (System.String name) (at C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Export/AndroidJavaImpl.cs:508)
    UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) (at C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Export/AndroidJavaImpl.cs:528)
    UnityEngine.AndroidJavaClass..ctor (System.String className) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/AndroidJava.cs:92)
    AdvertisementHandler.Instantiate (System.String pubID, AdvSize advSize, AdvOrientation advOrient, Position position_1, Position position_2, Boolean isTesting, System.String testDeviceId, AnimationInType animIn, AnimationOutType animOut, LevelOfDebug levelOfDebug) (at Assets/Scripts/Mics/Advertisement/AdvertisementHandler.cs:87)
    AdvertisementManager.Start () (at Assets/Scripts/Mics/Advertisement/AdvertisementManager.cs:167)
     
  24. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309

    Hi eze_devarg ,
    You are trying in Unity Editor. This plugin isn't meant for Unity Editor.
    Please try in Android device.
     
  25. eze_devarg

    eze_devarg

    Joined:
    Jan 21, 2014
    Posts:
    5

    I have many problems with admob plugin. please look at your private message .. you send my mail to show my problems. achievement not make it work please help.
    i have very much errors!! and have 3 games oks for up in google play :(
     
  26. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    '
    Hi eze_devarg ,
    Sorry, but i didn't received any Private Message from you, i checked. Please re-send me your List of problems getting from this plugin. I'll try to resolve ASAP.

    Thanks for using this plugin.
     
  27. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    298
    I am curios about this show / hide functions.

    What does realy HIDE do ?
    - Is this just hides the view while still showing ads invisibly ?
    - Is this stop receiving ads from Admob servers, and activates again when we use show ?

    I need to know this, if it is only hides the view visibility we will be wasting millions of impressions without chance of clicks. :)
     
  28. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309

    Hi MoribitoMT,
    Thanks for your interest in plugin.

    Yes. Hide() function just hides Ads Visibility container, but google admob plugin will keep requesting for Ads.
    To Disable ads, call Disable() function. Disable() function actually stop requesting ads from google admob server.
     
  29. Jokerzv

    Jokerzv

    Joined:
    Jan 30, 2014
    Posts:
    2
    Sorry, all works!
     
    Last edited: Jan 30, 2014
  30. Giaosuta

    Giaosuta

    Joined:
    Feb 1, 2014
    Posts:
    1
    i'm looking for interstitial. thank anyway! you've done a great job.
     
  31. bobbylee

    bobbylee

    Joined:
    Aug 15, 2013
    Posts:
    42
    Am I correct that "READ_PHONE_STATE" is only needed for testing mode?
    Thanks.
     
  32. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    Hi bobbylee,
    Yes, It should only work for testing mode. But there is a bug which makes 'READ_PHONE_STATE' permission compulsory to have. But i am using only to get device ID for adding device to Google Admob server for testing.
     
  33. demilp

    demilp

    Joined:
    Dec 6, 2012
    Posts:
    4
    I'm having an error in line 89 of AdevertisementHandler which seems to unchain some other errors in line 90 and 100.

    JNI: Unable to find field id for 'currentActivity' (static)
    UnityEngine.AndroidJavaObject:GetStatic(String)
    AdvertisementHandler:Instantiate(String, AdvSize, AdvOrientation, Position, Position, Boolean, String, AnimationInType, AnimationOutType, LevelOfDebug) (at Assets/Scripts/Mics/Advertisement/AdvertisementHandler.cs:89)
    AdvertisementManager:Start() (at Assets/Scripts/Mics/Advertisement/AdvertisementManager.cs:169)
     
  34. FabrizioSpadaro

    FabrizioSpadaro

    Joined:
    Jul 10, 2012
    Posts:
    276
    How can i change the position of the banner via script?
     
  35. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    Hi belva1234,
    You can change initially from inspector. But you can't change at Runtime.
     
  36. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309

    Hi demilp,
    Are you trying to run this plugin in Editor? This plugin only meant to provide Ads in Android Device.
     
  37. POLYGAMe

    POLYGAMe

    Joined:
    Jan 20, 2009
    Posts:
    196
    Ooooh, this looks awesome. Downladed, will attempt to incorporate into my project tomorrow... no doubt I'll have all sorts of issues, as I have the C# coding ability of a rabbit.
     
  38. castielblak

    castielblak

    Joined:
    May 1, 2013
    Posts:
    3
    Hi. I have a little problem with this.
    When my game is playing without ads its fps is 59-61, but when my game is playing with ads, its fps is 39-41.
    What can i do for fix?
     
  39. Sindorej

    Sindorej

    Joined:
    Dec 6, 2013
    Posts:
    10
    Great! just great! After 5 hours of work and 1 paid plugin i found this and after 5min it was working. Just thanks!
     
  40. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    Hi Castielblak,
    This is a weird issue. Can you tell me, which Version of Unity Admob SDK are you using?
     
  41. sunny8751

    sunny8751

    Joined:
    Jul 15, 2013
    Posts:
    3
    Does this thread work with the new Google Play Services version of Admob? Also, I am having trouble filling in the variables. For publisher id, do I put in the id starting with pub- 7....? Also, is the test device id variable the same as the app unit id? Thanks!

    UPDATE: Never mind, I got the ads to show up. However, it appears that this plugin does not run together with the google play services plugin in https://github.com/faizann/UnityGPGPlugin. I followed your directions to change the variable in the manifest file to true. Is there a solution to this problem? Thanks.
     
    Last edited: Feb 15, 2014
  42. Goliath520

    Goliath520

    Joined:
    Nov 24, 2012
    Posts:
    4
    First of all, awesome plugin, I used the previous version and it seemed to work pretty well. I seem to be having a few problems with this version however.

    1. Firstly when I try to enable ads or show them, nothing seems to work. I get an error in the editor and when I test it on a device, I press the buttons and nothing appears. I didn't touch any of the code, only the position on the screen.

    Edit: This is the error I was getting in the editor.
    Code (csharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. AdvertisementHandler.ShowAds () (at Assets/Scripts/Mics/Advertisement/AdvertisementHandler.cs:133)
    3. AdvertisementManager.OnGUI () (at Assets/Scripts/Mics/Advertisement/AdvertisementManager.cs:33)
    4.  
    2. The same as sunny8751, is the publisher ID the number that starts with pub-XXXXXXXXXXXXXXXXX / XXXXXXXXXX. I am not sure if it is supposed to be in this format or adjusted in someway. Also should the slash and the other stuff after be included?
     
  43. Goliath520

    Goliath520

    Joined:
    Nov 24, 2012
    Posts:
    4
    I don't want to spam but perhaps adding an FAQ to the end of the instructions on the OP would help. I am sure you don't like dealing with the same questions over and over again and its a pain to look for a solution through 15 pages of Q&As.
     
  44. GastonC

    GastonC

    Joined:
    Aug 26, 2012
    Posts:
    28
  45. OlafSk

    OlafSk

    Joined:
    Feb 14, 2014
    Posts:
    2
    Overall the plugin is working great and is really easy in implementation, however i have a weird issue. Whenever ads appear on screen the background of the screen goes dark. Buttons are visible, but it is a problem for me. If u could post a solution i would be very thankful.
     
  46. Shigidy

    Shigidy

    Joined:
    Dec 14, 2011
    Posts:
    441
    $admob help.png

    I've just started to try and get this working. I imported it and changed the ad mob id to mine, but it is giving me this error. Also i have two advertising managers in one scene, I don't know if you can tell from the picture or not. I did this because I wanted to see ads on main menu and on score screen, but not on actual play screen. Any help would be greatly appreciated.
     
  47. Eldirfar

    Eldirfar

    Joined:
    Feb 9, 2014
    Posts:
    39
    Thanks for plugin. Every thing seems working :)

    You can't run this pugin in Unity editor mode. I suggest you adding somethink like this for editor

    Code (csharp):
    1. if (Application.platform == RuntimePlatform.Android) {
    2.             AdvertisementHandler.Instantiate (m_publisherId, m_advSize, m_orientation, m_positionOne, m_positionTwo, m_isTesting, m_testDeviceId, m_animationInType, m_animationOutType, m_levelOfDebug);
    3. }
    and for any functions called from AdvertismentHandler, then you don't worry about errors with plugin in editor.

    Also I have one suggestion to improvement plugin to handling state if it is instantiated, then you don't need to worry when calling Instantiate() multiple times.
    Code (csharp):
    1.  
    2. public static bool isInstatiated = false;
    3.  
    4.     public static void Instantiate(string pubID, AdvSize advSize, AdvOrientation advOrient, Position position_1, Position position_2, bool isTesting, string testDeviceId, AnimationInType animIn, AnimationOutType animOut, LevelOfDebug levelOfDebug)
    5.     {
    6.         Debug.Log("Instantiate Called");
    7.         if (!isInstatiated) {
    8.             admobPluginClass = new AndroidJavaClass ("com.microeyes.admob.AdmobActivity");
    9.             unityPlayer = new AndroidJavaClass ("com.unity3d.player.UnityPlayer");
    10.             currActivity = unityPlayer.GetStatic<AndroidJavaObject> ("currentActivity");
    11.             admobPluginClass.CallStatic ("AdvHandler", (int)Activity.INSTANTIATE, currActivity, pubID, (int)advSize, (int)advOrient, (int)position_1, (int)position_2, isTesting, testDeviceId, (int)animIn, (int)animOut, (int)levelOfDebug);
    12.             isInstatiated = true;
    13.             Debug.Log ("Instantiate FINISHED");
    14.         } else {
    15.             Debug.Log ("Already Instantiated");
    16.         }
    17.     }

    Also pubId is a bit confusing. PubId means ca-app-pub-XXXXXXXXXXXXXXXX/XXXXXXXXXX (unit add id)

    About testing mode. I have clicked my banner in testing mode to see if is working but Admob have counted this clicks. Admob not allows to click on own ads. Any suggestions to not earn ban on Admob account?

    Hmm does isTesting works? Because I'm receiving real ads instead of testing :(, i have changed the devideID.
     
    Last edited: Feb 15, 2014
  48. HammerBG

    HammerBG

    Joined:
    Mar 30, 2013
    Posts:
    6
    Hello,
    I seem to be having an issue with the plugin:

    Code (csharp):
    1. I/Unity   (20318): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 53)
    2. I/Unity   (20318):
    3. I/Unity   (20318): Instantiate Called
    4. I/Unity   (20318):
    5. I/Unity   (20318): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 53)
    6. I/Unity   (20318):
    7. I/Unity   (20318): AndroidJavaException: java.lang.ClassNotFoundException: com.microeyes.admob.AdmobActivity
    8. I/Unity   (20318):   at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <filename unknown>:0
    9. I/Unity   (20318):   at UnityEngine.AndroidJNISafe.CallStaticObjectMethod (IntPtr clazz, IntPtr methodID, UnityEngine.jvalue[] arg
    10. s) [0x00000] in <filename unknown>:0
    11. I/Unity   (20318):   at UnityEngine.AndroidJavaObject._CallStatic[AndroidJavaObject] (System.String methodName, System.Object[] ar
    12. gs) [0x00000] in <filename unknown>:0
    13. I/Unity   (20318):   at UnityEngine.AndroidJavaObject.CallStatic[AndroidJavaObject] (System.String methodName, System.Object[] arg
    14. s) [0x00000] in <filename unknown>:0
    15. I/Unity   (20318):   at UnityEngine.AndroidJavaObject.FindClass (System.String name) [0x00000] in <filename unknown>:0
    16. I/Unity   (20318):   at UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) [0x00000] in <filename unknown>:0
    17.  
    18. I/Unity   (20318):   at UnityEngine.AndroidJavaClass..ctor (System.String className) [0x00000] in <filename unknown>:0
    19. I/Unity   (20318):   at AdvertisementHandler.Instantiate (System.String pubID, AdvSize advSize, AdvOrien
    20.  
    For some reason unity cannot load the jar file.
    The file is located in the default directory:
    "Assets/Plugins/Android/"

    I am also using this plugin, if it matters:
    https://github.com/playgameservices/play-games-plugin-for-unity

    Any suggestions?
     
    Last edited: Feb 15, 2014
  49. Morichalion

    Morichalion

    Joined:
    Mar 21, 2011
    Posts:
    9
  50. Reizla

    Reizla

    Joined:
    Nov 5, 2013
    Posts:
    136
    Blond question (2 actually :p )

    1. PubId: Your Admob PublisherID/App ID, that's the whole "ca-app-pub-XXXXXXXXXXXXXXXX/XXXXXXXXXX" or do I have to strip some of the 'ca-app-pub-' part of it?
    2. The plugin is working perfectly on Android, but I still have the OnGUI() elements. How to remove those?

    At this moment my game is not yet ready to release, but I'll be there SOON(tm). I'll drop your credits in the game as well, most likely under the start-up logo.

    [EDIT]

    I'm not so blond as I thought. Got both answers figured out myself and the plugin is working perfectly!
     
    Last edited: Feb 16, 2014
unityunity