Ionic Ads not working with AdMob Id


#1

I am using this example Integrating Google AdMob Advertisements in Ionic

In above example i’m using only banner ads.

Ionic Info:
DemoAds1

Apk Build Commends:
ionic cordova build --release android

keytool -genkey -v -keystore my-release-key.keystore -alias techno -keyalg RSA -keysize 2048 -validity 10000

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore D:\ionic\demoAds1\platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk techno

jarsigner -verify -verbose -certs D:\ionic\demoAds1\platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk

zipalign -v 4 D:\ionic\demoAds1\platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk magictricks.apk

With above commend app build fine its working in mobile too but only ads not working.
Note: One more thing If i use isTesting: true with this ads showing in prod app but when i use admob ID & isTesting: false at that time ads not working.

home.ts

showBanner() {
 
        let bannerConfig: AdMobFreeBannerConfig = {
            isTesting: false, // Remove in production
            autoShow: true
            id: 'ca-app-pub-3940256099942544/6300978111'; //Your Ad Unit ID goes here
        };
 
        this.admob.banner.config(bannerConfig);
 
        this.admob.banner.prepare().then(() => {
            // success
        }).catch(e => console.log(e));
 
    }

home.html

<ion-header>
  <ion-navbar>
    <ion-title>
      Ionic Blank
    </ion-title>
  </ion-navbar>
</ion-header>
 
<ion-content padding>
    <button ion-button (click)="showBanner()">Show Banner</button>
</ion-content>
Any help..Thanks

#2

Are you getting any error or anything in console??


#3

Here my console:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

D:\ionic\demoAds1>ionic cordova build --release android
> ionic-app-scripts build --target cordova --platform android
[11:43:02]  ionic-app-scripts 3.2.0
[11:43:02]  build dev started ...
[11:43:02]  clean started ...
[11:43:02]  clean finished in 80 ms
[11:43:02]  copy started ...
[11:43:03]  deeplinks started ...
[11:43:03]  deeplinks finished in 20 ms
[11:43:03]  transpile started ...
[11:43:10]  transpile finished in 6.95 s
[11:43:10]  preprocess started ...
[11:43:10]  preprocess finished in 1 ms
[11:43:10]  webpack started ...
[11:43:10]  copy finished in 8.52 s
[11:43:17]  webpack finished in 6.71 s
[11:43:17]  sass started ...
[11:43:22]  sass finished in 4.85 s
[11:43:22]  postprocess started ...
[11:43:22]  postprocess finished in 11 ms
[11:43:22]  lint started ...
[11:43:22]  build dev finished in 19.84 s
[11:43:26]  lint finished in 4.70 s
> cordova build android --release
Android Studio project detected
ANDROID_HOME=D:\Android\Sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_51
studio
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reus
ed, use --status for details
publishNonDefault is deprecated and has no effect anymore. All variants are now
published.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be re
moved in Gradle 5.0. Please use Task.doLast(Action) instead.
        at build_8mwz0dnbux7vbk4r1pbadhqck.run(D:\ionic\demoAds1\platforms\andro
id\app\build.gradle:143)
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' in
stead.
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preReleaseBuild UP-TO-DATE
:CordovaLib:compileReleaseAidl UP-TO-DATE
:CordovaLib:compileReleaseRenderscript UP-TO-DATE
:CordovaLib:checkReleaseManifest UP-TO-DATE
:CordovaLib:generateReleaseBuildConfig UP-TO-DATE
:CordovaLib:prepareLintJar UP-TO-DATE
:CordovaLib:generateReleaseResValues UP-TO-DATE
:CordovaLib:generateReleaseResources UP-TO-DATE
:CordovaLib:packageReleaseResources UP-TO-DATE
:CordovaLib:platformAttrExtractor UP-TO-DATE
:CordovaLib:processReleaseManifest UP-TO-DATE
:CordovaLib:processReleaseResources UP-TO-DATE
:CordovaLib:generateReleaseSources UP-TO-DATE
:CordovaLib:javaPreCompileRelease UP-TO-DATE
:CordovaLib:compileReleaseJavaWithJavac UP-TO-DATE
:CordovaLib:processReleaseJavaRes NO-SOURCE
:CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForRelease UP
-TO-DATE
:app:preBuild UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:compileReleaseAidl UP-TO-DATE
:CordovaLib:packageReleaseRenderscript NO-SOURCE
:app:compileReleaseRenderscript UP-TO-DATE
:app:checkReleaseManifest UP-TO-DATE
:app:generateReleaseBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources UP-TO-DATE
:app:mergeReleaseResources UP-TO-DATE
:app:createReleaseCompatibleScreenManifests UP-TO-DATE
:app:processReleaseManifest UP-TO-DATE
:app:splitsDiscoveryTaskRelease UP-TO-DATE
:app:processReleaseResources UP-TO-DATE
:app:generateReleaseSources UP-TO-DATE
:app:javaPreCompileRelease UP-TO-DATE
:app:compileReleaseJavaWithJavac UP-TO-DATE
:app:compileReleaseNdk NO-SOURCE
:app:compileReleaseSources UP-TO-DATE
:CordovaLib:mergeReleaseShaders UP-TO-DATE
:CordovaLib:compileReleaseShaders UP-TO-DATE
:CordovaLib:generateReleaseAssets UP-TO-DATE
:CordovaLib:mergeReleaseAssets UP-TO-DATE
:app:mergeReleaseShaders UP-TO-DATE
:app:compileReleaseShaders UP-TO-DATE
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets
:app:transformClassesWithStackFramesFixerForRelease UP-TO-DATE
:app:transformClassesWithDesugarForRelease UP-TO-DATE
:app:transformClassesWithPreDexForRelease UP-TO-DATE
:app:transformDexWithDexForRelease UP-TO-DATE
:CordovaLib:compileReleaseNdk NO-SOURCE
:CordovaLib:mergeReleaseJniLibFolders UP-TO-DATE
:CordovaLib:transformNativeLibsWithMergeJniLibsForRelease UP-TO-DATE
:CordovaLib:transformNativeLibsWithIntermediateJniLibsForRelease UP-TO-DATE
:app:mergeReleaseJniLibFolders UP-TO-DATE
:app:transformNativeLibsWithMergeJniLibsForRelease UP-TO-DATE
:app:processReleaseJavaRes NO-SOURCE
:app:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
:app:packageRelease
:app:lintVitalRelease
:app:assembleRelease
:app:cdvBuildRelease

BUILD SUCCESSFUL in 1m 31s
45 actionable tasks: 3 executed, 42 up-to-date
Built the following apk(s):
        D:\ionic\demoAds1\platforms\android\app\build\outputs\apk\release\app-re
lease-unsigned.apk

D:\ionic\demoAds1>

#4

First of all why are you using release build for testing…?? Try to use ionic cordova build android.
Please post a screenshot of your app where the ads are not showing up.


#5

error solved boss :::


Admobfree not showing ads
#6

Great… What was the problem and how did you solved it??


#7

i added this platform: ionic cordova platform add android@6.3.0

D:\ionic\myapp\platforms\android\src\name\ratson\cordova\admob\AdMobConfig.java

In this file i replace my ads id like this:

// Banner
    private static final String TEST_BANNER_ID = "ca-app-pub-xxx/xxx";
    private String bannerAdUnitId = "ca-app-pub-xxx/xxx";

and add isTesting = false

if (options.has(OPT_IS_TESTING)) {
            this.isTesting = false;
}

with this everything working perfect.