Package Native Android, was working, now fails

I started getting failures with Ionic Pro Native Packaging on Android. The failure is:

:transformDexWithDexForRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ‘:transformDexWithDexForRelease’.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/auth/api/signin/internal/zzo;

To attempt tracking where the error originated, I submitted native packaging jobs to other builds in my build history to see which commit introduced the problem. This got me to the point where I ended up submitting a native packaging job to the last job where native packaging succeeded. This time it failed.

Comparing logs between the failed and successful packaging I noticed that the build is now using https://jcenter.bintray.com/com/google/gms/google-services/3.2.1/google-services-3.2.1.jar. There are other version updates. My theory is that there is some dependency in my project that is not pegged to a specific version and so the Packaging jobs running on ionic pro are not packaging with identical versions.

My project seems to package fine on my local host with ionic cordova build android --prod --release. I even went through the steps on https://ionic.zendesk.com/hc/en-us/articles/115015846847-Troubleshooting-snapshot-build-failures- to attempt locally identifying how to fix, but what succeeds locally, fails on ionic pro.

Any advice would be welcome. Thank you

i can fix doing that. On the platform/android/project.properties i have the following dependencies :

target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.facebook.android:facebook-android-sdk:4.+
cordova.system.library.2=com.google.android.gms:play-services-maps:+
cordova.system.library.3=com.google.android.gms:play-services-location:+
cordova.system.library.4=com.google.android.gms:play-services-auth:11.8.0
cordova.system.library.5=com.google.android.gms:play-services-identity:11.8.0

i repleaced with :

target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.facebook.android:facebook-android-sdk:4.+
cordova.system.library.2=com.google.android.gms:play-services-maps:11.8.0
cordova.system.library.3=com.google.android.gms:play-services-location:11.8.0
cordova.system.library.4=com.google.android.gms:play-services-auth:11.8.0
cordova.system.library.5=com.google.android.gms:play-services-identity:11.8.0

i put the same version of ‘com.google.android.gms’ differents artifcats and build success

Hope that help

Thanks for the advice @snakepit

When I build android locally with

ionic cordova build android --prod --release

I don’t have this issue. The problem is only on the ionic pro build channel, when I select package native binary. These builds come from my .git channel, I don’t commit my platforms files there and I am a little hesitant to update my config.json to try and do a edit-config patch of the android project.properties.

Its not that big a deal I suppose of the ionic pro native packaging for android fails since I can do so on my own workstation.

I’m not sure why, but now I am seeing the problem on my local builds.

Tracking things down I think it might be an incompatibility between cordova-plugin-firebase and cordova-plugin-googleplus.

I created a new ionic project added these plugins and ionic build android fails with the same error.

<plugin name=“cordova-plugin-firebase” spec=“^0.1.25” />
<plugin name=“cordova-plugin-googleplus” spec=“^5.2.2” />

Hi@diydanielle
Try this

ionic cordova platform rm android
ionic cordova platform add android

Thanks I tried, it over and over again. tried deleting node_modules, plugins, package-lock.json.
I tried

rm -rf node_modules plugins, package-lock.json
npm install
ionic cordova platform rm android
ionic cordova platform add android@6,4.0
ionic cordova build

got the same error.

I would get the same error doing

ionic start testbuild blank
cd testbuild
ionic platform add android@6.4.0
ionic cordova plugin add cordova-plugin-firebase
ionic cordova plugin add cordova-plugin-googleplus
ionic cordova build android

my ionic info:

cli packages: (C:\Users\Daddy B\AppData\Roaming\npm\node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
System:
Node : v8.9.4
npm : 5.6.0
OS : Windows 10
Misc:
backend : pro

What I finally found that helps is adding this plugin: GitHub - dpa99c/cordova-android-play-services-gradle-release: Cordova/Phonegap plugin for Android to align versions of the Play Services library components specified by other plugins to a specific version.

TL;DR: To prevent build failures caused by including different versions of the Play Services library.

Some Cordova plugins include the Play Services library to faciliate them. Most commonly, these are now included into the Cordova project by specifying them as Gradle dependencies (see the Cordova plugin spec documenation).

Example plugins:

cordova-plugin-googleplus
phonegap-plugin-push@1
google-analytics-plugin

The problem arises when these plugins specify different versions of the Play Services library. This can cause build failures to occur, which are not easy to resolve without changes by the plugin authors to align the specified versions. See these issues:

phonegap-plugin-push#17720
google-analytics-plugin#427
cordova-plugin-googleplus#398

To resolve these version collisions, this plugin injects a Gradle configuration file into the native Android platform project, which overrides any versions specified by other plugins, and forces them to the version specified in its Gradle file.

If you’re encountering similar problems with the Android Support libraries, checkout the sister plugin: cordova-android-support-gradle-release.