Multiple dex files Build Error After Updating to ns 3.3 ng 4.4.1


#1

EDIT- this post seems related.

I just upgraded from ns 3.2 to 3.3 and at the same time upgraded to angular 4.4.1 along with upgrading various nativescript plugins.

When I try to run the app (android from win10) I now get:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithDexForF0F1F2F3F4Debug'.
> 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/internal/zzbzv;

Googling around I tried deleting any zip, tar, or gz files in my node modules.
I also tried

npm uninstall nativescript
npm install nativescript
tns platform clean android

but no go. Any ideas?

>tns info
All NativeScript components versions information
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Component        β”‚ Current version β”‚ Latest version β”‚ Information      β”‚
β”‚ nativescript     β”‚ 3.3.0           β”‚ 3.3.0          β”‚ Up to date       β”‚
β”‚ tns-core-modules β”‚ 3.3.0           β”‚ 3.3.0          β”‚ Up to date       β”‚
β”‚ tns-android      β”‚ 3.3.0           β”‚ 3.3.0          β”‚ Up to date       β”‚
β”‚ tns-ios          β”‚ 3.1.0           β”‚ 3.3.0          β”‚ Update available β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Here’s my package.json:

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "org.nativescript.myHiddenApp",
    "tns-ios": {
      "version": "3.1.0"
    },
    "tns-android": {
      "version": "3.3.0"
    }
  },
  "dependencies": {
    "@angular/animations": "~4.4.1",
    "@angular/common": "~4.4.1",
    "@angular/compiler": "~4.4.1",
    "@angular/core": "~4.4.1",
    "@angular/forms": "~4.4.1",
    "@angular/http": "~4.4.1",
    "@angular/platform-browser": "~4.4.1",
    "@angular/platform-browser-dynamic": "~4.4.1",
    "@angular/router": "~4.4.1",
    "crypto-js": "^3.1.9-1",
    "nativescript-angular": "^4.4.1",
    "nativescript-background-http": "^3.0.0",
    "nativescript-fresco": "~3.0.6",
    "nativescript-geolocation": "~4.2.0",
    "nativescript-google-maps-sdk": "^2.4.2",
    "nativescript-master-technology": "^1.1.1",
    "nativescript-platform-css": "^1.6.5",
    "nativescript-sqlite": "^1.1.11",
    "nativescript-theme-core": "^1.0.4",
    "nativescript-unit-test-runner": "^0.3.4",
    "oauth-signature": "^1.3.1",
    "reflect-metadata": "~0.1.10",
    "rxjs": "~5.4.3",
    "tns-core-modules": "^3.3.0",
    "util": "^0.10.3",
    "zone.js": "~0.8.2"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~4.4.1",
    "@ngtools/webpack": "1.6.2",
    "babel-traverse": "6.26.0",
    "babel-types": "6.26.0",
    "babylon": "6.18.0",
    "copy-webpack-plugin": "~4.0.1",
    "extract-text-webpack-plugin": "2.1.2",
    "jasmine-core": "^2.8.0",
    "karma": "^1.7.1",
    "karma-jasmine": "^1.1.0",
    "karma-nativescript-launcher": "^0.4.0",
    "lazy": "1.0.11",
    "nativescript-css-loader": "~0.26.1",
    "nativescript-dev-sass": "^1.3.0",
    "nativescript-dev-typescript": "~0.5.0",
    "nativescript-dev-webpack": "^0.8.0",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "^2.1.0",
    "tns-platform-declarations": "^3.3.0",
    "typescript": "^2.5.2",
    "webpack": "~2.7.0",
    "webpack-sources": "~1.0.1",
    "webpack-bundle-analyzer": "^2.8.2",
    "nativescript-worker-loader": "~0.8.1"
  },
  "scripts": {
    "ns-bundle": "ns-bundle",
    "publish-ios-bundle": "npm run ns-bundle --ios --publish-app",
    "generate-android-snapshot": "generate-android-snapshot --targetArchs arm,arm64,ia32 --install",
    "start-android-bundle": "npm run ns-bundle --android --run-app",
    "start-ios-bundle": "npm run ns-bundle --ios --run-app",
    "build-android-bundle": "npm run ns-bundle --android --build-app",
    "build-ios-bundle": "npm run ns-bundle --ios --build-app"
  }
}

#2

Downgrading to "nativescript-geolocation": "^3.0.1" β€œfixed” the issue for me.


#3

That can usually happen when you don’t purge the platforms/android dir between updating/changing a multitude of android plugins, since they can carry along different versions of .aars and .jars.


#4

and when you get the multidex error,
you can add this to your app.gradle file, inside default config.

android {  
  defaultConfig {  
    multiDexEnabled true
  }
}

#5

I believe that enabling multiDex support is necessary when you get a dex overflow of 65536 methods and up - https://developer.android.com/studio/build/multidex.html


#6

Thanks guys… adding multiDexEnabled true removed the multiple dex files error. But then I get the error:

FAILURE: Build failed with an exception.

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

So I purged the android platform directory with

tns platform remove android
tns platform add android

But I’m still getting the duplicate entry error for com/google/android/gms/internal/zzbzo.class

This only happens if I use "nativescript-geolocation": "4.2.0" rather than "nativescript-geolocation": "3.0.1"


#7

Then it’s some incompatibility between google versions of certain plugins in your application. I’d hardcode the geolocation veresion in its include.gradle to be like that of google maps, as a temporary workaround. Contact the plugin author to get this resolved, if there isnt an issue already.