cordova-plugin-admob-free icon indicating copy to clipboard operation
cordova-plugin-admob-free copied to clipboard

AdMobFree crahsed on .prepare()

Open netidjen opened this issue 6 years ago • 36 comments

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 avatar May 09 '18 04:05 netidjen

@netidjen try to remove all plugins and run again. backup first

ivanov84 avatar May 09 '18 05:05 ivanov84

@ivanov84 nothing is change, i already renewing the plugins & android platforms. Any suggestion?

netidjen avatar May 09 '18 06:05 netidjen

@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.

ivanov84 avatar May 09 '18 08:05 ivanov84

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 avatar May 09 '18 12:05 rafaellop

@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. `

netidjen avatar May 09 '18 13:05 netidjen

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>

coolman7 avatar May 09 '18 14:05 coolman7

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 avatar May 09 '18 14:05 coolman7

@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.

rafaellop avatar May 09 '18 14:05 rafaellop

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 avatar May 09 '18 14:05 netidjen

@netidjen So we should have different problems.

coolman7 avatar May 09 '18 14:05 coolman7

@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. `

netidjen avatar May 09 '18 14:05 netidjen

Check the dependencies in the build.gradle file. This will tell you what versions it tries to link. Then search for the references.

rafaellop avatar May 09 '18 15:05 rafaellop

@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?

netidjen avatar May 09 '18 15:05 netidjen

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.

rafaellop avatar May 09 '18 15:05 rafaellop

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.

netidjen avatar May 09 '18 15:05 netidjen

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.

BanwariLal avatar May 17 '18 08:05 BanwariLal

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?

sonugpc avatar May 18 '18 09:05 sonugpc

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.

coolman7 avatar May 18 '18 09:05 coolman7

On the other hand cordova-admob-pro plugin does not have this problem. It can run with cordova-plugin-google-analytics plugin.

coolman7 avatar May 18 '18 17:05 coolman7

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

paulstelzer avatar May 22 '18 09:05 paulstelzer

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 avatar May 27 '18 12:05 puffnir

@puffnir Did you use FCM/Firebase plugin?

netidjen avatar May 30 '18 11:05 netidjen

@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

mikealo avatar Jun 20 '18 19:06 mikealo

Any one found the solution??? I tried all the options mention above. But nothing is working for me :-(

PalakjainJain avatar Sep 22 '18 09:09 PalakjainJain

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 avatar Sep 22 '18 10:09 paulstelzer

@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 avatar Sep 23 '18 03:09 m-itkdev

@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

ivanov84 avatar Sep 23 '18 06:09 ivanov84

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

code_2018-09-23_08-30-57

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

paulstelzer avatar Sep 23 '18 06:09 paulstelzer

@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!

m-itkdev avatar Oct 01 '18 01:10 m-itkdev

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.

CHUN-WEI-HSU avatar Oct 19 '18 06:10 CHUN-WEI-HSU