Campaign Ads (House Ads) - android

my admob ads works perfectly (mediation by admob, running like 7 activities where i have these ads) but when i started campaign in one of my activity with one simple AD (320x50) it doesnt show. Tried every type of campaign noone worked.
Is there anything what i need to do? Something in code? or in Admob settings (except cpm, chose which activity, type of AD etc... already done that). I was searching for this problem the whole week but didnt find any succes.
If someone could help me it will be awesome because there is no support on AdMob except of FAQ which tells you nothing.

There is a sample of code activity and layout:
<LinearLayout
android:id="#+id/tejbl_tlacitka"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:orientation="vertical"
>
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
style="#style/bannerpozadi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-4412963312739253/5142509411" />
</LinearLayout>
Activity:
public class oAplikaciActivity extends AppCompatActivity {
private AdView mAdview;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_oaplikaci);
setTitle("O aplikaci");
mAdview = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdview.loadAd(adRequest);

Related

my ads are not showing up

i am just trying to learn how to add ads in android app.but the ads are not showing up.i don't know why its not coming up
here is my mainactivity.xml
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="#string/banner_ad_unit_id"
android:layout_marginTop="443dp"
android:layout_below="#+id/textView"
android:layout_alignParentEnd="true">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
Mainactivity.java
package com.example.a1407268.admob;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}
}
If you're testing your app then use addTestDevice() to check Ad alignment.
AdView adView = new AdView(this);
AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
adView.loadAd(adRequestBuilder.build());
Otherwise If your App is live then and not able to show any Ad then you've to wait for some time.
According to Google
"It could be that you have only recently created a new Ad Unit ID and
requesting for live ads. It could take a few hours for ads to start
getting served if that is that case. If you are receiving test ads
then your implementation is fine. Just wait a few hours and see if you
are able to receive live ads then. If not, can send us your Ad Unit ID
for us to look into."
https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/android/fBe3YL3ffpo

Android, admob advert is not displaying

I am trying to implement a banner advert in my Android application. I have used Gradle to download the dependencies, etc.
In my activity where I want the advert to be displayed I have:
<com.google.android.gms.ads.AdView
android:id="#+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="#string/ad_mob_id" />
And ad_mob_id is
ca-app-pub-3940256099942544/6300978111
Which is for test ads, I took that from https://developers.google.com/mobile-ads-sdk/docs/admob/android/quick-start#step_1_modify_the_main_activity_layout
However when I run the activity nothing is displayed and there are no errors/warnings generated.
Am I missing another step?
AdView mAdView = (AdView) getView().findViewById(R.id.adView); // locate the id the banner view
// if you do not use fragments and you are using it directing the remove the getView();
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest); // load it..that's all and you will see logs on it
i took it from the link you posted, it has all you need.

How to add AdMob to a Frozen Bubble like game?

I would like to get some help with integrating AdMob into a game structured like Frozen Bubble. I have made the layout with the adview in itself, and tried to load ad in the FrozenBubble.java (which file is the appropriate for it in my game), but it is crashing with NullPointerException for some reason.
Here is my FrozenBubble like code:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
isRunning = true;
setVolumeControlStream(AudioManager.STREAM_MUSIC);
requestWindowFeature(Window.FEATURE_NO_TITLE);
restoreGamePrefs();
AdView adview = (AdView)findViewById(R.id.adView);
AdRequest re = new AdRequest();
re.setTesting(true);
adview.loadAd(re);
...
It is the Admob based code... But it is crashing with NullPointerException.
In the layout I have the GameView and the AdMob View:
<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="MY_CODE_HERE"
ads:adSize="BANNER"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"/>
I don't if it is enough information, but not, then you can find the frozen bubble source here, which my game based on:
Frozen Bubble Google Code
Please look at it, and help me if you can!
Thanks in advance!
You never called setContentView with your layout file. As a result, AdView adview = (AdView)findViewById(R.id.adView); will return null, and adview.loadAd(re); will crash.
Attach your layout file to your activity prior to calling findViewById.

weird admob problem

I did some updates to my application today but now admob dont work right and it gives me an error in the ad saying adview missing xml attribute "adsize". now the changes i made have nothing to do with the ads and they have been the same since I implemented them and worked
this is my xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res/com.notify.me.lite"
android:layout_width="fill_parent"
android:id="#+id/mainLayout1"
android:layout_height="fill_parent" android:orientation="vertical">
<com.google.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adUnitId="id"
ads:adSize="BANNER"/>
<WebView android:layout_width="fill_parent" android:id="#+id/webView1" android:layout_height="fill_parent"></WebView>
</LinearLayout>
and where its implemented
public class Main extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_webview);
WebView browser = (WebView) findViewById(R.id.webView1);
browser.loadUrl("file:///android_asset/about.html");
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest request = new AdRequest();
request.setTesting(true);
adView.loadAd(request);
}
as you can see adsize is there in the xml file so there should be no reason why I should be getting that error. Ideas as to why this is happening all of the sudden?
Google updated the AdMob library but did not yet document the required changes, as per this forum thread
The substance of the change is to update the ads namespace:
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
No idea why its suddenly stoped working but whenever i use Admob i always put it in a seperate layout, with xml like:
<RelativeLayout android:id="#+id/rLayAdMob"
android:layout_width="match_parent" android:layout_height="50dip">
</RelativeLayout>
Then in the onCreate function i setup the adView like:
adView = new AdView(Menu.this, AdSize.BANNER, MY_AD_UNIT_ID);
RelativeLayout layout = (RelativeLayout)findViewById(R.id.rLayAdMob);
layout.addView(adView);
I've never had any issues doing it this way, and would only require a small change to your code.
Hope this helps,
Kenny

Integrating admob into Android app

Been having some trouble trying to integrate the admob sdk into my application to display ads. Im using the AdmobSDK version 4.1.0. I've read loads of posts and there seems to be lacking some decent documentation and many discussions on the topic including http://groups.google.com/group/google-admob-ads-sdk/browse_thread/thread/3b885d3fe5bb21a5?pli=1 So far my layout is..
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/linear"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true">
<com.google.ads.AdView
android:id="#+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId="MY_PUB_CODE"
ads:adSize="BANNER"/>
</LinearLayout>
</ScrollView>
my androidmanifest.xml contains...
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"></activity>
<meta-data android:value="MY_PUBLISHER_ID" android:name="ADMOB_PUBLISHER_ID"></meta-data>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
EDIT, UPDATE:
Ok i seem to have gotten admob working on my HTC by adding,
AdView ad = (AdView) findViewById(R.id.ad);
AdRequest r = new AdRequest()
r.addTestDevice("X3XFX518X7DE1FD879XA5XXAX1AX8BXX");
ad.loadAd(r);
however i only recieve a test banner, stating im ready to explore the google app galaxy. When i remove the "addTestDevice" method, the banner/ad does not show up atal and in the log i recieve, "ad not recieved due to lack of inventory" .. Anyone sheed some light on this?
thanks for the help so far!
To your comment, I use this and it works quite well for me. The size is the second param of the AdView constructor.
ad = new AdView(this, AdSize.BANNER, "<ID>");
LinearLayout layout = (LinearLayout) findViewById(R.id.main_admob_layout);
// Add the adView to it
layout.addView(ad);
AdRequest request = new AdRequest();
request.setTesting(TESTING_MODE);
ad.loadAd(request);

Categories

Resources