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

Error during build on cordova 8.0.0 #143

Closed rjoydip-zz closed 6 years ago

rjoydip-zz commented 6 years ago

Hi @ratson I am getting these error during build on ionic 1 project which is build on cordova latest version

error: package name.ratson.cordova.admob.banner does not exist
import name.ratson.cordova.admob.banner.BannerExecutor;

error: package name.ratson.cordova.admob.interstitial does not exist
import name.ratson.cordova.admob.interstitial.InterstitialExecutor;

error: package name.ratson.cordova.admob.rewardvideo does not exist
import name.ratson.cordova.admob.rewardvideo.RewardVideoExecutor;

error: cannot find symbol
    private BannerExecutor bannerExecutor = null;
            ^
symbol:   class BannerExecutor
location: class AdMob

error: cannot find symbol
    private InterstitialExecutor interstitialExecutor = null;
            ^
symbol:   class InterstitialExecutor
location: class AdMob

error: cannot find symbol
    private RewardVideoExecutor rewardVideoExecutor = null;
            ^
symbol:   class RewardVideoExecutor
location: class AdMob

error: cannot find symbol
    bannerExecutor = new BannerExecutor(this);
                         ^
symbol:   class BannerExecutor
location: class AdMob

error: cannot find symbol
    interstitialExecutor = new InterstitialExecutor(this);
                                ^
symbol:   class InterstitialExecutor
location: class AdMob

error: cannot find symbol
    rewardVideoExecutor = new RewardVideoExecutor(this);
                                ^
symbol:   class RewardVideoExecutor
location: class AdMob
souly1 commented 6 years ago

+1 any update about this?

bulbul-ismail commented 6 years ago

+1

jpglomot commented 6 years ago

Same issue with a brand new generated empty ionic 3 application (same cordova 8.0.0 version)

itsyub commented 6 years ago

Had the same issue when upgraded to cordova 8.0.0. I fixed it by copying following 3 folders to platforms/android/app/src/main/java/name/ratson/cordova/admob/

platforms/android/src/name/ratson/cordova/admob/banner platforms/android/src/name/ratson/cordova/admob/interstitial platforms/android/src/name/ratson/cordova/admob/rewardvideo

it's dirty fix, but for now i can build my app. ;)

RenaudRohlinger commented 6 years ago

So, basically as itsyub said we just need to update the plugin.xml file at the following lines :

Ligne 48 - 50

FROM

<source-file src="src/android/banner" target-dir="src/name/ratson/cordova/admob" />
<source-file src="src/android/interstitial" target-dir="src/name/ratson/cordova/admob" />
<source-file src="src/android/rewardvideo" target-dir="src/name/ratson/cordova/admob" />

TO

<source-file src="src/android/banner" target-dir="src/main/java/name/ratson/cordova/admob" />
<source-file src="src/android/interstitial" target-dir="src/main/java/name/ratson/cordova/admob" />
<source-file src="src/android/rewardvideo" target-dir="src/main/java/name/ratson/cordova/admob" />

But since cordova plugin add [GIT_URL] is not supported I cannot really try if the fix works & PR ...

itsyub commented 6 years ago

@RenaudROHLINGER yes that's what needs to be done to fix such error, but these changes are required only required for Cordova 8.0.0. If you do these changes in plugin.xml, it won't work with the previous version of Cordova.

shinobirozs commented 6 years ago

Hi guys,

I did the exact things as indicated above. But I still cannot build for android. Any other techniques or steps that I can perform to fix this?

:app:mergeDebugAssets UP-TO-DATE
:app:extractTryWithResourcesSupportJarDebug UP-TO-DATE
:app:transformClassesWithStackFramesFixerForDebug UP-TO-DATE
: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.DefaultMethodClassFixer$DefaultMethodFinder.visit(DefaultMethodClassFixer.java:471)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at com.google.devtools.build.android.desugar.DefaultMethodClassFixer.defaultMethodsDefined(DefaultMethodClassFixer.java:319)
shinobirozs commented 6 years ago

I recreated my cordova project from scratch and pasted the 3 folders

platforms/android/src/name/ratson/cordova/admob/banner platforms/android/src/name/ratson/cordova/admob/interstitial platforms/android/src/name/ratson/cordova/admob/rewardvideo

To

