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

Mobclix plugin that works with Unity 3.2

Discussion in 'Android' started by Wozik, Feb 17, 2011.

  1. Wozik

    Wozik

    Joined:
    Apr 10, 2009
    Posts:
    662
    And just to complement Open Feint and Ad Mob plugins for Unity Android, here's the basic implementation of Mobclix plugin.

    Please try it out and share your experience.

    We provide it for free and we'd be really grateful for any contribution that makes sense.

    Regards,
    Unity Android team
     

    Attached Files:

  2. Curious

    Curious

    Joined:
    Nov 19, 2009
    Posts:
    334
    Thank you thank you thank you :D

    Downloading now... ;)
     
  3. DstruX

    DstruX

    Joined:
    Jun 10, 2008
    Posts:
    75
    Thanks much for the pluggin.
    I have it working in my app displaying the 300x250 test ad, but cant seem to get it to display the 300x50 test ads.
    I have them enabled in test mode in mobclix for the app.
    Is there something else I have to do to display the 320x50?
    Thanks for your help.
     
    Last edited: Feb 18, 2011
  4. sinxtanx

    sinxtanx

    Joined:
    Feb 18, 2011
    Posts:
    25
    I tried to run the MobclixTest script with the editor set to android, but I get a message saying:

    JNI: Unable to find method id for 'getAd'
    UnityEngine.AndroidJavaObject:Call(String, Object[])

    Am I correct in assuming that you have to run it on an actual phone to get ads?

    EDIT: turns out I was correct
     
    Last edited: Feb 18, 2011
  5. legion

    legion

    Joined:
    Feb 9, 2011
    Posts:
    174
    Thanks a lot for this as we are most likely going to use MobClix.
     
  6. Wozik

    Wozik

    Joined:
    Apr 10, 2009
    Posts:
    662
    killsage, here at Unity we just wanted to make the bootup easier, so we don't support/maintain these plugins we made.
    The sources are provided, so it's the community who should chime in and adapt these for custom needs.
     
  7. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    I had the same problem, but solved it by doing this:

    1.) Open up "Plugins/Android/src/MobclixTestActivity.java", and change the following 2 lines:

    Code (csharp):
    1. public static MobclixIABRectangleMAdView adView;
    2.  
    3. ...
    4.  
    5. adView = new MobclixIABRectangleMAdView(this);
    to this:

    Code (csharp):
    1. public static MobclixMMABannerXLAdView adView;
    2.  
    3. ...
    4.  
    5. adView = new MobclixMMABannerXLAdView(this);
    The "new LayoutParams(300, 250)" code doesn't seem to affect it, but you can change that to "new LayoutParams(320, 50)" too.

    2.) This is using a Mac, might be different on Windows, but using Terminal, go to the "Plugins/Android/" folder, and run:

    ant build-jar

    This re-builds the compiled .class and .jar files.

    Note: You have to update the file "local.properties" to point to where you installed the Android SDK, or ant will fail.

    3.) Now build the Android app again and try it on your device.

    I haven't found out how to position the ad though (especially when running landscape mode), or how to make it rotate when you rotate the phone.
     
    Last edited: Feb 22, 2011
  8. Curious

    Curious

    Joined:
    Nov 19, 2009
    Posts:
    334
    Thanks for the info TMK, really useful

    Regards,
    Curious
     
  9. DstruX

    DstruX

    Joined:
    Jun 10, 2008
    Posts:
    75
    TMK.
    Thanks so much! That was exactly it. Works like a charm.
     
  10. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    Great to hear that! Now we just have to figure out how to move the ad around (and how to rotate it when you rotate the phone) :)
     
  11. JoshOClock

    JoshOClock

    Joined:
    Dec 8, 2010
    Posts:
    107
    It took me a while to figure out the changes for windows. Maybe no one else has tried or everyone is smarter than me.

    Windows users I suggest the following steps on top of TMK's steps:

    1) Create a clean unity project called CleanMobclix and install the above package in there as well as in your game, and run it once to make sure you see the 320x250 ad you should see by default. (Make sure you're connected to the internet or you won't see anything).

    2) In your CleanMobclix project - Open up "Plugins/Android/build.properties" and change external.libs.absolute.dir to point to something like this (wherever you installed Unity to):
    Code (csharp):
    1. external.libs.absolute.dir=/Program Files (x86)/Unity/Editor/Data/PlaybackEngines/androidplayer/bin
    3) Again in CleanMobclix project - Open up "Plugins/Android/local.properties" and change sdk.dir to point to something like this (wherever you installed your Android sdk)
    Code (csharp):
    1. sdk.dir=/android-sdk-windows
    and then follow TMK's steps here:

    4) Finally copy the MobclixActivity.jar from your CleanMobclix project to your actual game and you should see the smaller ads.

    I recommend the extra steps just in case anything goes wrong... as long as you keep a backup of the original MobclixActivity.jar that came with the package you can get back to a non-broken state.

    ...And this is all assuming you've installed the JDK and ANT and added them to your PATH.
     
    Last edited: Mar 15, 2011
  12. Prakash

    Prakash

    Joined:
    Oct 20, 2010
    Posts:
    9
    It gives me 12 error while executing build-jar command...Can anyone help me on this?

    Please see below log for reference.

    $Screen shot 2011-03-07 at 4.59.13 PM.png
     
  13. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    Have you edited the file "local.properties" to point to where you installed the Android SDK? I don't remember exactly what kind of error message I got when I hadn't done that, but it was something similar to what you are getting...
     
  14. Prakash

    Prakash

    Joined:
    Oct 20, 2010
    Posts:
    9
    Now its working nd I am able to see ads from Mobclix, but how can I set the ads to landscape left orientation?
     
  15. Joshua_Falkner

    Joshua_Falkner

    Joined:
    Feb 19, 2010
    Posts:
    45
    Thanks JoshOClock - but step 3 of your instructions should read Plugins/Android/local.properties. Appreciate the info!
     
  16. benhigg

    benhigg

    Joined:
    Aug 3, 2010
    Posts:
    34
    I'm getting this error when I try to rebuild the package using the instructions for getting the 320x50 ads.

    I'm following the Windows instructions.

    BUILD FAILED
    F:\SoundMaker\Assets\Plugins\Android\build.xml:46: taskdef class com.android.ant
    .SetupTask cannot be found
    using the classloader AntClassLoader[]

    I'm pretty sure I've got everything pointed to the right place, but I can't get it to find that class.
     
  17. legion

    legion

    Joined:
    Feb 9, 2011
    Posts:
    174
    Got a question about this. How do we get the application id? And any other id's we need?
    As i understand it you seem to have to upload the app first and get some sort of id from google, then
    add that id to mobclix as an app, do you get the id after that so you can add it to your app?

    I'm confused :)
     
  18. benhigg

    benhigg

    Joined:
    Aug 3, 2010
    Posts:
    34
    Ugh... when you run the build off of the F: drive, I guess you need to specify that the sdk is on the c: drive, huh?

    Feeling a bit of an idiot now.
     
  19. JoshOClock

    JoshOClock

    Joined:
    Dec 8, 2010
    Posts:
    107
    Just register on Mobclix.com and then 'Add an Application' fill it out and you'll see your ID in the list. It doesn't have anything to do with Google ID or anything. It's a value your app sends to mobclix for revenue tracking. And can be used for iOS or Android.
     
  20. JoshOClock

    JoshOClock

    Joined:
    Dec 8, 2010
    Posts:
    107
    READ THIS IF YOU'RE USING THIS PACKAGE!!!
    READ THIS IF YOU'RE USING THIS PACKAGE!!!

    Make sure you download the latest SDK and drop the mobclix.jar it comes with over the one that comes with the the unitypackage at the top of this thread.

    The one in the unitypackage requests 'root' as mobclix was using it to do some testing. People won't DL your game if you have that... and likely give you '1 star' to warn others as it appears suspicous.
     
  21. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    Oh, thanks for letting us know JoshOClock! I added Mobclix today actually with the previous version, quickly changed it to the newest one now! :)

    By the way, a heads up for others, Unity adds the correct value to the AndroidManifest.xml file to make it install to SD by default (App2SD), but since you have to override it with the Mobclix-added AndroidManifest.xml, Unity doesn't add this value to games compiled with it.

    You need to add 'android:installLocation="preferExternal" ' to the AndroidManifest.xml file in the Plugins/Android folder. I also added the "supports-screens" line too since Unity didn't add that line either. Here's how it looks in the file:

    Without this apps won't be installed to SD by default.
     
  22. JoshOClock

    JoshOClock

    Joined:
    Dec 8, 2010
    Posts:
    107
    I was wondering about that TMK... thanks...

    I seem to have an issue now where my icons are showing up as some weird standard Android one. I believe integrating this package caused it. Anyone seen that? Or know of a fix?
     
  23. legion

    legion

    Joined:
    Feb 9, 2011
    Posts:
    174
    Seems you misunderstood me perhaps. On mobclix when i try to add an app i have to fill in the Android Market Information
    Package ID. Which i dont seem to have, unless i have uploaded an apk to my merchant account?

    So in essence this is the procedure i have to do?
    Upload apk to android.
    Get the package id.
    Add application to mobclix and type in the application id.
    add mobclix id number to the game, build a new apk
    upload apk
    publish game.
    Is this the way i have to do it?
     
  24. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    Ah, yep, those get overrided too, you need to replace these icons:

    Assets\Plugins\Android\res\drawable-hdpi\icon.png
    Assets\Plugins\Android\res\drawable-ldpi\icon.png
    Assets\Plugins\Android\res\drawable-mdpi\icon.png
     
  25. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    Legion: I don't believe you have to upload APK or write the package ID on the Android Developer account (merchant account), I couldn't find any place I've entered it there at least.

    The package ID I entered into Mobclix is the same "Bundle Identifier" I entered on the "Player Settings" in Unity Android, which is located under the "Other Settings" tab. I used the same bundle ID style as on iPhone, so I use this style:

    com.kristanix.android.PRODUCT
     
  26. JoshOClock

    JoshOClock

    Joined:
    Dec 8, 2010
    Posts:
    107
    Legion: Confirming TMK's info. Just type in there whatever it will be. I honestly don't even think they use that info for anything, maybe just records or something? I've put in my application ID on other apps with different Bundle ID's and ads show up fine. So you don't have to worry if it's wrong or you change it later.
     
  27. legion

    legion

    Joined:
    Feb 9, 2011
    Posts:
    174
    Thanks for the replies, we did manage to figure it out ourselves finally :p
     
  28. lightbringer

    lightbringer

    Joined:
    Jul 30, 2009
    Posts:
    14
    How do you grab the current UnityPlayer activity to be able to pass it to Mobclix?

    I've modified the example so rather then extending UnityActivity it receives it so it can create the banner. I do this so I can create the adView via runOnUiThread() and call setVisibility() on the adView whenever I please.
     
  29. JoshOClock

    JoshOClock

    Joined:
    Dec 8, 2010
    Posts:
    107
    Not relevant to Unity or the plug-in in question, but an FYI if you're choosing mobclix for your Ads.

    To use Mobclix you will have to ask for a few more permissions than with Admob (AFAIK they just want to check for an internet connection). A few friends that have Androids mentioned that usually if they see that many permissions they won't install the game.

    I'm not sure how many installs this could cost you. And since learning this I still use mobclix... but it's food for thought.
     
  30. Lostlogic

    Lostlogic

    Joined:
    Sep 6, 2009
    Posts:
    693
    I'm trying this on a build and it shows in the box "An error has occured. Click here for details". I click, and it takes me to web-page saying the application ID may not be set, or the app may not be set for the size of ads?

    Any suggestions on how to fix this? I've re-entered my Application ID 4 times now and am sure it matches what is on the Mobclix dashboard.
     
  31. Lostlogic

    Lostlogic

    Joined:
    Sep 6, 2009
    Posts:
    693
    Has anyone made a version of this that displays the wider (but smaller) ads, and allows positioning? The version provided, while nice, seems very lacking in usefulness.
     
  32. lincthra

    lincthra

    Joined:
    Apr 5, 2011
    Posts:
    5
    *L* Oi. I do web JS, PHP, VB and others (but never Java) and for some reason I have had massive issues getting my head around this. I finally get the ads somewhat working and try to look up how to rotate them to landscape and my brain explodes all over again.

    Mike
    Black Feather Productions
     
  33. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    Unfortunately I haven't found a way to rotate or move the ads either, so I ended up just using it's default location and disabling rotation for the game. Angry Birds on Android also doesn't support rotation, so I assume if they don't need it... :)

    Hopefully someone will figure out how to do rotate/move the ads though! :)
     
  34. lincthra

    lincthra

    Joined:
    Apr 5, 2011
    Posts:
    5
    I don't need to actively support rotation, per se. I just need to figure how getting them displayed in landscape for the whole time.

    Mike
    Black Feather Productions
     
  35. Rom-

    Rom-

    Joined:
    Nov 26, 2008
    Posts:
    90
    Any updates to this plugin? Particularly, I have to the need to switch from banner ads to full screen ads at certain points in my game (inbetween levels).
     
  36. sheva

    sheva

    Joined:
    Nov 22, 2010
    Posts:
    157
    Hi Guys,
    Can anybody explain me this step, pleaseeeee ?
    cause I dunno how to run : ant build-jar .. I can't find it.
    Thank you.
     
    Last edited: Nov 14, 2011
  37. unitynewb

    unitynewb

    Joined:
    Feb 22, 2009
    Posts:
    243
    Can anyone help me out? I'm trying to get 320x50 working:

    I'm getting this when running ant build-jar

    Code (csharp):
    1.  
    2. BUILD FAILED
    3. c:\App002\Assets\Plugins\Android\build.xml:46: taskdef clas
    4. s com.android.ant.SetupTask cannot be found
    5.  using the classloader AntClassLoader[]
    6.  

    I looked online and they said the solution was to run android update project --path .
    When I run it I get this:
    Code (csharp):
    1.  
    2. build.xml: Failed to find version-tag string. File must be updated.
    3. In order to not erase potential customizations, the file will not be automatical
    4. ly regenerated.
    5. If no changes have been made to the file, delete it manually and run the command
    6.  again.
    7. If you have made customizations to the build process, the file must be manually
    8. updated.
    9. It is recommended to:
    10.         * Copy current file to a safe location.
    11.         * Delete original file.
    12.         * Run command again to generate a new file.
    13.         * Port customizations to the new file, by looking at the new rules file
    14.           located at <SDK>/tools/ant/build.xml
    15.         * Update file to contain
    16.               version-tag: custom
    17.           to prevent file from being rewritten automatically by the SDK tools.
    18.  
    I then thought it probably the values I set in the property files. So I went in and put double \\ for the paths like c:\\android\\android-sdk

    That gave me the same error I get after I run the android update project which is:
    Code (csharp):
    1.  
    2. c:\App002\Assets\Plugins\Android\build.xml:87:
    3.  
    4. Error. You are using an obsolete build.xml
    5. You need to delete it and regenerate it using
    6.         android update project
    7.  
    8.  
    9.  
    I then removed the <setup /> line from line 87 and I received the following:
    Code (csharp):
    1.  
    2. BUILD FAILED
    3. Target "compile" does not exist in the project "MobclixTest". It is used from ta
    4. rget "build-jar".
    5.  
     
    Last edited: Feb 2, 2012
  38. unitynewb

    unitynewb

    Joined:
    Feb 22, 2009
    Posts:
    243
    I figured it out. Has anyone figured out how to center the ad?
     
  39. hs1S

    hs1S

    Joined:
    Jul 23, 2009
    Posts:
    153
    How did you fix that? I tried to change settings, update project and nothing...

    I'm using windows 7 and the sdk tools rev 16, and it looks like none of the instructions to customize these two plugins ( admob and mobclix ) works.
     
    Last edited: Mar 5, 2012
  40. unitynewb

    unitynewb

    Joined:
    Feb 22, 2009
    Posts:
    243
    What error are you getting?
     
  41. ShadoVv

    ShadoVv

    Joined:
    Jan 10, 2012
    Posts:
    3
    Hi, I stuck on this same place as unitynewb, I recive error:

    Code (csharp):
    1.  
    2.  
    3.     BUILD FAILED
    4.     Target "compile" does not exist in the project "MobclixTest". It is used from ta
    5.     rget "build-jar".
    6.  
    7.  
    Could you tell me how do you resolve it?
     
    Last edited: Apr 24, 2012
  42. ShadoVv

    ShadoVv

    Joined:
    Jan 10, 2012
    Posts:
    3
    Resloved.

    I opened project in eclipse, added missing library, fixed all errors, and exported .jar file, whith I changed with old file: "MobclixTestActivity.jar".
     
  43. Allebi

    Allebi

    Joined:
    Oct 4, 2011
    Posts:
    120
    Hi there,
    Could someone please tell me how to hide Ads when it isn't needed?
    Since it's stay on screen whole time ...
     
  44. wizarden

    wizarden

    Joined:
    Aug 5, 2012
    Posts:
    2
    I need help - with MobclixTest I receive errors in my log :

    MobclixTestActivity (server) - consumer closed input channel or an error occured.

    So, I didnt see any banners, but statistics on Mobclix site shows my activity (users/devises, but any banners).
    What I doing wrong? )
     
  45. 3dskimaps_tech

    3dskimaps_tech

    Joined:
    Jan 20, 2013
    Posts:
    1
  46. CuddlyBunnie

    CuddlyBunnie

    Joined:
    Jan 25, 2013
    Posts:
    26
    Just a quick note to everyone viewing this, I really so strongly wouldn't recommend Mobclix if you ever want to be paid. there 8 months late and just ignoring emails now. Use Admob or anyone else really. There are actually quite a few to choose from that come with plugins that are super easy to implement, for example:

    Appbrain do an appwall that pays well and takes about 30 seconds to put in( i would also recomond using these guys for advertising a game aswell).

    Revmob have a load of options for ads.

    Heyzap Have ads, leaderboards, achievements and Facebook integration (very simple to implement all of this aswell).

    Admob I actually put up a plugin (its free) that is as simple as putting a prefab in your scene although its only really useful for banner ads.

    There are a few others around as well like placeplay but the ones above I've had good experiences with. If you have a look around on the forum you will see its not only me that isn't getting paid by Mobclix, its everyone and its been like this for a long time.
     
    Last edited: Feb 4, 2013