Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
[Solved] Problem running adMob on Android — Gideros Forum

[Solved] Problem running adMob on Android

Tom2012Tom2012 Guru
edited August 2015 in General questions
Hello :)

Can someone please take a look over these steps and see if there's anything glaringly obvious that I've done wrong?

The apk builds without errors in Android studio but the app crashes on device (it's just a blank hello world type app).

Thanks!

EDIT: Solved, and these steps now do the job:

Here's how I get Admob ads on my Android app:

DO ON PC if possible as Mac does weird things when copying folders.

1) Download plugins from Gideros github

2) Export project from Gideros (to Eclipse)

2a) Move gideros.jar to libs

2a) If you’re making a Gideros player, delete the assets folder within [exported project]/assets/

3) Go into the Gideros plugins folder

4) Then /ads/source/Android

5) Copy folders: libs and src to [exported project] folder

6) For admob, Go into libs and delete everything except:

armeabi/
armeabi-v7a/
x86/

gideros.jar

7) Go into src and click through to frameworks/

8) Delete everything except AdsAdmob.java

9) Open your main java activity file ([exported project]/src/com/giderosmobile/android/projectName.java

10) UNDER under System.loadLibrary("gideros");

Add:

System.loadLibrary("ads");

11) In the same file add this function, replace

static private String[] externalClasses = {
};

with:

static private String[] externalClasses = {
"com.giderosmobile.android.plugins.ads.Ads",
};

12) Open AndroidManifest.xml in [exported project]/app/src/main

13) To the list of permission tags, add:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
14) Add this to the application tag
<!-- google play -->
<meta-data android:name="com.google.android.gms.version" android:value="<a href="https://forum.giderosmobile.com/profile/integer%2Fgoogle_play_services_version%26quot" rel="nofollow">@integer/google_play_services_version&quot</a>; />
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
Make sure each tag takes up one line and isn't broken by a line break. This can cause errors when building the app later.

15) Open your exported project in Android Studio

16) Add the dependency for google play services to your project:

» File
» project structure
» app
» dependencies
» click on +
» library dependency
» select play-services (Something like: com.google.android.gms:play-services:7.5.0)

17) In the Gradle Scripts drop down, look for build gradle:app

Set these values

- minSdkVersion 9 (might change over time - can't be lower than whatever is in google play services)
- compileSdkVersion 22
- targetSdkVersion 22

Comments

  • What does logcat writes about crash?
  • Hi unlying, thanks for the help.

    Here's the output from logcat
    08-12 12:43:10.479  17345-17345/com.giderosmobile.androidtemplate E/AndroidRuntime﹕ FATAL EXCEPTION: main
        Process: com.giderosmobile.androidtemplate, PID: 17345
        java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.giderosmobile.androidtemplate-2/base.apk"],nativeLibraryDirectories=[/data/app/com.giderosmobile.androidtemplate-2/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libads.so"
                at java.lang.Runtime.loadLibrary(Runtime.java:366)
                at java.lang.System.loadLibrary(System.java:989)
                at com.giderosmobile.android.AdsActivity.<clinit>(AdsActivity.java:29)
                at java.lang.reflect.Constructor.newInstance(Native Method)
                at java.lang.Class.newInstance(Class.java:1572)
                at android.app.Instrumentation.newActivity(Instrumentation.java:1088)
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2215)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
                at android.app.ActivityThread.access$800(ActivityThread.java:148)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
                at android.os.Handler.dispatchMessage(Handler.java:102)
                at android.os.Looper.loop(Looper.java:135)
                at android.app.ActivityThread.main(ActivityThread.java:5312)
                at java.lang.reflect.Method.invoke(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:372)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
    The notification on the device is 'unfortunately the app has stopped running;
  • Looks like problem is here: "couldn't find "libads.so""

    5) Copy folders: libs and src to [exported project]/app/

    Try to find this lib thorough file tree in android studio.

    btw, What device do you use?
  • Tom2012Tom2012 Guru
    edited August 2015
    Thanks for the help.

    The crash I have is now:
    08-12 14:54:01.815  27779-27841/? W/Adreno-ES20﹕ <core_glFramebufferRenderbuffer:2833>: GL_INVALID_OPERATION
    08-12 14:54:02.046  27779-27779/? W/ResourcesManager﹕ Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
    08-12 14:54:02.046  27779-27779/? W/ResourcesManager﹕ Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
    08-12 14:54:02.113  27779-27841/? A/libc﹕ Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 27841 (GLThread 93497)
    The lua code I am using is
    require "ads"
    admob = Ads.new("admob")
    admob:setKey("8922743526077835/7874665730")
    admob:showAd("banner")
    admob:setAlignment("center", "bottom")
    stage:addChild(admob)
    If I try this code:
    require "ads"
    admob = Ads.new("admob")
    admob:setKey("8922743526077835/7874665730")
    admob:showAd("banner")
    admob:setAlignment("center", "bottom")
    The app runs fine but the screen is blank.

    Thanks!
  • Oh, my device is a moto g
  • unlyingunlying Guru
    Accepted Answer
    @Tom2012 don't use stage:addChild(admob)

    Try to use alerts on ads events. Like AD_FAILED and AD_RECEIVED. With second option of your code.

    Likes: Tom2012

    +1 -1 (+1 / -0 )Share on Facebook
  • Tom2012Tom2012 Guru
    edited August 2015
    Ah its working. (HAPPY DANCE) :)

    What I was doing wrong was using run straight in Android Studio.

    Once I made my own Gideros Player, and then launched from Gideros Studio, I could see the ad.

    So the big question is - why can't you 'run' your app from Android Studio / Eclipse and see the ads in place. Why does it only work when you first create a player, and then test from Gideros?

    Thanks again for the help guys.
  • I can't find any difference between "gideros player" that you created and another application that you'll create. Sure it will be shown. You can create apk for "your gideros player" and it will work as application. You can even publish it to Play Store.

    Likes: Tom2012

    +1 -1 (+1 / -0 )Share on Facebook
  • Tom2012Tom2012 Guru
    edited August 2015
    @unlying

    You're quite right. It's running fine now as a player or as the actual app.

    EDIT: I've updated my list of steps in the original post in case anyone else is struggling to do this.
Sign In or Register to comment.