platforms/android/app/src/main/java/name/ratson/cordova/admob/

and I am able to compile in android now. Without recreating the project, it seems it cannot work. But luckily the workaround works. I'll just include it for now on my python script.

@itsyub, saved me some time.

RenaudRohlinger commented 6 years ago

Temporally you can cordova plugin add https://github.com/RenaudROHLINGER/lycwed-cordova-plugin-admob-free

my repo is fixed for the latest version. I can't really PR this repo atm since this is a specific cordova 8.0 issue

berlanga2008 commented 6 years ago

Thanks a lot, Now I can build my app

pacificip commented 6 years ago

You should try with old version of the plugin:

<plugin name="cordova-plugin-admob-free" spec="0.12.0" source="npm" />

Works for me :-)

X0t0 commented 6 years ago

@RenaudROHLINGER Bro i'm getting this error after doing the copy and past of folders Dex: Error converting bytecode to dex: Cause: PARSE ERROR: class name (com/google/android/gms/R) does not match path (Com/google/android/gms/R.class) ...while parsing Com/google/android/gms/R.class

X0t0 commented 6 years ago

@itsyub Bro i'm getting this error after doing the copy and past of folders Dex: Error converting bytecode to dex: Cause: PARSE ERROR: class name (com/google/android/gms/R) does not match path (Com/google/android/gms/R.class) ...while parsing Com/google/android/gms/R.class

aabdolla commented 6 years ago

So I also copied the three missing admob folders to the correct directory but now I am getting this error and not finding much on google about it:

error: cannot access zze isGpsAvailable = (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(cordova.getActivity()) == ConnectionResult.SUCCESS);

class file for com.google.android.gms.common.zze not found

Anyone else get this?

tennist commented 6 years ago

To sum up everything, the fix for this issue is to change lines 48-56 in the plugin.xml file to


        <source-file src="src/android/interstitial" target-dir="app/src/main/java/name/ratson/cordova/admob" />
        <source-file src="src/android/rewardvideo" target-dir="app/src/main/java/name/ratson/cordova/admob" />

        <source-file src="src/android/AbstractExecutor.java" target-dir="app/src/main/java/name/ratson/cordova/admob" />
        <source-file src="src/android/Actions.java" target-dir="app/src/main/java/name/ratson/cordova/admob" />
        <source-file src="src/android/AdMob.java" target-dir="app/src/main/java/name/ratson/cordova/admob" />
        <source-file src="src/android/AdMobConfig.java" target-dir="app/src/main/java/name/ratson/cordova/admob" />
        <source-file src="src/android/CordovaEventBuilder.java" target-dir="app/src/main/java/name/ratson/cordova/admob" />

        <framework src="com.google.android.gms:play-services-base:+" />
        <framework src="com.google.android.gms:play-services-ads:+" />
Wolf00Bomber commented 6 years ago

@rjoydip is the Fix applied to the plugin? If so close the Issue, else please keep it open. We can't go through the Issues and find a fix and move on. Wasted nearly 4 hours trying to find a solution to this published plugin :(

Wolf00Bomber commented 6 years ago

Even now after using the above fix, its not fixed.

See Log:

Note: Some input files use or override a deprecated API.

Note: Recompile with -Xlint:deprecation for details.

:app:processDebugManifest

:app:processDebugResources

:app:generateDebugSources :app:compileDebugNdk NO-SOURCE :app:mergeDebugAssets

:app:processDebugJavaRes NO-SOURCE :CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug

:app:javaPreCompileDebug

:app:compileDebugJavaWithJavac E:\Ionic Projects\DemoP2P\platforms\android\app\src\main\java\name\ratson\cordova\admob\AdMob.java:27: error: package name.ratson.cordova.admob.banner does not exist

