I tried implementing Native Express Ads, but for testing purposes i can't find the test ad id.
I found alot of posts which just used the test id for banner ads ca-app-pub-3940256099942544/6300978111and for some reason this does work.
Now my question is if Native Express Ads are still recommended to use as an ad type or are they deprecated and should i switch to Native Advanced Ads?
My code
LinearLayout adContainer = findViewById(R.id.adContainer);
mAdView = new NativeExpressAdView(getApplicationContext());
mAdView.setAdSize(new AdSize(320,50);
mAdView.setAdUnitId("ca-app-pub-3940256099942544/6300978111");
adContainer.addView(mAdView);
LinearLayout adContainer2 = findViewById(R.id.adContainer2);
mAdView2 = new NativeExpressAdView(getApplicationContext());
mAdView2.setAdSize(new AdSize(320,50);
mAdView2.setAdUnitId("ca-app-pub-3940256099942544/6300978111");
adContainer2.addView(mAdView2);
AdRequest adRequest = new AdRequest.Builder().addTestDevice("4EF772AE9549741BE0E1FCA236C7382C").build();
mAdView.loadAd(adRequest);
mAdView2.loadAd(adRequest);
Yes you are right now google has replaced Native Express Ads with Native Advanced Ads.
Here is the official link of Google Admob documentation
https://developers.google.com/admob/android/native/advanced
Related
TLDR: I get real ads even if I use a sample unit id provided by Google for testing.
I implemented native ads in my application.
I am using the Native Advanced sample ad unit as described here:
https://developers.google.com/admob/android/test-ads
However, the ads I get look very real, even though they have a "Test Ad" text in the title, and they also redirect me to real company websites. This has not happened with banner ads, I only got Google sample ads previously (e.g. Nice job, this is a test ad).
Some of the ads are coming from well-known restaurants in my country, and clicking on them navigates me to their website. I don't use my own unit id anywhere.
This is the code I use to initialize ads.
public static final String UNIFIED_AD_UNIT_ID = "ca-app-pub-3940256099942544/2247696110";
MobileAds.initialize(context, initializationStatus -> {
});
AdLoader adLoader = new AdLoader.Builder(context, UNIFIED_AD_UNIT_ID)
.forUnifiedNativeAd(unifiedNativeAd -> {
populateNativeAdView(unifiedNativeAd, nativeAdView);
}).build();
adLoader.loadAd(new AdRequest.Builder().build());
}
Is this a bug, or am I doing something wrong? (Or are these really test ads?) I really don't want to get banned from AdMob.
If you start your App running Android Studio, you can get the test device id for your device from the logcat at the bottom of Android Studio. Add this to your builder. By the way, the ads you are getting are looking like they should.
I'm still testing my app ads and I use this code to generate test ads.
But I was wondering if there is any difference between using AdRequest.DEVICE_ID_EMULATOR and using the id generated in logcat?
Code I'm using
adLoader.loadAd(new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build());
I would so encourage to just use test ads provided by Google.
AdView adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(BuildConfig.DEBUG ? "ca-app-pub-3940256099942544/6300978111" : "yourRealAdUnitID");
So much simpler than messing around with multiple test devices.
i am playing around with flavors in Android studio, i made one demo and one full flavor, the sole difference beeing the demo version having a copy of the activity_main.xml layout with an admod view in it,
the full version has not....
i read that having separate java class files is a bad idea, so i integrated the admob stuff in the main/.../src/java/.../MainActivity class:
if("free".equals(BuildConfig.FLAVOR))
{
Log.d(TAG, "flavor: " + BuildConfig.FLAVOR);
MobileAds.initialize(this, ADMOB_APP_ID);
AdView mAdView;
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
//.addTestDevice("151A597D874BD0B8D69D5D5E5B18B0E8")
.build();
mAdView.loadAd(adRequest);
}
and building the demo version goes flawlessly....
but, since the admob view id doesn't exist in the full version, well it doesn't build anymore....
quitting with a
Error:(204, 34) error: cannot find symbol variable adView
so i am a bit at a loss how to solve that... all the examples about flavors i read through, adress the problem generally, but for solving specifically that sort of problem i couldn't find anything....
You must to use only one xml file (activity_main.xml) and use
AdView mAdView;
mAdView = findViewById(R.id.adView);
if("free".equals(BuildConfig.FLAVOR))
{
mAdView.setVisibility(View.VISIBLE);
mAdView.loadAd(adRequest);
}else{
mAdView.setVisibility(View.GONE);
}
So I made a game that I'm trying to add ads to but I'm not using any XML. I found two examples that say they should work after extensive research and many hours of looking. How ever even when I try implementing that code I still get errors and am at a loss.
I've searched through stack overflow and many other sites and I am at a loss. Ive tried implementing this several different ways and I'm not sure if I'm not including ti right or what.
Here are the two remaining errors I'm getting:
The Constructor is not working for the AdView class the way its described in the tutorial and I'm not sure how to fix that.
and the AdRequest() function says its implemented as private and even when i try to use the AdRequest().Builder().build(); it still gives the same error.
I have no xml in my code and am using a class that extends SurfaceView for the entire game, and i am using AdMob ads. How do i do this with out xml?
Here is how I load my ads. Hope it helps.
admobAdView = new com.google.android.gms.ads.AdView(getActivity());
admobAdView.setAdSize(AdSize.SMART_BANNER);
admobAdView.setAdUnitId("ca-app-pub-###########/#######");
adViewContainer = (ViewGroup) getView().findViewById(R.id.ad_view_group);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("#################")
.build();
admobAdView.loadAd(adRequest);
I have a working AdMob AdView on top of my opengl game. Its working great but I notice that it keeps showing a particular blank ad. I thought it was a bug on my side but then I noticed that the ad is functioning partially. The ad appears to be a RocketFuel ad according to the provided info button in the top right of the AdView. Clicking within the blank AdView area does nothing unless the info button it hit. The images and code below help explain.
I thought RocketFuel was a separate ad service, is it possible to limit its appearance in Google AdMob using the Filter Settings > Category / Type Settings > Affiliate offers? Or perhaps one of the other categories? I am going to try adding a URL Block for rocketfuel.com under the Ad Filters. However I am unsure if they are serving ads directly from their domain.
Otherwise, is there any way to block, report, or limit these types of ads from being shown through my app? Has anyone had similar problems with such ads?
Here is how I slap the adview on top of my java based OpenGL ES 2 renderer:
#Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
mView = new nopgRenderer(this);
setContentView(mView);
adView = new AdView(this, AdSize.IAB_LEADERBOARD, "<AdMobAdAppID>");
RelativeLayout layout = new RelativeLayout(this);
layout.addView(adView);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
params.addRule(RelativeLayout.CENTER_HORIZONTAL);
adView.setLayoutParams(params);
this.addContentView(layout, params);
adView.loadAd(new AdRequest());
}
public static void hideAd(){
adView.setVisibility(AdView.GONE);
}
public static void showAd(){
adView.setVisibility(AdView.VISIBLE);
}
The app on Google Play:
https://play.google.com/store/apps/details?id=com.dmtsource.nopg
Example of a normal ad:
Example of the blank ad:
Clicking on the info item in the blank ad: