Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Pointers on using Admobs — Gideros Forum

Pointers on using Admobs

private_kennyprivate_kenny Member
edited January 2015 in Game & application design
Hi,

I now intend to use probably admob on my mobile game.

I have several questions.
1. First is an issue I encountered. Linking admob to the test environment

I used the following code from http://giderosmobile.com/tools/admob

While debugging using the Gideros Player, I received the following error
module 'admob' not found:

2. How to link admob to the game in playstore?

3. The proper procedure for implementation for ads. I should complete everything ahead first. Launch the application in Playstore or AppStore. Then link admob to an account given?


3. What is the real meaning of CPM?
It states that Cost per thousand iMpressions. Does it refers to the money received per 1000 click?





Comments

  • 1. You have 2 options.
    To build your own specific gideros player with ads plugin or don't debug using player at all.
    You can use code like this
    if application:getDeviceInfo()=="Android" then
    require "ads"
    admob = Ads.new("admob")
    admob:setKey("your_key")
    admob:showAd("smart_banner")
    admob:setAlignment("center", "bottom")
    end

    2. You can link your game with admob in admob interface. I'm not sure that it is necessery, but you can do it.

    3. Sry, can't understand what you mean. You don't need to link admob with your game at all. Only if you want.

    4. No. It is more like money per 1000 impressions(shows). But not really sure about that.
  • How does admob credit to the developer then?
    Based on "your_key"?
  • Yes, you login to admob.com by your gmail, and create ad unit and then you get the key to fill in admob:setKey("your_key"). After you earn 10$, you can complete payment info and google will send you money...
    Coming soon
  • 100$ as much as i know.
  • Without knowing your_key first.

    I need to
    1. complete my development (including admob api and plugin) for the application.
    2. launch in playstore (eg. for android)
    3. Use admob to tie to application to get the key
    4. Then recompile game with key
    5. Relaunch in playstore?

    Is the procedure correct?
  • Nope, you don't need to launch anything to get your_key.
    Just put a name-only application on admob, and get the key.

    This also applied on any other ad network.

    You can link the app on ad network to store later on, it's not necessary though.
  • I have added a simple Admob code to be launched.
    require "ads"
    admob = Ads.new("admob")
    admob:setKey("your_key")
    admob:showAd("smart_banner")
    admob:setAlignment("center", "bottom")

    I tried to find admob SDK but realised that its no longer available as a standalone SDK and required me to download google play services instead.

    Updated both the Application and Permissions tag as mentioned in
    http://docs.giderosmobile.com/interface/ads
    I couldn't find AdsMob.java since Google Play Services is installed instead. Hence, I followed the linking procedure of google play services by importing the library to Eclipse and link my application to the library.

    The application had problem launching with the simple ad code as shown above.
  • @private_kenny the right filename is AdsAdmob.java

    And please also post what you have in logcat, so we could see what error you have ;)
  • I am just showing the logcat errors.
    admob:showAd("banner") shows nothing(just a bar), would a
    admob:hideAd("banner") call crashes the application?

    01-15 21:30:36.534: E/VCharge(115): vcharged write
    01-15 21:30:46.535: E/VCharge(115): vcharged write
    01-15 21:30:56.541: E/VCharge(115): vcharged write
    01-15 21:31:06.534: E/VCharge(115): vcharged write
    01-15 21:31:16.535: E/VCharge(115): vcharged write
    01-15 21:31:26.534: E/VCharge(115): vcharged write
    01-15 21:31:36.535: E/VCharge(115): vcharged write
    01-15 21:31:46.534: E/VCharge(115): vcharged write
    01-15 21:31:56.541: E/VCharge(115): vcharged write
    01-15 21:32:06.534: E/VCharge(115): vcharged write
    01-15 21:32:10.524: E/AudioMTKHardware(134): setCommonParameters() still have param.size() = 1, remain param = "screen_state=on"
    01-15 21:32:16.542: E/VCharge(115): vcharged write
    01-15 21:32:16.672: E/(134): AudioCloseDumpPCMFile file== NULL
    01-15 21:32:16.672: E/(134): AudioCloseDumpPCMFile file== NULL
    01-15 21:32:19.608: E/Trace(6793): error opening trace file: No such file or directory (2)
    01-15 21:32:19.729: E/linker(6793): load_library(linker.cpp:759): library "libmaliinstr.so" not found
    01-15 21:32:26.541: E/VCharge(115): vcharged write
    : E/(): Device disconnected
  • Hmm.. By removing admob:hideAd("banner"), it does not crashes. However, I did not see any Ads before hand. Do I need to loadAd() first?
  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    you can also subscribe to events to see if it is working or provides any errors
    admob:addEventListener(Event.AD_RECEIVED, function(e)
    	print("ads AD_RECEIVED", e.type)
    end)
     
    admob:addEventListener(Event.AD_FAILED, function(e)
    	print("ads AD_FAILED", e.type, e.error)
    end)
     
    admob:addEventListener(Event.AD_ACTION_BEGIN, function(e)
    	print("ads AD_ACTION_BEGIN", e.type)
    end)
     
    admob:addEventListener(Event.AD_ACTION_END, function(e)
    	print("ads AD_ACTION_END", e.type)
    end)
     
    admob:addEventListener(Event.AD_DISPLAYED, function(e)
    	print("ads AD_DISPLAYED", e.type)
    end)
     
    admob:addEventListener(Event.AD_DISMISSED, function(e)
    	print("ads AD_DISMISSED", e.type)
    end)
     
    admob:addEventListener(Event.AD_ERROR, function(e)
    	print("ads AD_ERROR", e.error)
    end)
    and also try enabling test ads, just in case yours is not getting any ads now:
    admob:enableTesting()
  • Ah thanks! With enableTesting and logcat, I finally knew what was the problem:

    01-16 22:03:23.946: W/Ads(31087): Invalid unknown request error: [Cannot determine request type. Is your ad unit id correct?]
    01-16 22:03:23.955: W/Ads(4547): There was a problem getting an ad response. ErrorCode: 1

    I did not applied for an ad unit because I have not decided on the application name yet. I am worried that once I decided on a name and if the name is taken up subsequently, I might have a problem with recompiling and require me to relaunch the game.

    Anyway great help guys!
    I have done a last min support for Gideros on kickstarter for Win 8 development :D

    Likes: ar2rsawseen

    +1 -1 (+1 / -0 )Share on Facebook
  • Oh no..
    I halted on my game application to focus on my other stuff.
    Just came back and got stucked here again.

    This time, the logcat gives me this:
    04-06 21:43:37.336: E/SMD(282): DCD ON
    04-06 21:43:40.336: E/SMD(282): DCD ON
    04-06 21:43:40.766: E/art(893): No implementation found for void org.codeaurora.Performance.native_deinit() (tried Java_org_codeaurora_Performance_native_1deinit and Java_org_codeaurora_Performance_native_1deinit__)
    04-06 21:43:40.766: E/System(893): Uncaught exception thrown by finalizer
    04-06 21:43:40.776: E/System(893): java.lang.UnsatisfiedLinkError: No implementation found for void org.codeaurora.Performance.native_deinit() (tried Java_org_codeaurora_Performance_native_1deinit and Java_org_codeaurora_Performance_native_1deinit__)
    04-06 21:43:40.776: E/System(893): at org.codeaurora.Performance.native_deinit(Native Method)
    04-06 21:43:40.776: E/System(893): at org.codeaurora.Performance.finalize(Performance.java:97)
    04-06 21:43:40.776: E/System(893): at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:190)
    04-06 21:43:40.776: E/System(893): at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:173)
    04-06 21:43:40.776: E/System(893): at java.lang.Thread.run(Thread.java:818)
    04-06 21:43:40.776: E/art(893): No implementation found for void org.codeaurora.Performance.native_deinit() (tried Java_org_codeaurora_Performance_native_1deinit and Java_org_codeaurora_Performance_native_1deinit__)
    04-06 21:43:40.776: E/System(893): Uncaught exception thrown by finalizer
    04-06 21:43:40.776: E/System(893): java.lang.UnsatisfiedLinkError: No implementation found for void org.codeaurora.Performance.native_deinit() (tried Java_org_codeaurora_Performance_native_1deinit and Java_org_codeaurora_Performance_native_1deinit__)
    04-06 21:43:40.776: E/System(893): at org.codeaurora.Performance.native_deinit(Native Method)
    04-06 21:43:40.776: E/System(893): at org.codeaurora.Performance.finalize(Performance.java:97)
    04-06 21:43:40.776: E/System(893): at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:190)
    04-06 21:43:40.776: E/System(893): at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:173)
    04-06 21:43:40.776: E/System(893): at java.lang.Thread.run(Thread.java:818)

    I have re-exported the project.
    Anyways, just for clarifications, I'll post some snippet of code here:

    AdmobController.lua
    require "ads"

    AdmobController = gideros.class(BaseSprite)

    function AdmobController:init()
    self.bAdisUp = false
    end

    function AdmobController:showAd()
    if application:getDeviceInfo()=="Android" then
    self.admob = Ads.new("admob")
    self.admob:setKey("ca-app-pub-XXXXXXXXX/XXXXXXXXXX")
    self.admob:enableTesting()
    self.admob:showAd("banner")
    self.admob:setAlignment("center", "top")

    end
    end

    function AdmobController:hideAd()
    if application:getDeviceInfo()=="Android" then

    end
    end

    function AdmobController:onAddedtoStage(event)
    self.admob:addEventListener(Event.AD_RECEIVED, function(e)
    print("ads AD_RECEIVED", e.type)
    end)

    self.admob:addEventListener(Event.AD_FAILED, function(e)
    print("ads AD_FAILED", e.type, e.error)
    end)

    self.admob:addEventListener(Event.AD_ACTION_BEGIN, function(e)
    print("ads AD_ACTION_BEGIN", e.type)
    end)

    self.admob:addEventListener(Event.AD_ACTION_END, function(e)
    print("ads AD_ACTION_END", e.type)
    end)

    self.admob:addEventListener(Event.AD_DISPLAYED, function(e)
    print("ads AD_DISPLAYED", e.type)
    end)

    self.admob:addEventListener(Event.AD_DISMISSED, function(e)
    print("ads AD_DISMISSED", e.type)
    end)

    self.admob:addEventListener(Event.AD_ERROR, function(e)
    print("ads AD_ERROR", e.error)
    end)
    end

    function AdmobController:onRemovedFromStage(event)
    end

    GameScene.lua

    function GameScene:init()
    self.admobControl = AdmobController.new()
    end

    function GameScene:onAddedtoStage(event)
    self.addChild(self.admobControl)
    if (self.randomchance == 5) then
    self.admobControl:showAd()
    end
    end





  • ar2rsawseenar2rsawseen Maintainer
    I'm sorry I have no idea what org.codeaurora.Performance package is for, but I have not seen it not only in Ads interface, but not in entire Gideros :)

    But the lua code you posted seems legit
  • Just to confirm.
    Can I try to test this on Gideros player?
    Or only able to test this on specific platforms. Eg. Eclipse.
    require "ads" cannot be found in gideros even if I build Gideros from scratch
  • Anyways, that error got no relationship with the crash. I tried on another mobile phone. no errors were shown on Logcat, but the application crashed nevertheless.
  • After downloading the latest ads and linking the libads.so from the directory, this is the error I got from Logcat

    04-07 14:50:59.287: E/libEGL(14357): call to OpenGL ES API with no current context (logged once per thread)
    04-07 14:51:00.400: E/VCharge(119): vcharged write
    04-07 14:51:01.570: E/(139): AudioCloseDumpPCMFile file== NULL
    04-07 14:51:01.570: E/(139): AudioCloseDumpPCMFile file== NULL
  • Finally... Able to see the ads successfully but very rarely.

    Now I get a verbose

    04-07 17:34:52.442: D/Gideros(31017): /Users/xxx/Documents/XXXXX/XXXX/assets/assets/scripts/gameScene/admobController.lua.jet:1: module 'ads' not found:
    04-07 17:34:52.442: D/Gideros(31017): no field package.preload['ads']
    04-07 17:34:52.442: D/Gideros(31017): no file './ads.lua'
    04-07 17:34:52.442: D/Gideros(31017): no file '/usr/local/share/lua/5.1/ads.lua'
    04-07 17:34:52.442: D/Gideros(31017): no file '/usr/local/share/lua/5.1/ads/init.lua'
    04-07 17:34:52.442: D/Gideros(31017): no file '/usr/local/lib/lua/5.1/ads.lua'
    04-07 17:34:52.442: D/Gideros(31017): no file '/usr/local/lib/lua/5.1/ads/init.lua'


    I have the libads.so files in armeabi, armeabi-7v, x86
    I have edited the manifest file to include google play
    I have edited my mainActivity.java to include
    System.loadLibrary("ads");
    "com.giderosmobile.android.plugins.ads.Ads",
    I have included the files
    com.giderosmobile.android.plugins.ads
    com.giderosmobile.android.plugins.ads.framework

    What did I missed?

  • ar2rsawseenar2rsawseen Maintainer
    That is interesting, that with such error you would be able to see ads at all.

    It is really hard to say, but back tracing it like:

    If lua can't see plugin, it means either libads.so file is not present or is incorrect (like using armeabi binary for x86, or something like that)

    and in the same case, as you say, you have included System.loadLibrary("ads"); then it would give Unsatisfied link error if it could not find libads.so

    So either you included System.loadLibrary("ads"); in the wrong place and app does not look for it, or it finds it, but lua can't use it, because it is for incorrect platform or damaged.

    Unfortunately thats all I can deduct from the info I have :)
  • I dun know but it seems that after restarting the mobile phone, the ads seems to appear :D.

    Let me close this thread!
    Thanks ar2rsawseen
  • ar2rsawseenar2rsawseen Maintainer
    Then it might something to do with mystical .so file cache on android
    glad it was resolved :)
  • Thanks ar2rsawseen. I got another question regarding the Apprater that u maintained on Github.
Sign In or Register to comment.