Nativescript: dex file cannot exceed 64K error

Created on 4 Jun 2019  路  4Comments  路  Source: NativeScript/NativeScript

hello, i can't run a stable project that runs with another pc and i have the following error:

D8: Cannot fit requested classes in a single dex file (# methods: 106083 > 65536)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
  The number of method references in a .dex file cannot exceed 64K.
  Learn how to resolve this issue at 
   https://developer.android.com/tools/building/multidex.html

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

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

i've seen that this is an error thrown with older versions of nativescript, my configuration is this:

{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
    "id": "xxxxxxx",
    "tns-ios": {
        "version": "5.0.0-rc-2018-10-12-131715-01"
    },
    "tns-android": {
        "version": "5.1.0"
    }
},
"dependencies": {
    "html-entities": "^1.2.1",
    "moment": "^2.22.2",
    "nativescript-checkbox": "^3.0.3",
    "nativescript-drop-down": "^4.0.1",
    "nativescript-loading-indicator": "^2.4.0",
    "nativescript-phone": "^1.3.1",
    "nativescript-plugin-firebase": "^8.3.0",
    "nativescript-theme-core": "^1.0.4",
    "nativescript-ui-listview": "^6.3.0",
    "nativescript-ui-sidedrawer": "^4.3.0",
    "tns-core-modules": "^5.3.1"
},
"devDependencies": {
    "babel-traverse": "6.4.5",
    "babel-types": "6.4.5",
    "babylon": "6.4.5",
    "lazy": "1.0.11"
    }
}

someone could help me? i tried also upgrading nativescript version and tns-core modules.
thank you

needs more info android question

Most helpful comment

@peppeg85 can you try to modify your project's app.gradle file as done here (enabling multidex)

e.g.

android {
  defaultConfig {
    multiDexEnabled true
  }
}

All 4 comments

@peppeg85 can you try to modify your project's app.gradle file as done here (enabling multidex)

e.g.

android {
  defaultConfig {
    multiDexEnabled true
  }
}

yes, now it works.....but why on the other pc it works without this trick? we have more pcs and it happens to work on the same project from different pcs....
anyway, thank you

@peppeg85 it has to do with the resources needed for Dalvik to work _ see here for more details

android {
defaultConfig {
multiDexEnabled true
}
}

Was this page helpful?
0 / 5 - 0 ratings