cordova-plugin-admob-free
cordova-plugin-admob-free copied to clipboard
AdMobFree crahsed on .prepare()
This is my ionic info result: cli packages: (/home/user/app/node-v8.9.4-linux-x64/lib/node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
@ionic/app-scripts : 3.1.6
Cordova Platforms : android 6.4.0
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
Node : v8.9.4
npm : 6.0.0
OS : Linux 4.13
Environment Variables:
ANDROID_HOME : /home/user/Android/Sdk
Misc:
backend : pro
And this is the cordova plugins:
cc.fovea.cordova.purchase 7.1.3 "Purchase" com-sarriaroman-photoviewer 1.1.16 "PhotoViewer" cordova-admob-sdk 0.16.0 "AdMob SDK" cordova-plugin-admob-free 0.16.1 "Cordova AdMob Plugin" cordova-plugin-android-downloadmanager 0.5.0 "cordova-plugin-android-downloadmanager" cordova-plugin-app-version 0.1.9 "AppVersion" cordova-plugin-camera 4.0.2 "Camera" cordova-plugin-contacts 3.0.1 "Contacts" cordova-plugin-device 1.1.7 "Device" cordova-plugin-fcm 2.1.2 "FCMPlugin" cordova-plugin-file 6.0.1 "File" cordova-plugin-file-transfer 1.7.1 "File Transfer" cordova-plugin-ionic-webview 1.2.0 "cordova-plugin-ionic-webview" cordova-plugin-sms 1.0.5 "SMS" cordova-plugin-splashscreen 4.1.0 "Splashscreen" cordova-plugin-statusbar 2.4.1 "StatusBar" cordova-plugin-whitelist 1.3.3 "Whitelist" cordova-plugin-x-socialsharing 5.4.0 "SocialSharing" cordova-promise-polyfill 0.0.2 "cordova-promise-polyfill" cordova.plugins.diagnostic 4.0.5 "Diagnostic" es6-promise-plugin 4.2.2 "Promise" ionic-plugin-keyboard 2.2.1 @@"Keyboard"
My problem is, when i try to show the banner it always stopping my apps. I've try to develop admobfree on a separated project, and it works. I'm pretty sure that i've implement the same code, the different is only on android engine version (mine is 6.4.0) & play-services-ads version (mine is 9.0.0) that required by my system. Is that the problem? @ratson
@netidjen try to remove all plugins and run again. backup first
@ivanov84 nothing is change, i already renewing the plugins & android platforms. Any suggestion?
@netidjen not renew. Remove all plugin. Let stay only 1 plugin with admob-free. Then add one by one plugin to define after what prepare() crushes.
You probably have a wrong version of Google Play Services. The plugin requires a specific version and if it is different it compiles properly but crashes at prepare. Had this trouble too. You must find references to the services version in your plugins/platforms and change the + instead of version number.
And by the way, the method suggested in the docs to add variable with the preferred version to the config.xml simply doesn't change anything.
@rafaellop Did you mean to edit the gms:play-service- version on project.properties with "+"? if so, then this is the result: `FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':processDebugGoogleServices'.
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0. `
I have exactly same problem. I have Google Play Services SDK version 49, so I added following lines to config.xml but nothing has changed:
<plugin name="cordova-admob-sdk" spec="~0.16.0">
<variable name="PLAY_SERVICES_VERSION" value="49" />
</plugin>
I noticed that If I use this plugin with the following Google Analytics plugin, this problem happens. If I don't use Admob plugin, I can use Google Analytics plugin. If I don't use Google Analytics plugin, I can use AdMob plugin. But I can't use both of them at the same time.
https://github.com/danwilson/google-analytics-plugin https://ionicframework.com/docs/native/google-analytics/
@netidjen Do you have same situation? Do you use Google Analytics plugin too?
@netidjen I have changed in project.properties
cordova.system.library.4=com.google.android.gms:play-services-base:+
cordova.system.library.5=com.google.android.gms:play-services-ads:+
In the effect you should have the following in the \platforms\android\build.gradle
:
dependencies {
[....]
compile "com.google.android.gms:play-services-base:+"
compile "com.google.android.gms:play-services-ads:+"
}
If you don't have +
here there are other places you should replace this. Then cordova clean
then cordova build
. I also had errors if I tried to build without cleaning first.
I noticed that If I use this plugin with the following Google Analytics plugin, this problem happens. If I don't use Admob plugin, I can use Google Analytics plugin. If I don't use Google Analytics plugin, I can use AdMob plugin. But I can't use both of them at the same time.
https://github.com/danwilson/google-analytics-plugin https://ionicframework.com/docs/native/google-analytics/
@netidjen Do you have same situation? Do you use Google Analytics plugin too?
@coolman7 i have no Google Analytics plugin
@netidjen So we should have different problems.
@rafaellop after doing codova clean & build, the problem is still the same:
What went wrong: Execution failed for task ':processDebugGoogleServices'. Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0. `
Check the dependencies in the build.gradle
file. This will tell you what versions it tries to link. Then search for the references.
@rafaellop don't you remember that the dependencies in build.gradle is depend on project.properties? Once i change the version in project.propertie, then on build.gradle will be affacted right?
I think so, but project.properties is controlled by plugins so if you update any that modifies it, it will be changed. Unfortunately I don't know better way. I've got on my todo to check this when I build for Android. Would be great if the config.xml params worked like announced but they aren't.
I agree with you sir, but i don't know exactly what version of play-service in build.gradle needed. Since i changed the version from 11.0.4 to 9.0.0 my app crashed when try to show some ads. If i change the version number to "+" then another problem above appears.
I had the same issue, the app was crashing on prepare(). It worked fine when I removed plugin cordova-plugin-firebase
. Is there anyway to get this fixed.
I am having the same issue with cordova-plugin-firebase
and admob-free
uninstalling one of them fix the issue. is there any other way?
As far as I understand common plugin is admob-free. admob-free and google analytics or admob-free and firebase does not work together. I guess the problem should be inside admob-free code.
On the other hand cordova-admob-pro
plugin does not have this problem. It can run with cordova-plugin-google-analytics
plugin.
I am using cordova-plugin-firebase and cordovoa-plugin-admob-free at the same time and everything works (prepare and launch of banner, interstitial and rewarded video) using the latest version of play-services-base and play-services-ads
PS: If the banner prepare fails, check that you are using a correct size-property of the banner
Any one solve this issue? I've found this but it didn't help too: https://github.com/dpa99c/cordova-android-play-services-gradle-release
Nir.
@puffnir Did you use FCM/Firebase plugin?
@netidjen maybe i'm late, anyway this may be usefull to someone else
the conflict it was raised by this plugin which use firebase https://github.com/phonegap/phonegap-plugin-push
in build.gralde(Module: app) you have to check the dependecies section and change them to a common version:
compile "com.google.firebase:firebase-messaging:11.6.2" compile "com.google.android.gms:play-services-base:11.6.2" compile "com.google.android.gms:play-services-ads:11.6.2"
i didn't test this plugin combos: https://github.com/dpa99c/cordova-android-play-services-gradle-release https://github.com/dpa99c/cordova-android-firebase-gradle-release
but it seems promising as you can manually set the version for every google service and it should fix every future problem if you change anything in the project without manually changing the versions every time
Any one found the solution??? I tried all the options mention above. But nothing is working for me :-(
I can just give the advice to use the latest version of the Play Services:
<plugin name="cordova-admob-sdk" spec="^0.18.0">
<variable name="PLAY_SERVICES_VERSION" value="+" />
</plugin>
And afterwards make sure that the version is set in platforms/android/app/build.gradle
:
compile "com.google.android.gms:play-services-base:+"
compile "com.google.android.gms:play-services-ads:+"
@paulstelzer Thank you for useful information!
Where should I write following code to?
<plugin name="cordova-admob-sdk" spec="^0.18.0">
<variable name="PLAY_SERVICES_VERSION" value="+" />
</plugin>
cordova-plugin-admob-free does not have platforms/android/app/build.gradle
.
Should I create it myself?
@m-itkdev in plugin directory. Then remove platform and add again with modifed plugin folder. P.S.: not cordova-plugin-admob-free but cordova-admob-sdk
Where should I write following code to?
<plugin name="cordova-admob-sdk" spec="^0.18.0"> <variable name="PLAY_SERVICES_VERSION" value="+" /> </plugin>
Like mentioned in the documentation: https://github.com/ratson/cordova-plugin-admob-free#customize-google-play-services-versions-android-only
platforms/android/app/build.gradle
should be in your main folder structure
PS: Adding the PLAY_SERVICES_VERSION cannot work sometimes, then edit it in pluigns/corodva-admob-sdk/plugin.xml
to <preference name="PLAY_SERVICES_VERSION" default="+"/>
Keep in mind to remove the platforms folder afterwards and re-run cordova platform add android
If you have multiple cordova plugins who each has it's own play services version, use the following plugin: https://github.com/dpa99c/cordova-android-play-services-gradle-release
@ivanov84
@paulstelzer
I'm using Monaca. So my project does not have platforms/android/app/build.gradle
.
I wrote following code to config.xml, resolved my problem.
<plugin name="cordova-admob-sdk" spec="^0.18.0">
<variable name="PLAY_SERVICES_VERSION" value="+" />
</plugin>
Thank you for your advise!
same issue. I called prepare funciton and got following message.
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zzur;
at com.google.android.gms.ads.BaseAdView.<init>(Unknown Source:3)
at com.google.android.gms.ads.AdView.<init>(Unknown Source:1)
at name.ratson.cordova.admob.banner.BannerExecutor$1.run(BannerExecutor.java:70)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
I develop with ionic capacitor.