ratson / cordova-plugin-admob-free

New development has been moved to "admob-plus-cordova", https://github.com/admob-plus/admob-plus/tree/master/packages/cordova
https://github.com/admob-plus/admob-plus
MIT License
499 stars 214 forks source link

Ionic project crashes after adding cordova-plugin-admob-free #141

Closed matheuscaldasrj closed 6 years ago

matheuscaldasrj commented 6 years ago

Hi everyone, my project was working fine untill I add cordova-plugin-admob-free.

When I try to run

ionic serve the app starts on browser normally

but when I try running in a real device ionic cordova run android to test admob I get the following error:

UILD FAILED FAILURE: Build failed with an exception.

Total time: 32.323 secs (node:16892) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output: Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.

FAILURE: Build failed with an exception.

My plugins defined in package.json are:

  "cordova": {
    "plugins": {
      "cordova-plugin-device": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-whitelist": {},
      "ionic-plugin-keyboard": {},
      "cordova-plugin-geolocation": {
        "GEOLOCATION_USAGE_DESCRIPTION": "To locate you"
      },
      "cordova-plugin-admob-free": {}
    },
    "platforms": [
      "android",
      "browser"
    ]
  }

And my dependencies are:

  "dependencies": {
    "@angular/common": "4.4.4",
    "@angular/compiler": "4.4.4",
    "@angular/compiler-cli": "4.4.4",
    "@angular/core": "4.4.4",
    "@angular/forms": "4.4.4",
    "@angular/http": "4.4.4",
    "@angular/platform-browser": "4.4.4",
    "@angular/platform-browser-dynamic": "4.4.4",
    "@ionic-native/core": "4.3.2",
    "@ionic-native/geolocation": "^4.5.2",
    "@ionic-native/splash-screen": "4.3.2",
    "@ionic-native/status-bar": "4.3.2",
    "@ionic/storage": "2.0.1",
    "angularfire2": "^5.0.0-rc.4",
    "cordova-admob-sdk": "^0.13.1",
    "cordova-android": "^6.2.3",
    "cordova-browser": "^4.1.0",
    "cordova-plugin-admob-free": "^0.13.0",
    "cordova-plugin-device": "^1.1.4",
    "cordova-plugin-geolocation": "~2.4.3",
    "cordova-plugin-ionic-webview": "^1.1.11",
    "cordova-plugin-splashscreen": "^4.0.3",
    "cordova-plugin-whitelist": "^1.3.1",
    "cordova-promise-polyfill": "0.0.2",
    "firebase": "4.8.0",
    "ionic-angular": "3.8.0",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "rxjs": "5.4.3",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.18"
  }

Am I doing something wrong?

merbin2012 commented 6 years ago

install lowest version of this plugin cordova plugin add cordova-plugin-admob-free@0.12.1

kumaravel95 commented 6 years ago

just try to remove the platform and add the platform again.

azarus commented 6 years ago

Install last cordova npm i cordova -g Remove cordova android from your app ionic cordova platform rm android Add cordova-android 6.3.0 cordova platform add android@6.3.0 Run: ionic cordova run android

This worked for me.

matheuscaldasrj commented 6 years ago

There was something wrong with version 0.13.0, so I tried 0.12.1 like @merbin2012 said. After removing platform and reinstalling cordova it has worked fine. Thank you all!

mithunnick commented 6 years ago

@azarus installing android@6.3.0 also solved my problem, Thnx bro

erperejildo commented 6 years ago

@azarus, @mithunnick roll back to 6.3 is not a real solution since January 23th. Unfortunately we need version 7 to display ads: https://support.google.com/admob/answer/7562314?ctx=email

I've been dealing with this for a few days :S

Cyberfolks commented 6 years ago

im facing same problem please help me... i tried @0.12.1 but same issue with admob plugin during release or debug same problem

RikdeBoer commented 5 years ago

Needless to say that today, June 2018 many of us are on Cordova 8.0.0 and android@7.0.0 (if not @7.1.0)...

$ cordova build android .... :app:transformClassesWithDesugarForDebugException in thread "main" java.lang.IllegalArgumentException at com.google.common.base.Preconditions.checkArgument(Preconditions.java:108) .... at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:584)

Alberick commented 5 years ago

@RikdeBoer did you find a fix with the current versions?

Riyaz0001 commented 5 years ago

`:app:transformClassesWithDesugarForDebug Exception in thread "main" java.lang.IllegalArgumentException

    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:108)`

same problem here, how to do solve? @RikdeBoer

Riyaz0001 commented 5 years ago

I changed the platform/project.properties file, just replace the version number then add + sign.

Example: Before cordova.system.library.2=com.google.android.gms:play-services-ads:11.8.0

After cordova.system.library.2=com.google.android.gms:play-services-ads:+

and just use this command in CLI: cordova clean android and build again.

I hope to solve this problem for cordova-plugin-admob-free plugin.

sorry for my bad English.

Stadtrausch commented 5 years ago

