Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Released] Android Native Plugin

Discussion in 'Assets and Asset Store' started by stanislav-osipov, Sep 20, 2013.

  1. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Hello tobia88,
    Are you using latest plugin version?

    Could you please explain more what do you mean by this?


    Hey, por.chin

    Well Facebook Unity SDK is already integrated, for other I can not answer on this question, it depends of those plugins. For my plugin this is AndroidNativeBridge. You shouldn't add all those activities in the manifest point is that you have to combine all plugins to use one main activity. There is now straight forward instruction how to combine different plugins, it depends from those plugins. All can I do from my side here:
    - open plugins source code
    - clean coding
    - all important stuff for AndroidNative plugin marked in manifest

    Currently plugins implementation contains only one function with allows you to register your device and get device id, with you can pass to your server and make it able to send push notifications not this device.
     
  2. tobia88

    tobia88

    Joined:
    Aug 1, 2013
    Posts:
    5
    1. I'm Pretty sure i'm using the latest Plugin!
    2. It cant login my facebook since my key store alias is assigned in Android. It works very well before i set up my key store, but since i wish to test in-app billing so i have to assign the store key alias, and i found that i cant log in anymore!

    Sorry as i'm quiet poor in my english, hope u can understand it :)
     
  3. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    YOU should add keyhash for your key store to your facebook app, as described here:
    https://docs.google.com/document/d/..._06bk3weoVOOD-0nY/edit#heading=h.2fae4js7xc3a

    Cheers!
     
  4. por-chin

    por-chin

    Joined:
    Jan 3, 2014
    Posts:
    4
    Hi Lacost,

    Sorry for trouble you again. I opened AndroidNativeBridge.java in your project and it had errors at
    Code (csharp):
    1. import com.facebook.Session;
    2. import com.facebook.unity.FB;
    it seems like it misses facebook plugin?
     
  5. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Hello. Are you trying to open the eclipse project?
    You actually need to import AndroidNativeProject and facebook project to your eclipse environment. Than this error will gone.
    Cheers!
     
  6. bruu

    bruu

    Joined:
    May 24, 2013
    Posts:
    2
    Trying to get AdMob to work but having no luck. Neither banner or interstitial appears, I've been following the online documentation but no luc

    Code (csharp):
    1. public class AdManager : MonoBehaviour {
    2.     // Use this for initialization
    3.     void Awake ()
    4.    
    5.     {
    6.         AndroidAdMobController.instance.Init(null, "Banner_Ad_Unit_ID");
    7.         AndroidAdMobController.instance.SetInterstisialsUnitID("Ad_Unit_ID");
    8.     }
    9.    
    10.  
    11.     void Start()
    12.     {
    13.         AndroidAdMobController.instance.ShowInterstitialAd();
    14.         AndroidAdMobController.instance.CreateAdBanner(TextAnchor.UpperCenter, GADBannerSize.SMART_BANNER);
    15.     }


    I've got this script named AdManager attached to a gameobject alongside AndroidAdMobController.

    Am I doing it completely wrong or?
     
    Last edited: Apr 8, 2014
  7. MarkHenderson

    MarkHenderson

    Joined:
    Oct 28, 2013
    Posts:
    16
    After installing this library, I can compile in the Unity Editor but not in Monodevelop.

    In Mono, I get the following warning
    Code (csharp):
    1. Warning BCW0000: WARNING: Could not load types from 'IFacebook, Version=0.0.0.0, Culture=neutral, PublicKeyToken=d9f0385cc69e16d8': System.IO.FileLoadException: Could not load file or assembly 'UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044) (BCW0000: WARNING: Could not load types from 'IFacebook, Version=0.0.0.0, Culture=neutral, PublicKeyToken=d9f0385cc69e16d8': System.IO.FileLoadException: Could not load file or assembly 'UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT) (Assembly-UnityScript-firstpass)

    followed by the below: (the two errors alternate, with the first appearing 4 times and the second appearing 3 times)
    Code (csharp):
    1. Error File name: 'UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' (File name) (Assembly-UnityScript-firstpass)
    2.  
    3. Error System.IO.FileLoadException: Could not load file or assembly 'UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044) (System.IO.FileLoadException: Could not load file or assembly 'UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT) (Assembly-UnityScript-firstpass)
    It's possible I missed some basic step somewhere along the lines - should I be installing the Facebook unity library or some android sdk separately from the contents of this package?

    I'm currently using Unity 4.3.4f1 on a windows 7 machine.

    Thanks for your help,
    Mark
     
  8. Mr_Mendel

    Mr_Mendel

    Joined:
    Dec 31, 2013
    Posts:
    19
    I have the exact same problem.

    Really want a fix as it clearly is an issue!
     
  9. Mr_Mendel

    Mr_Mendel

    Joined:
    Dec 31, 2013
    Posts:
    19
    I found a solution that works for the moment though I do not know why. In mono develop on the left you have Assembly-CSharp, Assembly-CSharp-Editor, Assembly-CSharp-Editor first pass, Assembly-CSharp first pass. If you right click on them, from the the bottom up, and do the option of Build ass... F7.

    After that mine seemed to work ok.
    Weird but hey.
     
  10. Mr_Mendel

    Mr_Mendel

    Joined:
    Dec 31, 2013
    Posts:
    19
    But problem came back ahhh!

    Fix this Stan ;)
     
  11. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    I sure this case already solved by e-mail. But any way IN this example banner_ad_id is null, that why no banners appear.

    MarkHenderson , Mr_Mendel Thanks for pointing this problem and possible solution. Point is that Facebook plugin part is builded as wrapper around Unity Official Facebook SDK. I sure this problem will be fixed in next SDK version. I will for sure talk about this with Unity support.
    Cheers!
     
  12. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    Last edited: Apr 11, 2014
  13. MinhDao

    MinhDao

    Joined:
    Oct 28, 2013
    Posts:
    155
    Hi Lacost,

    I have problem with google admob. I want to test google admob in my game. But when I add app on admob site, this form require App Store URL on IOS and Android Package URL on Android. But I have not published it on the market place. So, How i get Ad unit id and put it in my code?

    Thank you very much! :D
     
  14. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    I am not sure what you mean by this, can you please emplane more?


    Those fileds not required, feel free to leave it empty.
     
  15. Caffeen

    Caffeen

    Joined:
    Dec 25, 2013
    Posts:
    34
    I recently started trying to test the In-App Purchase functionality. I created a new project with the BillingImplementationExample scene, followed the documentation, uploaded my APK to the Dev console, created the In-App Products, etc.

    When I install the apk on my test phone, and press the "Coin Bonus" button, it opens the purchase interface and allows me to do a test purchase, but once the purchase is complete, I get the following error:

    -1003 Signature Verification Failed for SKU coins_bonus (Response: -1003: Purchase signature verification failed)

    Nothing else changes, and I do get the receipt email confirming my purchase. If I press the Coin Bonus button again, I get an error telling me I've already purchased it. Then, if I restart the app, both of the buttons are greyed out, and it immediately throws the following error:

    -1003 Error refreshing inventory(querying owned items). (response: -1003: Purchase signature verification failed)

    I'm assuming I made an error at some point, any idea what's causing this?

    Thanks!
     
    Last edited: Apr 13, 2014
  16. MinhDao

    MinhDao

    Joined:
    Oct 28, 2013
    Posts:
    155
    Hi Lacost,

    New google admob is not support my country, I can't use monetization app. So, how can I get Ad unit id? I have only Publisher ID! Can your plugin work with old admob?
     
  17. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    it was related business logic. i learned it. so you can ignore the question.

    i still request offline (asset store package) documentation update.
     
  18. Tongie

    Tongie

    Joined:
    Sep 19, 2012
    Posts:
    90
    Hi stan, I am working on android leaderboard but after GooglePlayConnection.instance.connect (); its just stopped. I am quite new to android. Its doesnt login to play service nor show leaderboard.

    Logcat:
    04-14 19:49:50.350: I/Unity(28673): GooglePlayManager was created
    04-14 19:49:53.070: I/Unity(28673): GooglePlayManager -> OnConnect

    Code (csharp):
    1.  
    2.     void Start()
    3.     {
    4.         #if UNITY_IPHONE
    5. //          GameCenterManager.init();  
    6.         #elif UNITY_ANDROID
    7.  
    8.             //listen for GooglePlayConnection events
    9.             GooglePlayConnection.instance.addEventListener (GooglePlayConnection.PLAYER_CONNECTED, OnPlayerConnected);
    10.             GooglePlayConnection.instance.addEventListener (GooglePlayConnection.PLAYER_DISCONNECTED, OnPlayerDisconnected);
    11.             GooglePlayConnection.instance.addEventListener (GooglePlayConnection.CONNECTION_INITIALIZED, OnConnect);
    12.            
    13.            
    14.             //listen for GooglePlayManager events
    15. //          GooglePlayManager.instance.addEventListener (GooglePlayManager.ACHIEVEMENT_UPDATED, OnAchivmentUpdated);
    16.             GooglePlayManager.instance.addEventListener (GooglePlayManager.PLAYER_LOADED, OnPlayerInfoLoaded);
    17. //          GooglePlayManager.instance.addEventListener (GooglePlayManager.SCORE_SUBMIT);
    18.  
    19.  
    20.             if(GooglePlayConnection.state == GPConnectionState.STATE_CONNECTED)
    21.             {
    22.                 //checking if player already connected
    23.                 Debug.Log("GooglePlayManager  -> GPConnectionState.STATE_CONNECTED");
    24.                 OnPlayerConnected ();
    25.             }
    26.  
    27.             //should be called on your application start
    28.             //best practice to call it only once. Any way other calls will be ignored by the plugin.
    29.             //if you want to use only Game service (Leader-boards, achievements) use GooglePlayConnection.CLIENT_GAMES
    30.             //if you want to use only Google Cloud service use GooglePlayConnection.CLIENT_APPSTATE
    31.             //if you want both: GooglePlayConnection.CLIENT_GAMES | GooglePlayConnection.CLIENT_APPSTATE
    32.             //and if you whant to get avaliable permissions for your app use: GooglePlayConnection.CLIENT_ALL
    33.             Debug.Log("GooglePlayManager  -> GooglePlayConnection.instance.start (GooglePlayConnection.CLIENT_GAMES)");
    34.             GooglePlayConnection.instance.start (GooglePlayConnection.CLIENT_GAMES);
    35.         #endif
    36.     }
    37.  
    38.     #region GooglePlayConnection event
    39.     private void OnConnect()
    40.     {
    41.         Debug.Log("GooglePlayManager  -> OnConnect");
    42.         GooglePlayConnection.instance.connect ();
    43.     }
    44.  
    45.     private void OnPlayerDisconnected()
    46.     {
    47.         Debug.Log("GooglePlayManager  -> OnPlayerDisconnected");
    48.     }
    49.  
    50.     private void OnPlayerConnected()
    51.     {
    52.         Debug.Log("GooglePlayManager  -> OnPlayerConnected");
    53.         GooglePlayManager.instance.loadPlayer ();
    54.         GooglePlayManager.instance.loadLeaderBoards();
    55.         GooglePlayManager.instance.loadAchivments ();
    56.     }
    57.     #endregion
    58.  
    59.     #region GooglePlayManager event
    60.     private void OnPlayerInfoLoaded(CEvent e) {
    61.         Debug.Log("GooglePlayManager  -> OnPlayerInfoLoaded");
    62.         GooglePlayResult result = e.data as GooglePlayResult;
    63.     }
    64.     #endregion
    65.  
    66.  
     
  19. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Hello. Caffeen.
    This error means your Base64Key does not match:
    http://stackoverflow.com/questions/15409833/signature-verification-failed-android-in-app-purchase

    This one means you trying to purchase product you already own. If you want to purchase products more that one time you should consume it before next purchase.

    Absolutely! Will do.

    Hey Tongie
    It should work on device only.
    If on device user is not connected to the play service this means you have problems with Developer Console setting or your app settings.
    I would recommend to follow step by step guide once again, if that will not solve your problem, feel free to contact support team as stans.assets@gmail.com and attach your device log, it will help to solve your issue faster.

    Cheers!
     
  20. deiong

    deiong

    Joined:
    May 24, 2013
    Posts:
    79
    how do you test in-app purchases without paying?? I want to make sure that the code will unlock what was paid for, but don't want to keep paying my google account every time I want to test..

    also.. I seem to have one problem. If I click off the inapp popup it crashes the application saying unfortunately the app has stopped. testing with the billingimplementation example.

    thanks
     
  21. Tongie

    Tongie

    Joined:
    Sep 19, 2012
    Posts:
    90
    You just enlighten me and I took a second look at my logcat, the problem was the version.xml in values folder. Change it to the latest version. Thanks stans!


    Code (csharp):
    1.  
    2. <?xml version="1.0" encoding="utf-8"?>
    3. <resources>
    4.     <integer name="google_play_services_version">4242000</integer>
    5.     <!--<integer name="google_play_services_version">4030500</integer>-->
    6. </resources>
    7.  
     
  22. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    Hi lacost,

    I have android free addon and i can use your addon. afaik your add on works as plugin. how can i run it? don't you implement this addon as plugin?
     
  23. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Hello. You will not be charged for making purchases while you in test mode, just make sure you have added your account as tester for billing in the developer console.
    And if you have any technical issue like crashing or you think something not working properly there. Feel free to drop e-mail at stans.assets@gmail.com
    And do not forget to attach log to the letter it will help to solve your issue faster.
    Cheers!

    It was problem like this on version 2.2 I guess. But currently plugin has rught versions.xml any way, sorry for inconvenience.
     
  24. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    I am sorry I am afraid I did not understood what you mean, can you please explain it. Thanks in advance.
     
  25. Becoming

    Becoming

    Joined:
    May 19, 2013
    Posts:
    781
    Hi, i am trying the facebook example that is included, when i press the LoadFriends button i get this error

    Code (csharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. SPFacebook.ParceFirendsData (System.String data) (at Assets/Extensions/GooglePlayCommon/Social/Facebook/SPFacebook.cs:248)
    3. SPFacebook.FriendsDataCallBack (.FBResult result) (at Assets/Extensions/GooglePlayCommon/Social/Facebook/SPFacebook.cs:238)
    4. Facebook.AsyncRequestString+<Start>c__Iterator0.MoveNext ()
    5.  
    I noticed that in many places "friends" is missspelled as "firends"... is this an accident and i should refactor it or i this intended to not collide with naming?
     
  26. gabrielthorn

    gabrielthorn

    Joined:
    Mar 10, 2014
    Posts:
    3
    Sorry for bothering you, but I have exactly the same problem. I have literally zero experience with Eclipse, I'm building my first ever Unity game using Unibill and I try to add Google Mobile Ads SDK without luck. I have the same error you had. Can you tell me how to rebuild the androidnative library in Eclipse with adding Unibill?

    Cheers,
    Gábor
     
  27. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    i tried to said how can i use your asset without having unity android pro. i think unity pro is enough to use plugins. so i can use plugins with my unity pro without unity android pro addon :)
     
  28. gutentagdesign1

    gutentagdesign1

    Joined:
    Mar 13, 2014
    Posts:
    4
    Dear Stan

    I have recently purchased the plugin. I would like to how to make a button that does not require authentication.

    When the button is clicked, the game goes to twitter app and auto-generate a specific line such as player's score in the game.

    Please see flappy wings android game for example.

    Thanks for your support
     
  29. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    I will check this and crash also, thanks for report!
     
  30. por-chin

    por-chin

    Joined:
    Jan 3, 2014
    Posts:
    4
    Hi Lacost,

    Thanks for the last help. I have one question about Notification.

    Can I schedule the notification likes I want it to popup one day later, can I do that with your plugin? Just like 'NotificationServices' built-in Unity function.

    Thanks.
     
  31. cuberob

    cuberob

    Joined:
    Apr 6, 2014
    Posts:
    5
    Hey Lacost,

    Props to you, awesome work!
    I do have some questions/problems though, it's probably my stupid mistake but hopefully you can help me out!

    The problem is that whenever I return from the native leaderboard or achievement screen to my game, the app crashes. (other than that all seems fine, achievements get awarded etc.)

    This is what i see in my logcat that I reckon is the pain point:

    04-19 10:20:12.592: E/AndroidRuntime(21926): Caused by: java.lang.NoClassDefFoundError: com.facebook.Session

    The thing is though, that after I first imported your complete package I started my removing all facebook and twitter referenced. Now I can imagine that is probably part of the problem. is there any way i can fix this without importing all facebook stuff?

    Also: how would I submit scores to a time based leaderboard?

    Thanks a lot!
     
  32. cuberob

    cuberob

    Joined:
    Apr 6, 2014
    Posts:
    5
    quick followup, when building with all facebook files I get the following error during build:
    again probably me being stupid, but anyone here who has an idea?


    Oke dunno what I did but it seems fixed..!

    found this somewhere:
    Step 1 : download the facebook sdk Step 2 : import the facebook sdk in eclipse Step 3 : Build the project Step 4 : Drag the created jar file to the unity project, same with the res folder.
    But that didn't quite work. After that i deleted all social references again but left that genereted jar in my plugin/android/libs folder (the facebooksdk.jar) and now it doesnt crash when returning to scene. Weird but im happy :)


    -- Still wondering how to submit "time" scores to leaderboard though, so if anyone knows please lemme know :) --


    UPDATE:
    Still running into some kind of FB error. When I go "home" on my device from my game and return to it by pressing the icon again from my home screen (so NOT through the multitask button). The app crashes with:

    [Caused by: java.lang.NoClassDefFoundError: com.facebook.unity.FB]
     
    Last edited: Apr 21, 2014
  33. jocyf

    jocyf

    Joined:
    Jan 30, 2007
    Posts:
    285
    Hi, I'm having an error when I try to loadStates using google Cloud, using (GoogleCloudManager.instance.loadAllStates ()

    I have the line needed in the Manifest file :
    Code (csharp):
    1. <!-- Important for Google Cloud Service -->
    2. <meta-data android:name="com.google.android.gms.appstate.APP_ID" android:value="@string/
    and any other feature works just fine (leaderboards, InApp purcahses, Rate and AdMob).

    I'm coneccting to Google Play serices using:
    Code (csharp):
    1. GooglePlayConnection.instance.start (GooglePlayConnection.CLIENT_GAMES | GooglePlayConnection.CLIENT_APPSTATE );
    In geeting this error in ADB:
    Code (csharp):
    1. 04-19 18:06:00.799: I/Unity(1103): AndroidJavaException: java.lang.IllegalStateException: Not connected. Call connect() and wait for onConnected() to be called.
    2. 04-19 18:06:00.799: I/Unity(1103):   at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <filename unknown>:0
    3. 04-19 18:06:00.799: I/Unity(1103):   at UnityEngine.AndroidJNISafe.CallVoidMethod (IntPtr obj, IntPtr methodID, UnityEngine.jvalue[] args) [0x00000] in <filename unknown>:0
    4. 04-19 18:06:00.799: I/Unity(1103):   at UnityEngine.AndroidJavaObject._Call (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0
    5. 04-19 18:06:00.799: I/Unity(1103):   at UnityEngine.AndroidJavaObject.Call (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0
    6. 04-19 18:06:00.799: I/Unity(1103):   at AndroidNative+<CallActivityFunction>c__AnonStorey31.<>m__1 () [0x00000] in E:\Unity3D\_Trabajos\Altivasoft\Kartsgame\Assets\Extensions\GooglePlayCommon\Core\AndroidNative.cs:388
    7. 04-19 18:06:00.799: I/Unity(1103):   at UnityEngine.AndroidJavaRunnableProxy.run () [0x00000] in <filename unknown>:0
    8. 04-19 18:06:00.799: I/Unity(1103):   at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Gl
    Any ideas?


    SOLVED: I was calling to the loadStates function before connecting to GooglePlayServices.
     
    Last edited: Apr 19, 2014
  34. keburanuil

    keburanuil

    Joined:
    Oct 25, 2013
    Posts:
    9
    Same problem here, people has started sending crash reports since I updated some of my games. I had to remove facebook folder in plugins folder, because it contained another android manifest and therefore I couldn't build projects on android. Hope this will be fixed soon.

    Crash report here:

    java.lang.Error: FATAL EXCEPTION [main]
    Unity version : 4.3.4f1
    Device model : HTC HTC One V
    Device fingerprint: htc_europe/htc_primou/primou:4.0.3/IML74K/92876.6:user/release-keys

    Caused by: java.lang.NoClassDefFoundError: com.facebook.Session
    at com.android.AndroidNativeBridge.onActivityResult(AndroidNativeBridge.java:535)
    at android.app.Activity.dispatchActivityResult(Activity.java:4747)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:3394)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3448)
    at android.app.ActivityThread.access$1100(ActivityThread.java:139)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:156)
    at android.app.ActivityThread.main(ActivityThread.java:4977)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    at dalvik.system.NativeStart.main(Native Method)

    You have to send time in milliseconds in type of integer.

    I'm not 100% sure how to do this in c# but in javascript:
    Code (csharp):
    1.  
    2. // Example if you have time stored to float variable in seconds
    3. var myTime : float = 5.38374959;
    4.  
    5. function Start()
    6. {
    7.     var lbTime : int = myTime * 1000;  // This gives you 5383, send this score to leaderboards
    8. }                                                    
    9.  
    Now the time will be displayed 5,38 on the leaderboards. If you send value that's over a minute, like 61234, it will be displayed 1:01,23
     
    Last edited: Apr 21, 2014
  35. kevinseligmann

    kevinseligmann

    Joined:
    Mar 23, 2011
    Posts:
    68
    Hi Lacost, how are you doing?

    I'm experiencing some problems when trying to set up Google AdMob.
    I created a GameObject and attached the following script to it:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class AdManager : MonoBehaviour
    6. {
    7.  
    8.     private const string MY_INTERSTISIALS_AD_UNIT_ID = "ca-app-pub-9026424771801317/1612372216";
    9.     private AndroidAdMobController Controller;
    10.  
    11.     void Awake ()
    12.     {
    13.         Controller = new AndroidAdMobController();
    14.         Controller.Init(MY_INTERSTISIALS_AD_UNIT_ID);
    15.         Controller.SetBannersUnitID(MY_INTERSTISIALS_AD_UNIT_ID);
    16.     }
    17.  
    18.     void Start ()
    19.     {
    20.  
    21.         Controller.StartInterstitialAd();
    22.         Controller.addEventListener(GoogleMobileAdEvents.ON_INTERSTITIAL_AD_LOADED, OnInterstisialsLoaded);
    23.         Controller.addEventListener(GoogleMobileAdEvents.ON_INTERSTITIAL_AD_OPENED, OnInterstisialsOpen);
    24.  
    25.     }
    26.  
    27.     private void OnInterstisialsLoaded ()
    28.     {
    29.         Debug.Log(">>> OnInterstisialsLoaded()");
    30.     }
    31.  
    32.     private void OnInterstisialsOpen ()
    33.     {
    34.         Debug.Log(">>> OnInterstisialsOpen()");
    35.     }
    36.  
    37. }
    38.  
    With this script and just for testing, whenever I run my application, an interstitial ad should appear on screen on my main scene. But instead of that, I just get on the console an error saying

    SendMessage: object AndroidAdMobController not found!

    Could you enlighten me as why is this happening please?
    Thank you very much!

    PS: I also tried with AndroidAdMobController.instance instead of initializing the class but had no luck as well. Thanks.
     
  36. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    Hi Lacost,

    i use AndroidAdMobController.instance.CreateAdBanner(x,y, GADBannerSize.BANNER); to add banner. it is ok on my tablet. it show banner like double sized on my Samsung Note 3. Do you have any idea?

    Note 3 Resolution : 1920x1080 v4.4.2
    Tablet Resolution : 1280x800 v4.2.2
     
    Last edited: Apr 23, 2014
  37. keburanuil

    keburanuil

    Joined:
    Oct 25, 2013
    Posts:
    9
    Solved this by removing the facebook folder in its real location \Assets\Facebook (not only in unity editor) and reinstalling the whole plugin. Now I can build for android even if facebook files are included to the plugin folder and the leaderboard/achievement crash is gone. :)

    Always when you update the plugin make sure you remove old files in their real location. Especially these files:
    \Assets\Extensions\AndroidNative
    \Assets\Extensions\GooglePlayCommon
    \Assets\Facebook
    \Assets\Plugins\Android
     
  38. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Sorry for slow replay guys. I just have huge amount of work with the plugin. Play service version in updated and I have to rewrite all play service code.

    cuberob , keburanuil
    It can happened if you have removed facebook Project. Use this jar file, it will solve your issue:
    https://www.dropbox.com/s/blosv8tc201ldm9/androidnative.jar

    Yep, more about leaderboards score submitting can be found here:
    https://developers.google.com/games/services/common/concepts/leaderboards#score_formatting

    kevinseligmann
    And that is right way to use it. If you do not see any ads, most likely you did somethng wrong with the set up. Please drop and e-mail to stans.assets@gmail.com support team will solve your problem. And it would be great if you can attach your log cat file to the letter.


    atmuc

    Banner size are not affect by resolution. Google SDK controls it, and makes sure that banner same size (cm) on all device.


    In next version of plugin it will be possible to get rid of Facebook Part if you do not use it. For current version 2.5 you can replace androidnative.jar
    https://www.dropbox.com/s/blosv8tc201ldm9/androidnative.jar
    and removing Facebook part will not harm your project.

    If you what to use full plugin power make sure
    \Assets\Facebook
    \Assets\Plugins\Android

    Have correct path. Other folders / scripts location doesn't matter.
     
  39. paala

    paala

    Joined:
    Mar 24, 2014
    Posts:
    20
    Hello,

    How do you generate a new jar with Eclipse?
    I tried to import all files in eclipse, generate a jar (for me the output is different file size), replace androidnative.jar, but the build doesn't work.
    Thanks
    EDIT:

    I got it working by doing:

    - right click in package explorer-> new->other->search android->android project from existing code->
    -> browse for the code provided-> select all +copy projects into workspace-> right click on facebook project->

    rmeove-> it appears a facebook blue folder-> double click on it-> all errors should be gone.
    -File->export->java->jar->select only Android native-src-> compress jar file export generated classes->

    The file exported is good.

    CHARTBOOST:

    copy chartboost.jar&chartboost_unity_android_bridge.jar from chartboost in your unity project(after you import the

    plugin) in libs(to your android native eclipse project)->right click-> refresh
    now you can:import com.chartboost.sdk.*; and do all from:
    https://help.chartboost.com/documentation/unity/delegates#conflicts
    except onstart (outdated)

    Generate new jar and use android manifest from page 4 of this topic.
     
    Last edited: Apr 24, 2014
  40. anshVol

    anshVol

    Joined:
    May 21, 2013
    Posts:
    12
    I want to know how do I get to know the state of the achivement i.e if the achivement is unlocked or not
    I am doing this and its updating the state of the achivement every frame
    void Update()
    {
    if (PlayerPrefs.HasKey("FIRSTPLAY"))
    {
    GooglePlayManager.instance.reportAchievement("achievement_FirstPlay");
    }
    }
     
  41. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    this page says it has a resolution; https://developers.google.com/mobile-ads-sdk/docs/admob/intermediate

    i want to place a banner to my empty space. on my tablet it is 320x50 as that link says. when i run the same application on my note 3 banner size is around 960x150 which is 3 times bigger than expected.i think there is a parameter like density. i will examine that. as i understand i cannot get the resolution of created banner.
     
  42. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    There is two ways actually.
    1) You can listen for ACHIEVEMENT_UPDATED event. When you call any interaction achievement function (increase, re, reveal)

    2) You can call loadAchivments function on your app start. As soon as all achievements info will be loaded you will get ACHIEVEMENTS_LOADED event. And you can accesses achievements data using this getter:
    Code (csharp):
    1. public Dictionary<string, GPAchievement> achievements

    Yep, there is resolutions there. But i noticed that banner is same size (not resolution ) on any device.
    and there is no API with can allow us to set or get created banner resolution.
    I assume it due to some ad policy, that ad should be fixed size. I mean if for example we will show 320x50 banner and on Nexus7 for example it will be too small end not ever readable, That's why google api is controlling that.
     
  43. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    thanks for answer lacost.

    i wrote my own plugin that makes different things than yours. i want to use both mine and yours. is it possible? i see debug logs that OnCreate is called on just main activity. does it mean there will be just one activity? can i run another plugin beside yours?
     
  44. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
  45. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    so the only way is to extend your activity. i cannot add add second activity to AndroidManifest.xml. that will make my plugin to dependent to your plugin. when i want to use my plugin without your plugin i have to extend UnityPlayerActivity.

    is it unity restriction that only one activity can be used with Unity?

    Edit:On each update of your plugin if i forget to deselect that file it overrides AndroidManifest.xml file. do you have any suggestion to keep custom changes on this file?

    I think you implemented major functions in AdMob like Gender. For example i need birthdate like this;

    Code (csharp):
    1. AdRequest request = new AdRequest.Builder()
    2.     .setGender(AdRequest.GENDER_FEMALE)
    3.     .setBirthday(new GregorianCalendar(1985, 1, 1).getTime())
    4.     .setLocation(location)
    5.     .build();
    how can i do that?
     
    Last edited: Apr 29, 2014
  46. Deleted User

    Deleted User

    Guest

    So I just purchased the admob plugin, because my free ad solution, stopped being clickable....so after install, clickable ads..that is great...but, I found out that my game services connection kept crashing my game, when I came back from leader boards or achievements.
    So I thought, well my version of Free NerdGPG Plugin is conflicting with your ad generator (MAIN Thread), so I Deleted It, bought the whole Native Plugin.. (I am $45.00 in) thinking that would solve it..It Does Not...

    New Project, Your Example, My Existing Game Credentials/Data/Name/Keystore...build..FAIL..Facebook Manifest.XML is conflicting on the merge..I do not remember seeing anything about that in documentation!...

    So After getting a clean apk..it runs I can log in..I can pull Data, Push Data ..but, Can Not view Native Google Play Services Dialog..and come back to my game...Period, My Game, Your example..it does not matter..so I have been trying to figure out for two days, how I can actually see that crash error, eclipse/ADT..things I really do not want to do...but I am trying to do today....I have no clue, why..where do I start? I log in, do everything else..the only explanation??... a thread call from your listener script, trying to rejoin the main activity...?? The game is on my signature, it has working ads/Play services, I just wanted to upgrade, now I have to revert??

    p-....
     
  47. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    i added this function to my plugin. i multiply (320x50) with density and get the exact resolution of the banner.

    Code (csharp):
    1.     public float getDensity() {
    2.         DisplayMetrics dm = new DisplayMetrics();
    3.         getWindowManager().getDefaultDisplay().getMetrics(dm);
    4.  
    5.         return dm.density;
    6.     }
    7.  
     
  48. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Yep that is Unity restrictions Unfortunately.

    Thanks for letting me know, will do this in the next update.

    I am really sorry to hear that you have so much issues. But actually I do not understand what is going wrong for you.
    1) All plugins (IOS Native, Android Native, Google Mobile Ad, Mobile Social plugins) should absolutely compatible, if you are using lates version of all plugins.
    2) There can be few reasons for crash
    * Set up problem
    * Plugin bug (I do me best to fix it as fast as possible if I got bug confirmation)
    But to find you exact crash reason I need to see the log.

    I will PM you my Skype id and we will try to solve you problems.
     
  49. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,459
    Hi Stan,

    Is there a way to get access to the built-in SQLite with your IOS and Android assets?

    Cheers.
     
  50. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    No, I do not have this feature currently.