Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    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. Reizla

    Reizla

    Joined:
    Nov 5, 2013
    Posts:
    136
    What's the minimum Android version requirement for this plugin anyway? The one Google has made has a minimum of Android version 3.2 (or 3.3). Does your plugin work with ANY version of Android, as long as Unity can compile it?
     
  2. Jeremie-Weldin

    Jeremie-Weldin

    Joined:
    Feb 16, 2014
    Posts:
    4
    Is there any update on this? It would be great to be able to use ads AND leaderboards :)
     
  3. Simon_says

    Simon_says

    Joined:
    Oct 19, 2013
    Posts:
    141
    I'm having a problem with the publisher id... I'm using the unity 4.3 and ads sdk 6.4.1, I've set my id like this ca-app-pub-XXXXXXXXXXXXXXXX/XXXXXXXXXX and even like this XXXXXXXXXXXXXXXX/XXXXXXXXXX yet nothing worked... old 15 char id works...

    Those who faced the same problem, could you tell me how to make it working? Thanks.
     
  4. overfile

    overfile

    Joined:
    Oct 21, 2013
    Posts:
    27
    Your Package is amazing! Well, I posted my game with your Package, of course show up in credits, D, you can see how it looks Here.

    $imagen1.jpg

    For Spanish (a friend asked me) I made a tutorial on how to use the package, you can see it Here. Kind regards!

     
    Last edited: Feb 16, 2014
  5. Jeremie-Weldin

    Jeremie-Weldin

    Joined:
    Feb 16, 2014
    Posts:
    4
  6. Jeremie-Weldin

    Jeremie-Weldin

    Joined:
    Feb 16, 2014
    Posts:
    4
  7. Reizla

    Reizla

    Joined:
    Nov 5, 2013
    Posts:
    136
    Have tried to get it working today myself. Here's the code I used:

    Code (csharp):
    1.  
    2.         #if UNITY_ANDROID
    3.         AdvertisementHandler.Instantiate("ca-app-pub-XXXXXXXXXXXXXXXX/XXXXXXXXXX",
    4.                                          AdvertisementHandler.AdvSize.SMART_BANNER,
    5.                                          AdvertisementHandler.AdvOrientation.HORIZONTAL,
    6.                                          AdvertisementHandler.Position.BOTTOM,
    7.                                          AdvertisementHandler.Position.FILL_HORIZONTAL,
    8.                                          false,
    9.                                          "E83D20734F72FB3108F104ABC0FFC738",
    10.                                          AdvertisementHandler.AnimationInType.NO_ANIMATION,
    11.                                          AdvertisementHandler.AnimationOutType.NO_ANIMATION,
    12.                                          AdvertisementHandler.LevelOfDebug.NONE);
    13.         AdvertisementHandler.EnableAds();
    14.         #endif
    15.  
    [EDIT]
    Wrong word of choice 'tried to get it working' - it is working :D
     
  8. Jeremie-Weldin

    Jeremie-Weldin

    Joined:
    Feb 16, 2014
    Posts:
    4
    If you want to use this plugin along with the Play Game Services plugin, then you need to do the following:
    1.) Unzip the google-play-services.jar file.
    2.) Delete the com/google/ads directory.
    3.) Delete the com/google/android/gms/ads directory.
    4.) Using command line or terminal, change into the unzipped directory.
    5.) Run the command 'jar -cfv google-play-services.jar *'
    6.) Replace the copy of google-play-services.jar in your Unity project with the newly created one.
    7.) Profit
     

    Attached Files:

    Last edited: Feb 16, 2014
  9. Simon_says

    Simon_says

    Joined:
    Oct 19, 2013
    Posts:
    141
    Anyone? I'm about to publish my game but I can't until I make this working...
     
  10. Reizla

    Reizla

    Joined:
    Nov 5, 2013
    Posts:
    136
    Look 3 replies up ;-)
     
  11. Simon_says

    Simon_says

    Joined:
    Oct 19, 2013
    Posts:
    141
    When using my ca-app-pub unit ID I can't see my ads when I run it, but in admob it says that ads were requested from my country( http://i.imgur.com/LnbDNuT.jpg ), also ads are shown if I change my IP to russian or so, why is that so? When I'm using the pub id given in this plugin I can see ads(I'm from Croatia)
     
  12. Reizla

    Reizla

    Joined:
    Nov 5, 2013
    Posts:
    136
    When I activated my Admob account, there was a list of countries that were 'supported' by Admob. You're sure that Croatia is on that list? Further more, I think the problem is clearly not the script since on a Russian IP you're getting the ads. Perhaps you should contact Admob support about your issue?
     
  13. remingtonchan

    remingtonchan

    Joined:
    May 10, 2013
    Posts:
    3
    Just have to ask, what's the attachment for? Is that the result of the process above?
     
  14. Simon_says

    Simon_says

    Joined:
    Oct 19, 2013
    Posts:
    141
    When I call for EnableAds() my fps in game suddenly drops on 5 for a few seconds, same as calling DisableAds(). Am I missing something and is there some way to optimize it?
     
  15. Shory90

    Shory90

    Joined:
    Jul 30, 2013
    Posts:
    3
    Reizla


    #if UNITY_ANDROID

    AdvertisementHandler.Instantiate("ca-app-pub-XXXXXXXXXXXXXXXX/XXXXXXXXXX",

    AdvertisementHandler.AdvSize.SMART_BANNER,

    AdvertisementHandler.AdvOrientation.HORIZONTAL,

    AdvertisementHandler.Position.BOTTOM,

    AdvertisementHandler.Position.FILL_HORIZONTAL,

    false,

    "E83D20734F72FB3108F104ABC0FFC738",

    AdvertisementHandler.AnimationInType.NO_ANIMATION,

    AdvertisementHandler.AnimationOutType.NO_ANIMATION,

    AdvertisementHandler.LevelOfDebug.NONE);

    AdvertisementHandler.EnableAds();

    #endif



    where did you put that code?
     
    Last edited: Feb 18, 2014
  16. whistler

    whistler

    Joined:
    Apr 15, 2013
    Posts:
    15
    Hi there,

    first of all I really thank for this package.

    But why do we need telephone state permission?
    "<uses-permission android:name="android.permission.READ_PHONE_STATE"/>"

    I got a lot of complaits for this permission request. Even this permission request alone "alienate" people, they become paranoid and they do give up an dont install our apps.

    I tried removing "<uses-permission android:name="android.permission.READ_PHONE_STATE"/>" in android manifest file, but my application stops afterwards.

    I have to remove this permission because people do afraid because of this permission,
    A quick search on google can prove this also.

    have a look at these links:

    https://play.google.com/store/apps/details?id=jp.ne.neko.freewing.ReadPhoneState&hl=en

    and especially here :
    http://android.stackexchange.com/qu...-permission-to-read-the-phone-state-and-ident

    "Google Play policy now forbids apps from getting your IMEI to identify you for advertising purposes. All the ad libraries have been updated now to use the Google-Play-Services-provided "advertising ID", so any that still use the IMEI for this purpose should be reported to Google."


    I dont want to be banned from google : )

    since there are tons of application which use admob and they dont need this telephone.state permission. so why do we need that permission?

    people get paranoid and our application downloads suffer hugely for this permission request.

    can we remove that "android.permission.READ_PHONE_STATE" for good?
     
    Last edited: Feb 19, 2014
  17. Reizla

    Reizla

    Joined:
    Nov 5, 2013
    Posts:
    136
    In my main game script under Start(). The Instantiate() should only be called once, and that's why I put it there (could also drop it under Awake() though)

    The AdvertisementHandler.EnableAds() can be put everywhere, but because I'm not toggling ads on/off, I dropped it directly under the Instantiate().
     
  18. tezt

    tezt

    Joined:
    Oct 19, 2013
    Posts:
    1
    I'm having strange issue when using this plugin. I'm trying to implement pausing/resuming in my game by using OnApplicationPause and it seems to work fine if I comeback to the game through list of recent apps (on Android) but when I click on the icon through home screen it relaunches the game instead of resuming. I tried to remove your plugin and it works fine. Is there any solution for that ?
     
  19. Shory90

    Shory90

    Joined:
    Jul 30, 2013
    Posts:
    3
    thanks Rezila
    i have the id only with pub-XXXXXXXXXXXXXXXX
    is not like yours "ca-app-pub-XXXXXXXXXXXXXXXX/XXXXXXXXXX"
    cand this be a problem because it didnt show the ads.
    I want to tell that i dont know where to find my test device ID. Can this be a problem? if YES, where i can find this ID
    thanks a lot
     
  20. Reizla

    Reizla

    Joined:
    Nov 5, 2013
    Posts:
    136
    First the test device. That's in the code I posted, right under false. When using the test device you have to chance false to true as well (that's the testing toggle).

    Then the ca-app-pub... thing. the pub-... you have is on your general Admob account (upper right on my screen). On the ad you make you should find the ca-app-pub... identifier (under menu All apps -> YourGame)..
     
  21. castielblak

    castielblak

    Joined:
    May 1, 2013
    Posts:
    3
    Version of Unity : 4.3.0f4
    AdmobSDK : 6.3.0
     
  22. demilp

    demilp

    Joined:
    Dec 6, 2012
    Posts:
    4
    Is it possible that my publisher ID is 16 characters and all numbers?
     
  23. itsboshytime

    itsboshytime

    Joined:
    Jan 10, 2014
    Posts:
    6
    Hey there. Plugin is working great. Only issue is the read phone state one? Any way to diable it without crashing my game? Removing it from manifest crashes the game.

    Thanks!
     
  24. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    You should put ca-app-pub-XXXXXXXXXXXXXXXX/NNNNNNNNNN.
     
  25. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    Hey,
    Yeah thats a bug. I am going to fix this in next version. For now its harmless. I am using it to get Device ID @ runtime.
     
  26. Reizla

    Reizla

    Joined:
    Nov 5, 2013
    Posts:
    136
    I love your plugin MicroEyes. At least yours works with 2D toolkit, while the official AdMob plugin from Google doesn't.

    Any chance for an iOS version any time soon?
     
  27. whistler

    whistler

    Joined:
    Apr 15, 2013
    Posts:
    15

    Pleaseeee fix this :(

    It really matters, and it is really harmful. People do scare and dont install our apps because of this permission request.



    here is what I wrote about this issue on page 16 of this thread:


    that is really important.

    thank you very much in adv.
     
  28. Tayfe

    Tayfe

    Joined:
    Nov 21, 2011
    Posts:
    71
    First: Thank you for this plugin and for sharing it for free! I made a new game and now im trying to use it :)

    But i have an issue: Are you using a GUI.Matrix? Since i installed the plugin my buttons are placed very strange and i have no idea why. Before i used your plugin the GUI worked fine. Maybe you have got an idea how i could solve this problem? Everything else works fine so far :)

    Oh and there is another question: Some people claim that there arent adds in every scene so that they should DontDestroyOnLoad(). My problem is just the other way around: I have two scenes and added the prefab to the first but there are adds in the second scene as well and i have problems removing them ...
     
    Last edited: Feb 21, 2014
  29. Eldirfar

    Eldirfar

    Joined:
    Feb 9, 2014
    Posts:
    41
    Just call Disable ads before loading new scene.
     
  30. Simon_says

    Simon_says

    Joined:
    Oct 19, 2013
    Posts:
    141
    When I call for EnableAds() my fps in game suddenly drops on 5 for a few seconds, same as calling DisableAds(). Am I missing something and is there some way to optimize it?
     
  31. Tayfe

    Tayfe

    Joined:
    Nov 21, 2011
    Posts:
    71
    Thank you, i will do so!

    But i just noticed another issue: I added AdvertisementHandler.EnableAds() into my start-function and 2 of 3 buttons disappeared and the positioning changed as well. So now i have even more positioning problems in my GUI ...
     
  32. aixaix

    aixaix

    Joined:
    May 7, 2010
    Posts:
    523
    Ok, this problem might have already been in th ecomments, but i'm getting this error as i start the game

    Code (csharp):
    1.  
    2. Exception: JNI: Init'd AndroidJavaClass with null ptr!
    3. UnityEngine.AndroidJavaClass..ctor (IntPtr jclass) (at C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Export/AndroidJavaImpl.cs:539)
    4. UnityEngine.AndroidJavaObject.get_JavaLangClass () (at C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Export/AndroidJavaImpl.cs:517)
    5. UnityEngine.AndroidJavaObject.FindClass (System.String name) (at C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Export/AndroidJavaImpl.cs:508)
    6. UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) (at C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Export/AndroidJavaImpl.cs:528)
    7. UnityEngine.AndroidJavaClass..ctor (System.String className) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/AndroidJava.cs:92)
    8. 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)
    9. AdvertisementManager.Start () (at Assets/Scripts/Mics/Advertisement/AdvertisementManager.cs:167)
    10.  
    And when i click Enable on the buttons that appear on the screen, it'll tell me this:
    Code (csharp):
    1.  
    2. NullReferenceException: Object reference not set to an instance of an object
    3. AdvertisementHandler.EnableAds () (at Assets/Scripts/Mics/Advertisement/AdvertisementHandler.cs:100)
    4. AdvertisementManager.OnGUI () (at Assets/Scripts/Mics/Advertisement/AdvertisementManager.cs:16)
    5.  
     
  33. sokolmkd

    sokolmkd

    Joined:
    Feb 20, 2014
    Posts:
    1
    Hello Sir,
    First of all thank you for helping us a lot with the ads and your plugin is amazing!
    I have a question, we have problems integrating the admob plugin and google play services. We researched the problem and it turned out that those two plugins can not be in the same file. So i am asking you how to do this and how to transform you plugin to work with that since the solution is one line of code but we do not know where to edit that. http://stackoverflow.com/questions/19721158/utilize-both-play-services-and-admob-sdk
    and here http://stackoverflow.com/questions/...dmobadssdk-6-4-1-jar-and-google-play-services
     
  34. nggb

    nggb

    Joined:
    Jan 12, 2014
    Posts:
    2
    Hello,
    First, thanks for the plug-in. I'm trying to put this in my game. The ads shows up and all, but I have no idea if it's actually registering or not. Normal ads shows up regardless of "Testing Mode" is on or not. Looking into my logcat says nothing about the deviceID of my device (I turn debugging to FLOOD even). So my question is, how do I find this device ID to enable to the test Ads so that I can test click on it to make sure it works.

    btw, I also tried to get my deviceID from other source, then MD5 hash it and put it in your plugin. Didn't seem like it makes any difference.
    Thanks.

    EDIT: I decided to go with a different solution. But thank you nonetheless for a great plugin.
     
    Last edited: Feb 23, 2014
  35. Eldirfar

    Eldirfar

    Joined:
    Feb 9, 2014
    Posts:
    41
    Can you say what one?
     
  36. DannyDan2468

    DannyDan2468

    Joined:
    Feb 23, 2014
    Posts:
    9

    Hi there!

    I compiled a new java package for the admob stuff WITHOUT the need of the READ_PHONE_STATE permission. I also used the new admob package GoogleAdMobAdsSdk-6.4.1.
    Because I dont know when MicroEyes is releasing a new package without the need of the READ_PHONE_STATE permission, I thought I check out his project and change the stuff myself.
    You only need to change the two jar files in your assets/plugins/android dir, comment the line with the phone_state permission in the manifest and use the two new cs files.
    I made a zip with all changed files.

    If you have any questions, feel free to ask.

    Hope anybody can use this too.
     

    Attached Files:

  37. Reizla

    Reizla

    Joined:
    Nov 5, 2013
    Posts:
    136
    Cool! Thanks. I'll use it later today for my own game (under development) and give feedback then.

    [EDIT]

    Had time to test is, but on my system it's not working :s
     
    Last edited: Feb 24, 2014
  38. DannyDan2468

    DannyDan2468

    Joined:
    Feb 23, 2014
    Posts:
    9
    What do you mean on your system? Do you get an error? Isnt the Ad showing in your app?!?
     
  39. MaZy

    MaZy

    Joined:
    Jun 29, 2012
    Posts:
    86
    I get this always.

    Code (csharp):
    1.  
    2. Exception: JNI: Init'd AndroidJavaClass with null ptr!
    3. UnityEngine.AndroidJavaClass..ctor (IntPtr jclass) (at C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Export/AndroidJavaImpl.cs:539)
    4. UnityEngine.AndroidJavaObject.get_JavaLangClass () (at C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Export/AndroidJavaImpl.cs:517)
    5. UnityEngine.AndroidJavaObject.FindClass (System.String name) (at C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Export/AndroidJavaImpl.cs:508)
    6. UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) (at C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Export/AndroidJavaImpl.cs:528)
    7. UnityEngine.AndroidJavaClass..ctor (System.String className) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/AndroidJava.cs:92)
    8. AdMobPlugin.SetCallbackHandlerName (System.String callbackHandlerName) (at Assets/Plugins/AdMobPlugin/AdMobPlugin.cs:69)
    9. AdMobPlugin.Awake () (at Assets/Plugins/AdMobPlugin/AdMobPlugin.cs:38)
    10.  
    11.  
    I even tried with this link: https://github.com/googleads/googleads-mobile-plugins I never get a ad :/
     
  40. seawolfff

    seawolfff

    Joined:
    Feb 24, 2014
    Posts:
    1


    I used your files and ads are working but I can't click the ads. Should this work? can you help me

    SOLVED: this helps http://forum.unity3d.com/threads/195169-Google-Admob-plugin-for-Unity-ad-is-not-clickable

    I just had this problem again after the 4.3 update and fixed it. I had to edit the manifest and change which Activity the ForwardNativeEventsToDalvik was called from due to a change in Unity 4.3.

    Move the line:
    <meta-data android:name="unityplayer.ForwardNativeEventsToDal vik" android:value="true" />

    To the activity UnityPlayerProxyActivity. Aka right before the line with </Activity> like this:

    Code:
    <activity android:name="com.unity3d.player.UnityPlayerProxyActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="landscape">

    <intent-filter>

    <action android:name="android.intent.action.MAIN" />

    <category android:name="android.intent.category.LAUNCHER" />

    </intent-filter>

    <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />

    </activity>
     
    Last edited: Feb 24, 2014
  41. itsboshytime

    itsboshytime

    Joined:
    Jan 10, 2014
    Posts:
    6
    So it's confirmed this is not working with Google Services? I'd like to implement leaderboards and achievements but I won't start until i know if it works or not.
     
  42. Simon_says

    Simon_says

    Joined:
    Oct 19, 2013
    Posts:
    141
    Does anyone else feel fps drops when ads are enabled/disabled?
     
  43. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    After testing Set plugin DebugLevel to Low from Editor.
     
  44. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    Hi Simon_says,
    After testing Set plugin DebugLevel to Low from Editor.

    Is this happening only when calling EnableAds/DisableAdvs OR keep droping after EnableAdv().?
     
  45. Adrian-Lungu

    Adrian-Lungu

    Joined:
    Nov 11, 2013
    Posts:
    2
    Hello,

    I seem to be having an issue with clicking the ads, it doesn't work.
     
  46. MFen

    MFen

    Joined:
    Sep 25, 2013
    Posts:
    13
    Is this package usable in editor or on Android device only?

    I am received this message:

    $errorMessage.png
     
  47. Eldirfar

    Eldirfar

    Joined:
    Feb 9, 2014
    Posts:
    41
    Please read previous posts. This question was asked few times. YES, it's only works on Android devices.


    @MicroEyes
    When you are planning to release new version without read phone permission?
     
  48. Gentleman Johnson

    Gentleman Johnson

    Joined:
    Feb 27, 2014
    Posts:
    5
    This thread can get a bit confusing, so I just wanted to confirm that I successfully have ads working, no read phone state permission, in combination with using the Google play services plug-in.

    Steps

    • Download the original plug-in
    • Apply the READ_PHONE_STATE patch by DannyDan2468, Page 17
    • Apply the ForwardNativeEventsToDalvik fixby seawolfff, Page 17
    • Follow the instructions by Jeremie Weldin Page 16 to modify your google-play-services.jar
    • Put your AD UNIT ID from ad mob in the Publisher Id field of the AdvertisementManager

    The jar fix step was a bit confusing for me. Do ONE of the following
    a) Set up your Google play unity plug-in first, which will generate the jar in your Unity project. Apply the patch to THIS jar
    b) Go to your android SDK and edit the jar there BEFORE you set up the unity plug-in. Setup of the unity plug-in will copy the jar from your android SDK into your unity project.


    Hats off to MicroEyes and the other contributers above! Admob ads and Google play services in my game is a go!
     
  49. Prabir

    Prabir

    Joined:
    Jul 8, 2012
    Posts:
    2
    Hey Micro eye Thanks for this great plugin, really helpful, Tried many other plugins , but all are quite complicated or less control, but this one got many options yet so simple to implement.

    Just have one issue, my Ads are not refreshing at all, at first i thought it may be due to the Refresh rate setting at Admob, but i changed it to 20 Sec, but still nothing, Ads is not at all refreshing. Did i miss something. Please help me check.
     
  50. Simon_says

    Simon_says

    Joined:
    Oct 19, 2013
    Posts:
    141
    It drops only when calling EnableAds/DisableAdvs, it's noticable on weaker devices only, but still it's a problem for me.
     
unityunity