Same problem here with cordova 8.0.0 and android 7.1.0 ! Any solutions so far ? Or is there an alternative to admob-free ?

azarus commented 5 years ago

@stadtrausch i posted a solution above did you see it or did you try it?

Stadtrausch commented 5 years ago

@azarus i tried every solution here without success.

What helped for me was create a new blank project, copy the src folder and reinstall every plugin of the project starting with admob-free.

merbin2012 commented 5 years ago

@Stadtrausch come to teamviewer I will try to solve your problem. merbin2010@gmail.com

Stadtrausch commented 5 years ago

@merbin2012 Thank you very much, but like i wrote above, creating a new project and adding the plugins again solved my problem.

siege-nnn commented 5 years ago

Not sure if it helps anyone, but I had a similar issue when installing admob free. To resolve, I followed the following steps.

1> saved my current code to repo (so I have a rollback position) //update environment cordova 2>sudo npm i cordova -g 3> ionic cordova platform rm android 4> rm -fr platforms/android www plugins 5> ionic cordova platform add android@7.1.1 5a> if you use firebase or services that require google-services.json, copy it again once the folder has been created. 6> ionic cordova build android 7> Likely to fail with error:: Execution failed for task ':app:transformClassesWithDesugarForDebug'. 7a> Unlike what was mentioned above, I made sure to specify the version. And also had the support-core-utils match my application and environment build. My environment is set to 26+, however, the project was pointing to 27., I changed it to 26 as per below. NOTE: Yours may look different than what I mentioned below, just make sure that google services follow the same version.

Example:: cordova.system.library.1=com.google.android.gms:play-services-maps:15.0.1 cordova.system.library.2=com.google.android.gms:play-services-location:15.0.1 cordova.system.library.3=com.android.support:support-core-utils:26.+ cordova.system.library.4=com.google.android.gms:play-services-base:15.0.1 cordova.system.library.5=com.google.android.gms:play-services-ads:15.0.1

Took me awhile to figure this out so hopefully it helps someone without having to rebuild your entire project :)

Malkiat-Singh commented 5 years ago

@Riyaz0001 Thanks this works fine thanks

LAHHCEN7 commented 5 years ago

@siege-nnn it's work for me Thanks

arijitnaskar commented 5 years ago

Few solutions above worked for me. I am able to build. But when I run the app in my device its crashing for the below code lines: admob.interstitial.prepare(); admob.interstitial.show();

Please help.

LAHHCEN7 commented 5 years ago

@arijitnaskar : this code is work for me test it in your .ts file constructor(public navCtrl: NavController, public navParams: NavParams, private admob: AdMobPro, private platform: Platform) {

    platform.ready().then(() => {
        var admobid = {
            banner: '',
            interstitial: ''
        };

        this.admob.createBanner({
            adId: admobid.banner,
            isTesting: true,
            autoShow: true,
            position: this.admob.AD_POSITION.BOTTOM_CENTER
        })

        this.admob.prepareInterstitial({
            adId: admobid.interstitial,
            isTesting: true,
            autoShow: false
        })
    });

}

showInterstitialAd() {
    if (AdMobPro) {
        this.admob.showInterstitial();
    }
}
arijitnaskar commented 5 years ago

