Search Unity

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.9%
  2. No

    8.0%
  3. Not Completely

    25.1%
  1. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    Yes, Interstitials gives more benefit then normal banner ads.
     
  2. wolodo

    wolodo

    Joined:
    Nov 22, 2012
    Posts:
    55
    BTW what is this error? I know, it works even with this error, but what really causes it?
     
  3. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    wolodo, mancuso was actually trying to run JNI code from Unity Editor.
     
  4. wolodo

    wolodo

    Joined:
    Nov 22, 2012
    Posts:
    55
    So it has no effect on compiled app running on target device?
     
  5. drkow19

    drkow19

    Joined:
    Jun 24, 2013
    Posts:
    7
    Hey, thanks MicroEyes for this awesome plugin. I am working on my first Unity game for Android. I was looking for a free AdMob plugin, this one finally came out, even long after I started the project. I was easily able to use the prefab, and even link to it from one of my existing main scripts (javascript) to call some functions I made that enable/disable ads.
     
  6. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    No. it won't affect anything on target device.
     
  7. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    I am glad you like it. :)
     
  8. wolodo

    wolodo

    Joined:
    Nov 22, 2012
    Posts:
    55
    Good to hear. However thank you for this plugin. It is one of the most useful free things for unity. Good work. Haven't you considered also making plugin for in-app billing? :D
     
  9. Treanoob

    Treanoob

    Joined:
    Jun 4, 2013
    Posts:
    9
    Many thanks MicroEyes. I am a solo wannabe developer with no funds for all the little extras. This has helped a great deal.

    Your example project worked first time, no hassles.

    JC
     
  10. warkarma

    warkarma

    Joined:
    Oct 9, 2009
    Posts:
    73
    Is it possible to use this for PC games as well?
     
  11. AlvinHerawan

    AlvinHerawan

    Joined:
    Apr 27, 2013
    Posts:
    4
    Thank you for this great plugin! I have tried putting the banner on one of our free educational games. You can get via http://bit.ly/ShapeFindAndroid

    We do not currently have dedicated credits page within the app itself but I have credited you on the description page.
     
  12. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    No Its for Android Platform only.
     
  13. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    No Problems man. I did mentioned on first page, "If Possible". In either ways, i don't have any issues. But thanks for using this plugin.
     
  14. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    301
    This is great, I just tested it works amazingly cool :grin:

    But one question, how to remove that enable, disable etc gui buttons for testing ?

    Also can we edit ad position on run time ?

    Thanks
     
    Last edited: Jun 28, 2013
  15. CoderBear

    CoderBear

    Joined:
    Feb 27, 2013
    Posts:
    12
    I am starting to have this odd problem. I have the test mode button unchecked in the editor. Just today it started showing the testing gui buttons. When yesterday it worked fine and without issue. I can't explain it.
     
  16. Rodolfo-Rubens

    Rodolfo-Rubens

    Joined:
    Nov 17, 2012
    Posts:
    1,197
    add
    Code (csharp):
    1. #if UNITY_EDITOR
    before the OnGUI(); and
    Code (csharp):
    1. #endif
    after the closing bracket of OnGUI() at the AdvertisementManager script...

    It worked for me...

    Oh, and thanks MicroEyes! That's really awesome man, I will put you on my game's credits, zen :].
     
  17. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    Thanks for using plugin.
    You can comment out function OnGUI() in AdvertisementManager.cs

    No You can't reposition Adv @ runtime.
     
  18. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    Hey CoderBear,
    TestMode in editor is for advertisement. By enabling that Google Admob server will send you only test advertisements. There is nothing to do with GUI buttons. You'll have to disable yourself by comment out function OnGUI() in AdvertisementManager.cs
     
  19. AlvinHerawan

    AlvinHerawan

    Joined:
    Apr 27, 2013
    Posts:
    4
    Hi MicroEyes,

    How do I add the SDKs for mediation with other ad networks? Do I have to do this from Eclipse or it still can be done through Unity and Android SDK? Thanks in advance.
     
  20. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    There is no support for other ad networks yet. Sorry about that.
     
  21. enmeii

    enmeii

    Joined:
    May 18, 2009
    Posts:
    7
    Can I test on PC? Or I must have an android machine to test?
     
  22. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    Plugin works only on Android device.
     
  23. Rodolfo-Rubens

    Rodolfo-Rubens

    Joined:
    Nov 17, 2012
    Posts:
    1,197
    Hi MicroEyes, I was wondering if I can trigger some booleans inside my games if the user click on some ads... do you know how could I do this?
     
  24. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    Sorry friend, Google Admob SDK doesn't have any functionality yet.
     
  25. Lorenfield

    Lorenfield

    Joined:
    Jul 7, 2013
    Posts:
    2
    Hello MicroEyes,
    I just made a lite version of my game and used your plugin in. I just imported the unitypackage, created an Adapter class and it worked like a charm. I didn't even have to change anything (well except commenting the debug.log calls). It was too easy, I wonder if I missed anything. In the end, it still works, I can display ads so I put you in the credits part. Thank you :)
    Here is the link to my game : http://play.google.com/store/apps/details?id=com.ngvuhoang.games.fme.ads

    I was just wondering why there was a permission to read the phone state in the manifest. Is this an Admob special requirement ?
     
  26. Argenex

    Argenex

    Joined:
    Jan 7, 2011
    Posts:
    34
    I need a way to disable the static calls to the classes when I build for PC.
    Sadly I can't just put a switch in the handler to check which version, as Unity refuses to build because, go figure, it cant find the Android classes...

    If there could be some way to tell Unity to ignore the following lines on build while NOT set for Android:

    static AndroidJavaClass admobPluginClass;
    static AndroidJavaClass unityPlayer;
    static AndroidJavaObject currActivity;

    That would be great.
     
    Last edited: Jul 13, 2013
  27. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309

    You can use Platform Dependent Compilation.
     
  28. Argenex

    Argenex

    Joined:
    Jan 7, 2011
    Posts:
    34
    Yea I just am not sure how to do that in C#, as everything I know how to code requires I extend monobehavior into it. I tried just adding a simple if statement and it didn't like that.
     
  29. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    No, it fairly simple man.

    void Function()
    {
    #if UNITY_ANDROID

    //put All Android statements here

    #endif
    }
     
  30. ihazbackup

    ihazbackup

    Joined:
    May 23, 2013
    Posts:
    8
    Hi, I'm using your AdMob plugin with Unity 4 and I ran into a problem.

    I've added the 'Advertisement' prefab from the package and provided the publisher ID.
    when I test my game, the ad won't come out and it shows error in the console like this:

    $admob.png

    When I clicked, the "Show Ads" button, nothing happens...

    Also, does this plugin also works for iOS?

    THX b4
     
  31. regy42

    regy42

    Joined:
    Feb 16, 2013
    Posts:
    8
    Nice Work!

    I have only one question. Is it posibble to detect click on ad?

    Thank you!

    Edit: I think that probably no by some behaviour, but if I can detect that user click to some place and than the game go to background, it's signal that user click on ad. Is it posibble something like this?
     
    Last edited: Jul 17, 2013
  32. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309

    You are running in Unity Editor. Plugin will work only in Android devices.
     
  33. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    Yes. I have written code to do the same, but actually i am no getting appropriate time to test launch. But i'll update latest package soon.
     
  34. Salem1526

    Salem1526

    Joined:
    Jul 21, 2013
    Posts:
    1
    Yes, thanks in advance
     
  35. It-is-I2

    It-is-I2

    Joined:
    Apr 18, 2013
    Posts:
    18
    Well Microeyes Thanks for theplugin, BUT
    does it take time for it to work?

    I have tested it with your file and the new android SDK.
    in test mode it both work. But when i turn testing off , then i don't see any apps

    thanks again!
     
    Last edited: Jul 21, 2013
  36. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    What do you mean by "then i don't see any apps:"?
     
  37. It-is-I2

    It-is-I2

    Joined:
    Apr 18, 2013
    Posts:
    18
    Sorry i ment adds

    (and thanks for the quick reply btw)
     
  38. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    By Enabling Test mode, Google Admob server will send you Test Adv that doesn't count in your revenue. Disabling Test mode, you will get actually Adv. Code for both are same. Please check in logs if you find anything or send me logs, so i could debug.
     
  39. It-is-I2

    It-is-I2

    Joined:
    Apr 18, 2013
    Posts:
    18
    I already fixed it.

    Turns out that i kept "enabling ad" in the script. ( a bad case of unproper script adjustement)
    So now it works!!

    Thanks again!
     
  40. Jaro

    Jaro

    Joined:
    Jul 26, 2013
    Posts:
    16
    Hello,
    sorry for noob question but, how can I use my own java plugin along with yours.

    I need this to use send intent.

    I created jar plugin with one activity

    Code (csharp):
    1. package pl.smart.tech.sheepGame;
    2. public class SmartShare extends UnityPlayerActivity {
    3.        
    4.           public void shareText(String subject,String text,String chooserTitle) {
    5.             Intent sendIntent = new Intent();
    6.             sendIntent.setAction(Intent.ACTION_SEND);
    7.             sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    8.             sendIntent.putExtra(Intent.EXTRA_TEXT, text);
    9.             sendIntent.setType("text/plain");    
    10.             startActivity(Intent.createChooser(sendIntent, chooserTitle));                 
    11.         }              
    12. }
    manifest.xml is

    Code (csharp):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="pl.smart.tech.sheepGame">
    3.   <application android:icon="@drawable/app_icon" android:label="@string/app_name">
    4.     <activity android:name=".SmartShare"
    5.           android:label="@string/app_name"
    6.           android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    7.       <intent-filter>
    8.         <action android:name="android.intent.action.MAIN" />
    9.         <category android:name="android.intent.category.LAUNCHER" />
    10.       </intent-filter>
    11.     </activity>
    12.   </application>
    13. </manifest>
    and I use it like this

    Code (csharp):
    1. void Share(string subject,string text,string chooserTitle)
    2.     {
    3.         string[] param = { subject, text, chooserTitle };
    4.         AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    5.         AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
    6.         jo.Call("shareText",param);
    7.  
    8.     }
    problem is when I use your plugin (btw. thank you so much - its great!) and I add my activity to yours manifest I've got the following error JNI: Unable to find method id "shareText"

    Thank you in advance!

    EDIT:

    I tried to grab current activity and statically start new activity from it but without luck

    Code (csharp):
    1.  
    2. AndroidJavaClass ajc = new AndroidJavaClass("pl.smart.tech.sheepGame");
    3. AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    4. AndroidJavaObject currActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
    5.  
    6. ajc.CallStatic("shareText", currActivity, subject, text, chooserTitle);
    I dont know what .class should be than in java file - so I put UnityPlayerActivity.class
    Code (csharp):
    1.  
    2.   public static void shareText(Activity root,String subject,String text,String chooserTitle) {
    3.            
    4.             Intent sendIntent = new Intent(root,UnityPlayerActivity.class);
    5.             sendIntent.setAction(Intent.ACTION_SEND);
    6.             sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    7.             sendIntent.putExtra(Intent.EXTRA_TEXT, text);
    8.             sendIntent.setType("text/plain");    
    9.             root.startActivity(Intent.createChooser(sendIntent, chooserTitle));    
    10.         }
    EDIT 2:

    I noticed great performance decrease when ads are active, is that normal ? Tested on HTC One V , Desire S, LG L7, Nexus 7
     
    Last edited: Jul 26, 2013
  41. TirythDM

    TirythDM

    Joined:
    Dec 17, 2012
    Posts:
    3
  42. russpuppy

    russpuppy

    Joined:
    Jul 29, 2013
    Posts:
    4
  43. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
  44. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
  45. Argenex

    Argenex

    Joined:
    Jan 7, 2011
    Posts:
    34

    Yea that sadly doesn't work.

    I have to now completely remove this from my project just to build for PC WEB.

    Not really sure why you altered it so it forces you to only work for Android, sort of defeats the whole point of Unity. Back when you originally created this plugin, it was great. Now I would have to keep some sort of insane duplicates of my project just to build seperately.

    Oh well.

    Errors:

    Which of course, is because we're not loading that library.
     
    Last edited: Aug 9, 2013
  46. Flux

    Flux

    Joined:
    Mar 31, 2013
    Posts:
    7
    Nice job!

    But is it possible to change the banner position in code?

    Regards,
    Fluxxi
     
  47. progmeer

    progmeer

    Joined:
    Oct 5, 2012
    Posts:
    36
    Noob question:
    I was able to display ads in my device using the test scene. When I changed the publisher id to mine(in the inspector and AdvertisementManger.cs), ads stopped showing.
    That's all the changes I've made and my game is not published in the appstore(needs ads to publish)

    Am I missing something?
     
  48. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    Hi,
    I am not getting your issue. Aren't you app showing Ads OR Did google play store rejected your app.?
    Please test your Admob publisher ID in TestScene with project i have uploaded in first page. This way you could check whether your publisher ID working or not.
     
  49. progmeer

    progmeer

    Joined:
    Oct 5, 2012
    Posts:
    36
    The ads show if I leave the publisher id that comes with the plugin. If i change it to mine, they disappear. I tested it in the TestScene that comes with the plugin using an Asus tablet.
    I also tried setting IsTesting to true.
    The app is not yet in the market and is listed as inactive(No ad requests received) in the admob dashboard.

    Thank you for the plugin and support. You're a great asset to the community BTW.
     
  50. MicroEyes

    MicroEyes

    Joined:
    Jul 3, 2012
    Posts:
    309
    Thanks, I appreciate you like the plugin.
    Please all your publisher ID to test Scene, change LevelOfDebug to Flood in the inspector.
    In the Android LogCat(preferably Eclipse logcat), check whether apk is able to send request or not and receiving in return.

    If you can't send me your apk, i'll try to give you the reason for the issue you are facing.