Build problem after adding Admob Free plugin

#1

Without Admob I can build apk.
But after install Admob Free plugin, build command giving error.

firstly it was given another error, which I resolved by adding “multiDexEnabled true” into “build.gradle” file.

Now new issue: Execution failed for task ==

Execution failed for task ':transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException
: duplicate entry: com/google/android/gms/internal/zzalj.class

Full Error:

D:\projectDir>ionic cordova build android --prod --release
...
...
:compileReleaseSources
:transformClassesWithJarMergingForRelease
 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException
: duplicate entry: com/google/android/gms/internal/zzalj.class

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s

38 actionable tasks: 36 executed, 2 up-to-date
(node:6432) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with ex
it 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.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException
: duplicate entry: com/google/android/gms/internal/zzalj.class

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
    at ChildProcess.whenDone (D:\projectDir\platforms\android\cordova\no
de_modules\cordova-common\src\superspawn.js:169:23)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:557:12)
(node:6432) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This
error originated either by throwing inside of an async function without a catch
block, or by rejecting a promise which was not handled with .catch(). (rejection
 id: 1)
(node:6432) [DEP0018] DeprecationWarning: Unhandled promise rejections are depre
cated. In the future, promise rejections that are not handled will terminate the
 Node.js process with a non-zero exit code.


D:\projectDir>

Edit:
Here is the dummy repo of the issue https://github.com/amin2009/conf102

#2

Ionic info:

$ ionic info
cli packages: (C:\Users\USERNAME\AppData\Roaming\npm\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.10
    Cordova Platforms  : android 6.4.0
    Ionic Framework    : ionic-angular 3.9.2
System:
    Android SDK Tools : 26.1.1
    Node              : v8.11.3
    npm               : 5.6.0
    OS                : Windows 8.1
Environment Variables:
    ANDROID_HOME : C:\Users\USERNAME\\AppData\Local\Android\Sdk
Misc:
    backend : pro

#3

have you found anything about this error?

#4

Nope.
I skipped ad display. I added placeholder, and released my app.

#5

I use admob free in my android app. Only solution I found that worked for me was to do the following:

ionic cordova platform remove android
ionic cordova platform add android@6.3.0

There are some newer versions of the plugin in development that try to fix this (check on GitHub for forks), but none worked for me, but your luck may differ.