@LAHHCEN7 Thanks. But mine is not a code issue. what I figured out is the plugin cordova-plugin-admob-free is conflicting with the plugin cordova-plugin-play-games-services. By doing cordova.system.library.2=com.google.android.gms:play-services-ads:+ I managed to build. But the app is crashing. Still not able to find a solution. :(

arijitnaskar commented 5 years ago

I solved the issue.

initially after installing both the plugin my project.properties was like below:

cordova.system.library.1=com.google.android.gms:play-services-base:11.0.4
cordova.system.library.2=com.google.android.gms:play-services-ads:11.0.4
cordova.system.library.3=com.google.android.gms:play-services-games:+
cordova.system.library.4=com.google.android.gms:play-services-plus:+

It was throwing error while building. Then I changed like below as suggested in above comments.

cordova.system.library.1=com.google.android.gms:play-services-base:+
cordova.system.library.2=com.google.android.gms:play-services-ads:+
cordova.system.library.3=com.google.android.gms:play-services-games:+
cordova.system.library.4=com.google.android.gms:play-services-plus:+

This change allowed me to build. But the app was crashing after installation. Then I thought may be the admob plugin will not work if I use version greater that 11.0.4 So changed like below and its working.

cordova.system.library.1=com.google.android.gms:play-services-base:11.0.4
cordova.system.library.2=com.google.android.gms:play-services-ads:11.0.4
cordova.system.library.3=com.google.android.gms:play-services-games:11.0.4
cordova.system.library.4=com.google.android.gms:play-services-plus:11.0.4

Spend almost 20 hours for this simple versioning issue :( It feels frustrating when you see you have no error in your code but the environment is destroying the application. :(

** I am not using Ionic. I am using simple cordova to build. But I think this will work for Ionic build also.

merbin2012 commented 5 years ago

@arjitnaskar don't do it will download lowest version 11.0 So follow the below line, might you will get after the build. If you get error simply run cordova clean command and run again, it should work.

cordova.system.library.1=com.google.android.gms:play-services-base:+ cordova.system.library.2=com.google.android.gms:play-services-ads:+ cordova.system.library.3=com.google.android.gms:play-services-games:+ cordova.system.library.4=com.google.android.gms:play-services-plus:+

Current latest version is 16+

arijitnaskar commented 5 years ago

@merbin2012 As I mentioned I already tried this (with cordova clean). I am able to build. But after installing the app is crashing while launch ( error popup in device: Unfortunately .... has stopped working) Is there any problem if I use version 11.0 ? I tested with android 5 (Samsung), android 6 (Motorola). and its working.

I did a alpha release in google play store. Till now not faced any problem.

merbin2012 commented 5 years ago

@arijitnaskar What is your cordova version?

arijitnaskar commented 5 years ago

@merbin2012 I am using cordova 8. Edit: Just now I changed all the versions from 11.0 to 15.0.1 and its working. Seems like the "+" for all is not working because I thing it is taking different versions for different libraries.

Lencebo commented 5 years ago

I solved the issue.

initially after installing both the plugin my project.properties was like below:

cordova.system.library.1=com.google.android.gms:play-services-base:11.0.4
cordova.system.library.2=com.google.android.gms:play-services-ads:11.0.4
cordova.system.library.3=com.google.android.gms:play-services-games:+
cordova.system.library.4=com.google.android.gms:play-services-plus:+

It was throwing error while building. Then I changed like below as suggested in above comments.

cordova.system.library.1=com.google.android.gms:play-services-base:+
cordova.system.library.2=com.google.android.gms:play-services-ads:+
cordova.system.library.3=com.google.android.gms:play-services-games:+
cordova.system.library.4=com.google.android.gms:play-services-plus:+

This change allowed me to build. But the app was crashing after installation. Then I thought may be the admob plugin will not work if I use version greater that 11.0.4 So changed like below and its working.

cordova.system.library.1=com.google.android.gms:play-services-base:11.0.4
cordova.system.library.2=com.google.android.gms:play-services-ads:11.0.4
cordova.system.library.3=com.google.android.gms:play-services-games:11.0.4
cordova.system.library.4=com.google.android.gms:play-services-plus:11.0.4

Spend almost 20 hours for this simple versioning issue :( It feels frustrating when you see you have no error in your code but the environment is destroying the application. :(

** I am not using Ionic. I am using simple cordova to build. But I think this will work for Ionic build also.

Thanks man, this one worked for me aswell, you saved my ass, cheers!

JMCollins commented 5 years ago

My issue occurred after updating the google Admob SDK. I found that the app would crash with "Unfortunately AppName has stopped unexpectedly" if I did the following.

ionic start AppName blank --type ionic-angular
ionic cordova platform add android
ionic cordova plugin add cordova-plugin-admobpro

OR ionic cordova plugin add cordova-plugin-admob-free

ionic cordova run android

I got the stack trace off the device by using ~/Android/Sdk/platform-tools/adb logcat and found the following error message:


dalejomen commented 5 years ago

good morning, I have problems with the plugin cordova-plugin-admobpro when I compile my project and generate the apk for android generates it well. but when I install the apk in my cellphone to application does not load the program is closed.

This was working fine until last week as this plugin used it in several apps.

bgosalci commented 5 years ago

Follow the instructions, you need to load additional package in Android SDK. Had the same problem but now resolved.

It's a screenshot on the readme.

Hope this helps you.

On Thu, 11 Oct 2018 at 18:36, dalejomen notifications@github.com wrote:

good morning, I have problems with the plugin cordova-plugin-admobpro when I compile my project and generate the apk for android generates it well. but when I install the apk in my cellphone to application does not load the program is closed.

This was working fine until last week as this plugin used it in several apps.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ratson/cordova-plugin-admob-free/issues/141#issuecomment-429048658, or mute the thread https://github.com/notifications/unsubscribe-auth/AAyTIvFL_V-0KF_cMeUVzLsy7FfbHsfAks5uj4GSgaJpZM4RN6Sj .

--

Burim Gosalci

dalejomen commented 5 years ago

I did not understand the solution

chintaner commented 5 years ago

Follow the instructions, you need to load additional package in Android SDK. Had the same problem but now resolved. It's a screenshot on the readme. Hope this helps you. On Thu, 11 Oct 2018 at 18:36, dalejomen @.***> wrote: good morning, I have problems with the plugin cordova-plugin-admobpro when I compile my project and generate the apk for android generates it well. but when I install the apk in my cellphone to application does not load the program is closed. This was working fine until last week as this plugin used it in several apps. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#141 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AAyTIvFL_V-0KF_cMeUVzLsy7FfbHsfAks5uj4GSgaJpZM4RN6Sj . -- Burim Gosalci

Where is the solution? PLease post here.