About Monkey 2 › Forums › Monkey 2 Programming Help › Problems with Admob
This topic contains 7 replies, has 4 voices, and was last updated by
Mark Sibly
4 months, 2 weeks ago.
-
AuthorPosts
-
November 16, 2018 at 12:01 pm #15609
Hello everyone,
I used to get the ads working with Admob module, but not anymore, after “com.google.android.gms:play-services-ads:17.1.1”.
I suppose something is changed.
After eveyting else failed, I tried to build the Admob banana example. I managed to do that in Android Studio without errors, but it also crashes, when I try to start the app.
Could someone show sample AndroidManifest.xml file one could use with Monkey 2 with ads?
I have made these little lines in Android Studio:
Build.gradle (Project):
Java12345678910allprojects {repositories {jcenter()maven {url "https://maven.google.com"}google()}}Build.gradle (Module):
Java1234dependencies {implementation 'com.android.support:appcompat-v7:27.1.1'implementation 'com.google.android.gms:play-services-ads:17.1.1'}In the Monkey2 app:
Java12345678910111213public class Monkey2Game extends Monkey2Activity{protected void onCreate(Bundle savedInstanceState){super.onCreate( savedInstanceState );MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");}protected void onDestroy(){super.onDestroy();}}And I have implemented the methods for Reward ads.
What else I should take into consideration?
November 23, 2018 at 5:40 pm #15616Anyone? No-one?
November 23, 2018 at 8:10 pm #15617Sorry, haven’t tried mobile at all yet. Hopefully someone who has can reply.
November 30, 2018 at 4:40 pm #15634I have added RelativeLayout to my Android project (layout.xml) just like the instructions say in Google’s Admob page:
Monkey123456789101112131415161718192021222324<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_height="match_parent"android:layout_width="match_parent"android:paddingLeft="@dimen/activity_horizontal_margin"android:paddingRight="@dimen/activity_horizontal_margin"android:paddingTop="@dimen/activity_vertical_margin"android:paddingBottom="@dimen/activity_vertical_margin"tools:context=".Monkey2Game"><com.google.android.gms.ads.AdViewxmlns:ads="http://schemas.android.com/apk/res-auto"android:id="@+id/adView"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerHorizontal="true"android:layout_alignParentBottom="true"ads:adSize="BANNER"ads:adUnitId="ca-app-pub-3940256099942544/6300978111"></com.google.android.gms.ads.AdView></RelativeLayout>Also metadata to Android manifest file:
Monkey123<meta-dataandroid:name="com.google.android.gms.ads.ca-app-pub-3940256099942544~3347511713"android:value="ca-app-pub-3940256099942544~3347511713"/>Still not working. Though I’m not sure about that RelativeLayout in Monkey 2 projects…
Is there anyone here who has working ad code with “com.google.android.gms:play-services-ads:17.1.1”?
November 30, 2018 at 7:24 pm #15635Isn’t version different? What if you use version 16.0.0?
November 30, 2018 at 8:05 pm #15636With version 16.0.0 the ads are working perfectly. I thought that 17.0.0 was oldest available after 17.1.1. Anyway 15.0.1 that I’ve used earlier isn’t available anymore. Thanks!
We should get ready for the time, when ads library that’s available is 17.0.0 or later.
But your reply saved my day! Thanks again.
Nice to see that Monkey 2 community is alive.
November 30, 2018 at 9:02 pm #15638Will take a look at this ASAP, thanks for bringing it to my attention.
December 1, 2018 at 1:16 am #15640For 17.1.1 you need to add this to your manifest inside the <application> block:
<meta-data android:name=”com.google.android.gms.ads.APPLICATION_ID”
android:value=”ca-app-pub-3940256099942544~3347511713″/>I also had to tweak the java code a bit (results are in develop branch), I’m surprised you could even build it.
-
AuthorPosts
You must be logged in to reply to this topic.