question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ionic: Google Maps and Admob free

See original GitHub issue

**I’m submitting a [ x] any problem or bug report

plugin version: (check one with “x”) [x ] 2.0.0-beta2

cordova information: (run $> cordova plugin list) com.googlemaps.ios 2.3.0 “Google Maps SDK for iOS” cordova-admob-sdk 0.7.0 “AdMob SDK” cordova-plugin-admob-free 0.9.0 “Cordova AdMob Plugin” cordova-plugin-console 1.0.5 “Console” cordova-plugin-device 1.1.4 “Device” cordova-plugin-googlemaps 2.0.0-beta2-20170721-1617 “cordova-plugin-googlemaps” cordova-plugin-splashscreen 4.0.3 “Splashscreen” cordova-plugin-statusbar 2.2.2 “StatusBar” cordova-plugin-whitelist 1.3.1 “Whitelist” cordova-promise-polyfill 0.0.2 “cordova-promise-polyfill” ionic-plugin-keyboard 2.2.1 “Keyboard”

Current behavior:

Hello, your plugin is very fantastic, it’s a great job, thank you very much.

I finalize my Ionic project, with plugin googlemaps, and I want insert Ad banner in all the page.

Without the plugin Ad mob, the google map display very good.

But when I insert the Ad banner, the screen of the page where is the map, is black.

An example of code

global packages:

@ionic/cli-utils : 1.5.0
Cordova CLI      : 7.0.1 
Ionic CLI        : 3.5.0

local packages:

@ionic/app-scripts              : 2.0.2
@ionic/cli-plugin-cordova       : 1.4.1
@ionic/cli-plugin-ionic-angular : 1.3.2
Cordova Platforms               : android 6.2.3
Ionic Framework                 : ionic-angular 3.5.3

System:

Node       : v6.10.0
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b 
ios-deploy : 1.9.1 
ios-sim    : 5.0.13 
npm        : 3.10.10 

Expected behavior:

Without Admob, the map display very well

Steps to reproduce:

  1. create ionic project
  2. install Google maps native: https://ionicframework.com/docs/native/google-maps/
  3. install Admob free: https://ionicframework.com/docs/native/admob-free/
  4. ionic cordova run android , on a LG device, Android version 5.0.1

Project bug example: https://github.com/jaylecorse/ionic-googlemap-admob.git

Screen capture or video record:

screenshot_2017-07-23-13-54-56


If your problem is solved, please consider small amount donation to this project. Appreciate for your kindness. https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/blob/master/README.md#buy-me-a-beer

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
wf9a5m75commented, Jul 23, 2017

Okay, I finally figured out the problem. This is completely the AdMob plugin’s problem.

The wrong point is here.

ViewGroup wvParentView = (ViewGroup) getWebView().getParent();
if (parentView == null) {
    parentView = new LinearLayout(webView.getContext());
}
if (wvParentView != null && wvParentView != parentView) {
    wvParentView.removeView(getWebView());
    ((LinearLayout) parentView).setOrientation(LinearLayout.VERTICAL);
    parentView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
    getWebView().setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1.0F));
    parentView.addView(getWebView());
    cordova.getActivity().setContentView(parentView);   <----- here is problem
}

https://github.com/ratson/cordova-plugin-admob-free/blob/f8357d40aded044a2e477e8a165b6a3ac2617e78/src/android/banner/BannerExecutor.java#L213

The webview redraws the background when the setContentView() method executes.

In order to prevent redraw the background, get the parentView of webView, and re-instart a new view.

ViewGroup rootView = (ViewGroup)(getWebView().getParent());
wvParentView.removeView(getWebView());
((LinearLayout) parentView).setOrientation(LinearLayout.VERTICAL);
parentView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
getWebView().setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1.0F));
parentView.addView(getWebView());
rootView.addView(parentView);
1reaction
wf9a5m75commented, Jul 23, 2017

Great preparation. I will check it later.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AdMob Free - Ionic Native
A free, no ad-sharing version of Google AdMob plugin for Cordova. Requires Cordova plugin: cordova-plugin-admob-free . For more info, please see the AdMob...
Read more >
Ionic 5|4 How to Integrate Google AdMob Advertisements
To use Google AdMob in the Ionic application we need to use the Cordova plugin. Here we will use the AdMob Free plugin....
Read more >
Conflict between Admob-Free and Google Maps Plugin ...
This is a Ionic issue using Admob-Free and Google Maps Plugin. All clicks on the header buttons are moved down (ToogleMenu and Back...
Read more >
Ionic AdMob Integration. Monetize your app with Google Ads.
Learn how to add Google Ads to an Ionic App. These Ionic AdMob tutorials explain how to display banner and interstitial ads in...
Read more >
google admob ads in ionic - YouTube
This is best tutorial video for ionic admob plugin install step by step. ... Ionic4 admob free plugin install | google admob ads...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found