Unable to run app using cordova after installing Firebase X

I am able to run my ionic app using ionic cordova run android fine, but then I add the following plugins:

cordova plugin add cordova-plugin-firebasex

npm install @ionic-native/firebase-x

Then I add the following to app.module.ts:

import { FirebaseX } from '@ionic-native/firebase-x/ngx';

providers: [
FirebaseX
]

Now when I run the app, it fails, & I get the following console output, can someone please tell me what I did wrong & what needs to change:

C:\Users\damie.gradle\caches\transforms-1\files-1.1\guava-26.0-android.jar\56894ff0d24741572c1b24be8e9453ef\jetified-guava-26.0-android.jar: D8: Type sun.misc.Unsafe was not found, it is required for default or static interface methods desugaring of sun.misc.Unsafe com.google.common.primitives.UnsignedBytes$LexicographicalComparatorHolder$UnsafeComparator.getUnsafe()
C:\Users\damie.gradle\caches\transforms-1\files-1.1\guava-26.0-android.jar\56894ff0d24741572c1b24be8e9453ef\jetified-guava-26.0-android.jar: D8: Type sun.misc.Unsafe was not found, it is required for default or static interface methods desugaring of void com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper.<clinit>()

D8: Cannot fit requested classes in a single dex file (# methods: 119442 > 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> Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
    option to get more log output. Run with --scan to get full insights.

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

BUILD FAILED in 2m 36s
40 actionable tasks: 13 executed, 27 up-to-date
C:\Users\damie\Documents\Ionic\my-mechanic\platforms\android\gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\damie\Documents\Ionic\my-mechanic\platforms\android\app\src\main\java\org\apache\cordova\file\AssetFilesystem.java uses
unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
D8: Cannot fit requested classes in a single dex file (# methods: 119442 > 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

2 Likes

idem here, following…

also added to project structure

multiDexEnabled true
implementation 'androidx.multidex:multidex:2.0.0'

but same error while building

UPDATE
I was able to build also adding multiDexEnabled true in build.gradle at module level

Modify the module-level build.gradle file to enable multidex and add the multidex library as a dependency, as shown here:


android {
    defaultConfig {
        ...
        minSdkVersion 15 
        targetSdkVersion 28
        multiDexEnabled true
    }
    ...
}

dependencies {
  implementation 'com.android.support:multidex:1.0.3'
}

this work for me;
Add o update is version in gradle.properties

cdvMinSdkVersion = 21

And platform/android/build.gradle

defaultMinSdkVersion = 21

ionic info is:

Ionic:

   Ionic CLI                     : 5.4.16 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.9.1
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 16 other plugins)

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v10.17.0 (/usr/local/bin/node)
   npm    : 6.11.3
   OS     : macOS Catalina
2 Likes