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 are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here: unity.com/legal/terms-of-service.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

I will pay someone to show me how to integrate admob

Discussion in 'Android' started by benhigg, Nov 19, 2010.

  1. BeforeTheLight

    BeforeTheLight

    Joined:
    Jan 7, 2011
    Posts:
    165
    Ok gave up tried one more thing and boom it works. Now I have a problem. If you made this how can I move the ad. Also menu brings up test test buttons which ruins some functionality of my game. Is there a reason for this? Thank you so much! Had to add ad sdk to folder. To get to work.
     
  2. NestorAlgieri

    NestorAlgieri

    Joined:
    Sep 11, 2011
    Posts:
    298
    When I get back I will help you. I'll give you the project source so you can customize it yourself quickly.
     
  3. BeforeTheLight

    BeforeTheLight

    Joined:
    Jan 7, 2011
    Posts:
    165
    Thank you so much!
     
  4. BeforeTheLight

    BeforeTheLight

    Joined:
    Jan 7, 2011
    Posts:
    165
    I thank you for your patience and help. I have got my eclipse project to run in unity yeah!! But my game does not run just the ads. I would use yours but now the menu button does not work at all. Thanks again.
     
  5. BeforeTheLight

    BeforeTheLight

    Joined:
    Jan 7, 2011
    Posts:
    165
    Yes I use the menu button for user menus. It works without admob but when I add yours it doesn't work anymore. I am probley going to just buy prime 31 admob. Thanks again.
     
  6. BeforeTheLight

    BeforeTheLight

    Joined:
    Jan 7, 2011
    Posts:
    165
    Thanks but in arround 30 seconds i add admob with prime 31 and moved it where i wanted! Thank you very much for your time and information!
     
  7. NestorAlgieri

    NestorAlgieri

    Joined:
    Sep 11, 2011
    Posts:
    298
    np! Good to know!
     
  8. shinriyo_twitter

    shinriyo_twitter

    Joined:
    Aug 12, 2011
    Posts:
    328
    Hello everyone
    can you success newest AdMob?
     
  9. shinriyo_twitter

    shinriyo_twitter

    Joined:
    Aug 12, 2011
    Posts:
    328
    "inneractive Ads for Android" was released on Asset Store
    does it work?
     
  10. Mindunity

    Mindunity

    Joined:
    Dec 30, 2011
    Posts:
    22
    admob such a pain in the ass for Unity, anyone know whats the easiest way to add admob to existing projects?
     
  11. Need2Revolt

    Need2Revolt

    Joined:
    Sep 4, 2011
    Posts:
    19
  12. b2team

    b2team

    Joined:
    Dec 8, 2011
    Posts:
    2
    Hi nepoez
    I followed your steps, but I still can not make it work. can you help me?
    thanks a lot.
     
  13. sleglik

    sleglik

    Joined:
    Jun 29, 2011
    Posts:
    682
    Can someone help me with configuring my game for Admob? I have plugin for Mobclix but they revenue is extremely low for 10.000 impressions and 350 clicks my revenue is $0.91 (yes less than one dollar). When I send them ticket no response :/.

    If you will help me I will pay you :(.

    EDIT: Can someone describe it much better? I really don´t understand. Your "guides" seems to me incomplete...
     
    Last edited: Feb 9, 2012
  14. SeikoTheWiz

    SeikoTheWiz

    Joined:
    Aug 1, 2011
    Posts:
    69
    Hello!
    I would require some help too :(

    I'm not exactly making a plugin for admob, but for Burstly which is required by our editor.
    I've made something prettry close to the one for admob, but I have a big trouble.
    In BurstlySDK.jar we have many files, not only java.class, there's configuration files for example.

    When I need to init the SDK he's searching for files but he doesn't find them. And I think that it might be stripped by unity during the build somehow. (Even if no strip still has the same issue).
    Maybe my lib is just missplaced. I'm kind of lost...

    Did someone run into a similar troubles?
     
  15. FPSimth

    FPSimth

    Joined:
    Apr 28, 2012
    Posts:
    10
    I dont know if someone already suggested this but the admob plugin from prime31.com gets the job done super easy.
     
  16. NestorAlgieri

    NestorAlgieri

    Joined:
    Sep 11, 2011
    Posts:
    298
  17. taar1

    taar1

    Joined:
    Jan 12, 2012
    Posts:
    26
    I could use some help integrating AdMob to an existing Unity Android game.
    I can run AdMob perfectly inside an Android project using following code:

    Code (csharp):
    1.  
    2. public class AdMobActivity extends Activity
    3. {
    4.     @Override
    5.     protected void onCreate(Bundle savedInstanceState) {
    6.         Log.i("AdMobTest", "onCreate");
    7.  
    8.         // super (UnityPlayerActivity) will use setContentView() ...
    9.         super.onCreate(savedInstanceState);
    10.  
    11.         // ... so instead of using setContentView(), we call addContentView()
    12.         // from setupAds()
    13.         setupAds();
    14.  
    15.         // Add test devices (check the logcat for the ID string of your
    16.         // device..)
    17.         AdManager.setTestDevices( new String[] { "TEST_DEVICE_ID" } );
    18.     }
    19.  
    20.     private void setupAds() {
    21.         LinearLayout layout = new LinearLayout(this);
    22.         layout.setOrientation(LinearLayout.VERTICAL);
    23.         addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    24.  
    25.         AdView adView = new AdView(this);
    26.         layout.addView(adView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    27.  
    28.         adView.setBackgroundColor(0xff000000);
    29.         adView.setPrimaryTextColor(0xffffffff);
    30.         adView.setSecondaryTextColor(0xffcccccc);
    31.         adView.setKeywords("Android game");
    32.         adView.setRequestInterval(15);
    33.  
    34.         // add listener for easier debugging
    35.         adView.setAdListener(new SimpleAdListener() {
    36.             @Override
    37.             public void onFailedToReceiveAd(com.admob.android.ads.AdView adView) {
    38.                 Log.d("AdListener", "onFailedToReceiveAd: " + adView.toString());
    39.                 super.onFailedToReceiveAd(adView);
    40.             }
    41.  
    42.             @Override
    43.             public void onFailedToReceiveRefreshedAd(com.admob.android.ads.AdView adView) {
    44.                 Log.d("AdListener", "onFailedToReceiveRefreshedAd: " + adView.toString());
    45.                 super.onFailedToReceiveRefreshedAd(adView);
    46.             }
    47.  
    48.             @Override
    49.             public void onReceiveAd(com.admob.android.ads.AdView adView) {
    50.                 Log.d("AdListener", "onReceiveAd: " + adView.toString());
    51.                 super.onReceiveAd(adView);
    52.             }
    53.  
    54.             @Override
    55.             public void onReceiveRefreshedAd(com.admob.android.ads.AdView adView) {
    56.                 Log.d("AdListener", "onReceiveRefreshedAd: " + adView.toString());
    57.                 super.onReceiveRefreshedAd(adView);
    58.             }
    59.         });
    60.  
    61.         adView.requestFreshAd();
    62.     }
    63. }
    64.  
    I already was able to make other Android plugins working in Unity so the process of doing so should be correct. So I alter the above class to the following:

    Code (csharp):
    1.  
    2. public class AdMobUnityActivity extends UnityPlayerActivity {
    3.  
    4.     @Override
    5.     public void onCreate(Bundle savedInstanceState) {
    6.         super.onCreate(savedInstanceState);
    7.     }
    8.  
    9.     public static void setupAdsStatic() {
    10.    
    11.         AdManager.setTestDevices( new String[] { "TEST_DEVICE_ID" } );
    12.        
    13.         // And this is the same, but done programmatically
    14.         LinearLayout layout = new LinearLayout(UnityPlayer.currentActivity.getApplicationContext());
    15.         layout.setOrientation(LinearLayout.VERTICAL);
    16.         UnityPlayer.currentActivity.addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    17.  
    18.         AdView adView = new AdView(UnityPlayer.currentActivity);
    19.         layout.addView(adView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    20.  
    21.         adView.setBackgroundColor(0xff000000);
    22.         adView.setPrimaryTextColor(0xffffffff);
    23.         adView.setSecondaryTextColor(0xffcccccc);
    24.         adView.setKeywords("Android game");
    25.         adView.setRequestInterval(15);
    26.  
    27.         // add listener for easier debugging
    28.         adView.setAdListener(new SimpleAdListener() {
    29.             @Override
    30.             public void onFailedToReceiveAd(com.admob.android.ads.AdView adView) {
    31.                 Log.d("AdListener", "onFailedToReceiveAd: " + adView.toString());
    32.                 super.onFailedToReceiveAd(adView);
    33.             }
    34.  
    35.             @Override
    36.             public void onFailedToReceiveRefreshedAd(com.admob.android.ads.AdView adView) {
    37.                 Log.d("AdListener", "onFailedToReceiveRefreshedAd: " + adView.toString());
    38.                 super.onFailedToReceiveRefreshedAd(adView);
    39.             }
    40.  
    41.             @Override
    42.             public void onReceiveAd(com.admob.android.ads.AdView adView) {
    43.                 Log.d("AdListener", "onReceiveAd: " + adView.toString());
    44.                 super.onReceiveAd(adView);
    45.             }
    46.  
    47.             @Override
    48.             public void onReceiveRefreshedAd(com.admob.android.ads.AdView adView) {
    49.                 Log.d("AdListener", "onReceiveRefreshedAd: " + adView.toString());
    50.                 super.onReceiveRefreshedAd(adView);
    51.             }
    52.         });
    53.  
    54.         adView.requestFreshAd();
    55.     }
    56. }
    57.  
    I create a JAR with that and put it to the Unity project as a plugin. I set the AndroidManifest.xml file properly and try to call the function inside a C# script with this code:

    Code (csharp):
    1.  
    2. public class Startup : MonoBehaviour
    3. {
    4.     public static AndroidJavaClass adMobJavaClass;
    5.    
    6.     void Start ()
    7.         adMobJavaClass = new AndroidJavaClass("jp.paperbooya.drteeth.AdMobUnityActivity");
    8.     }      
    9.    
    10.     void OnGUI ()
    11.     {
    12.         if(GUI.Button(new Rect(10, 200, 150, 120), "adMobJavaClass:setupAds")){
    13.             adMobJavaClass.CallStatic("setupAdsStatic");
    14.         }
    15.     }
    16. }
    17.  

    But when I call that function inside the Unity project (it's a plugin in the project) then I get this error:
    Code (csharp):
    1.  
    2. 06-04 16:18:03.914: E/AndroidRuntime(22576): FATAL EXCEPTION: GLThread 10
    3. 06-04 16:18:03.914: E/AndroidRuntime(22576): java.lang.NoClassDefFoundError: com.admob.android.ads.AdManager
    4. 06-04 16:18:03.914: E/AndroidRuntime(22576):    at jp.paperbooya.drteeth.AdMobUnityActivity.setupAdsStatic(AdMobUnityActivity.java:93)
    5. 06-04 16:18:03.914: E/AndroidRuntime(22576):    at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    6. 06-04 16:18:03.914: E/AndroidRuntime(22576):    at com.unity3d.player.UnityPlayer.onDrawFrame(Unknown Source)
    7. 06-04 16:18:03.914: E/AndroidRuntime(22576):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1363)
    8. 06-04 16:18:03.914: E/AndroidRuntime(22576):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
    9.  
    and the game crashes and closes immediately.

    Any ideas on what's missing or wrong here? Thanks for any hints!
     
  18. taar1

    taar1

    Joined:
    Jan 12, 2012
    Posts:
    26
  19. mikolo

    mikolo

    Joined:
    Nov 27, 2009
    Posts:
    249
    Thats a cool Tutorial... i made also a video tutorial about writing a java plugin here -> http://www.youtube.com/watch?v=zxn2CuQszvw

    What i want to do is to show any Java activity layouts i want... when clicking on some GUI buttons! And then send back some values to unity..if we can switch and open between Unity game and Activies with different layouts... that would be great for developing! Have you also done something like this?
     
  20. taar1

    taar1

    Joined:
    Jan 12, 2012
    Posts:
    26
    Cool thing. If you have more tutorials please make sure to post them here because I think in this forum are more questions than answers ;-)

    Yeah I'm going to make a tutorial how to display a Android activity inside a Unity Android project tomorrow. I've only done a simple example but maybe I can build something on top of that.
     
  21. SeikoTheWiz

    SeikoTheWiz

    Joined:
    Aug 1, 2011
    Posts:
    69
    The issue about burstly is now corrected I made a post somewhere about integrating burstly.
     
  22. mikolo

    mikolo

    Joined:
    Nov 27, 2009
    Posts:
    249
    OK i will post them here for sure! That would be great to have a tutorial from you again! I am curious of that..maybe i will also continue my video tutorial with basis of your written tutorial! Thanks cu
     
  23. MicroEyes_old

    MicroEyes_old

    Joined:
    Jun 9, 2011
    Posts:
    188
    Hey Mikolo,
    Actually i was successfully able to Call first static function in native ( e.g., Initiate() ). But when i call my next function in native ( e.g., EnableAds() ), this code wont call native function even gives no error. I don't know what to do. Can't even sat y this happening..
    If anybody have some info regarding this issue, please help me. I m using below code for both native calls.

    AndroidJavaClass plugin = new AndroidJavaClass("com.android.test.TestActivity");
    AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
    plugin.CallStatic("InstantiateMe", qwe);
     
    Last edited: Jun 4, 2012
  24. mikolo

    mikolo

    Joined:
    Nov 27, 2009
    Posts:
    249
    Hi MicroEyes,

    i think you must call the TestActivity Class and extends to UnityPlayerActivity and then call the static method. Not call direktly UnityPlayer. I mean Something like this:

    PHP:
    package com.android.test;

    import com.unity3d.player.UnityPlayer;
    import com.unity3d.player.UnityPlayerActivity;

    public class 
    TestActivity extends UnityPlayerActivity {
        
         @
    Override
         
    public void onCreate(Bundle savedInstanceState) {
               
    super.onCreate(savedInstanceState);
         }

         public static 
    void myMethod() {

        }
    }

    And in Unity:

    AndroidJavaClass plugin = new AndroidJavaClass("com.android.test.TestActivity");
    plugin.CallStatic("myMethod");

    Hope it helps
     
  25. MicroEyes_old

    MicroEyes_old

    Joined:
    Jun 9, 2011
    Posts:
    188
    Thankx mikolo for your help. I m extending UnityPlayerActivity make my function "MyMethod" static its working from unity.. But when i m making a function "MyMethod_2" static calling from unity, then unity won;t call this method, even not getting any error.

    Any suggestions, why this happening..?
     
  26. mikolo

    mikolo

    Joined:
    Nov 27, 2009
    Posts:
    249
    a silly question....did you build your game again and copied the bin and libs folder to eclipse?
     
  27. MicroEyes_old

    MicroEyes_old

    Joined:
    Jun 9, 2011
    Posts:
    188
    Yes, i tried all possible solution i had.
     
  28. sagarchalavadi

    sagarchalavadi

    Joined:
    Oct 16, 2012
    Posts:
    1
    I created a plugin for the admob and i integrated that in my application and it was working fine for me .No w my problem is that i have been seeing the ad in all the scenes .But i don't want the ad to be shown in all the scenes .I just want the ad in the first scene and when i move to the next scene i should not see the ad(for that i was dismissing the ad but that is not the best approach as per my knowledge) and when i come back to the first scene i need to the ad to appear in it.Is there a way to achieve this thing in the unity .

    and i have doubt in the unity that is scene in a unity is equivalent to activity in android or not?

    Thanks in advance.
     
  29. subash95

    subash95

    Joined:
    Mar 10, 2015
    Posts:
    4
    i tried integreting ads to unity using admob, ads show and they can be clicked but the game is not playable as in the mainmenu and eveyother things in game cannot be clicked. Please help
     
  30. bigjobs

    bigjobs

    Joined:
    Feb 24, 2016
    Posts:
    14
    check out https://github.com/unity-plugins/Unity-Admob
    and code

    Here is the minimal banner code to create an interstitial.

    Admob.Instance().loadInterstitial();

    Unlike banners, interstitials need to be explicitly shown. At an appropriate stopping point in your app, check that the interstitail is ready before showing it:

    if (Admob.Instance().isInterstitialReady()) {
    Admob.Instance().showInterstitial();
    }
     
unityunity