import name.ratson.cordova.admob.banner.BannerExecutor; ^ E:\Ionic Projects\DemoP2P\platforms\android\app\src\main\java\name\ratson\cordova\admob\AdMob.java:28: error: package name.ratson.cordova.admob.interstitial does not exist import name.ratson.cordova.admob.interstitial.InterstitialExecutor; ^ E:\Ionic Projects\DemoP2P\platforms\android\app\src\main\java\name\ratson\cordova\admob\AdMob.java:29: error: package name.ratson.cordova.admob.rewardvideo does not exist import name.ratson.cordova.admob.rewardvideo.RewardVideoExecutor; ^ E:\Ionic Projects\DemoP2P\platforms\android\app\src\main\java\name\ratson\cordova\admob\AdMob.java:44: error: cannot find symbol private BannerExecutor bannerExecutor = null; ^ symbol: class BannerExecutor location: class AdMob E:\Ionic Projects\DemoP2P\platforms\android\app\src\main\java\name\ratson\cordova\admob\AdMob.java:45: error: cannot find symbol private InterstitialExecutor interstitialExecutor = null; ^ symbol: class InterstitialExecutor location: class AdMob E:\Ionic Projects\DemoP2P\platforms\android\app\src\main\java\name\ratson\cordova\admob\AdMob.java:46: error: cannot find symbol private RewardVideoExecutor rewardVideoExecutor = null; ^ symbol: class RewardVideoExecutor location: class AdMob E:\Ionic Projects\DemoP2P\platforms\android\app\src\main\java\name\ratson\cordova\admob\AdMob.java:70: error: cannot find symbol bannerExecutor = new BannerExecutor(this); ^ symbol: class BannerExecutor location: class AdMob E:\Ionic Projects\DemoP2P\platforms\android\app\src\main\java\name\ratson\cordova\admob\AdMob.java:73: error: cannot find symbol interstitialExecutor = new InterstitialExecutor(this); ^ symbol: class InterstitialExecutor location: class AdMob E:\Ionic Projects\DemoP2P\platforms\android\app\src\main\java\name\ratson\cordova\admob\AdMob.java:76: error: cannot find symbol rewardVideoExecutor = new RewardVideoExecutor(this); ^ symbol: class RewardVideoExecutor location: class AdMob Note: Some input files use or override a deprecated API. FAILED Note: Recompile with -Xlint:deprecation for details. 9 errors

FAILURE: Build failed with an exception.

Ionic info:

` cli packages: (C:\Users\srikrishna\AppData\Roaming\nvm\v6.11.0\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.8
Cordova Platforms  : android 7.1.0
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
Node              : v8.9.1
npm               : 5.5.1
OS                : Windows 8.1

Environment Variables:

ANDROID_HOME : C:\Users\srikrishna\AppData\Local\Android\sdk

Misc:

backend : legacy

`

srikanth-wgl commented 6 years ago

Fix applied in PR #189. Try with the latest version of the plugin (v0.15.0).

tennist commented 5 years ago

in the latest version of this plugin, the following lines still need to be added to the android platform section of the plugin.xml file.

<framework src="com.google.android.gms:play-services-base:+" />
<framework src="com.google.android.gms:play-services-ads:+" />
arijitnaskar commented 5 years ago

I am using the latest version with Cordova 8. Its not working. I made below changes. But no luck.

    <source-file src="src/android/banner/BannerListener.java" target-dir="app/src/main/java/name/ratson/cordova/admob/banner" />
    <source-file src="src/android/interstitial/InterstitialExecutor.java" target-dir="app/src/main/java/name/ratson/cordova/admob/interstitial" />
    <source-file src="src/android/interstitial/InterstitialListener.java" target-dir="app/src/main/java/name/ratson/cordova/admob/interstitial" />
    <source-file src="src/android/rewardvideo/RewardVideoExecutor.java" target-dir="app/src/main/java/name/ratson/cordova/admob/rewardvideo" />
    <source-file src="src/android/rewardvideo/RewardVideoListener.java" target-dir="app/src/main/java/name/ratson/cordova/admob/rewardvideo" />

    <source-file src="src/android/AbstractExecutor.java" target-dir="app/src/main/java/name/ratson/cordova/admob" />
    <source-file src="src/android/Actions.java" target-dir="app/src/main/java/name/ratson/cordova/admob" />
    <source-file src="src/android/AdMob.java" target-dir="app/src/main/java/name/ratson/cordova/admob" />
    <source-file src="src/android/AdMobConfig.java" target-dir="app/src/main/java/name/ratson/cordova/admob" />
    <source-file src="src/android/CordovaEventBuilder.java" target-dir="app/src/main/java/name/ratson/cordova/admob" />

    <framework src="com.google.android.gms:play-services-base:+" />
    <framework src="com.google.android.gms:play-services-ads:+" />