Ionic 4 build error – Cannot read property ‘getBufferedLength’ of undefined

Issue

When i try to ‘ionic cordova –prod build android’, i have this error :

Error: Cannot read property ‘getBufferedLength’ of undefined

ANDROID_HOME/usr/local/Caskroom/android-sdk/4333796 (DEPRECATED)
Failed to run "javac -version", make sure that you have a JDK version 8 installed.
You can get it from the following location:
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Your JAVA_HOME is invalid: /Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home
Error: Cannot read property 'getBufferedLength' of undefined
[ERROR] An error occurred while running subprocess cordova.

What is strange is that when i enter ‘javac -version’ the output is :

macbook$ javac -version
javac 1.8.0_261

also, ‘ionic cordova requirements’ crash :

> cordova requirements
Error: Cannot read property 'getBufferedLength' of undefined

My package.json :

"dependencies": {
    "@angular/common": "^7.2.16",
    "@angular/core": "^7.2.16",
    "@angular/forms": "^7.2.16",
    "@angular/http": "^7.2.16",
    "@angular/platform-browser": "^7.2.16",
    "@angular/platform-browser-dynamic": "^7.2.16",
    "@angular/router": "^7.2.16",
    "@ionic-native/card-io": "^5.30.0",
    "@ionic-native/core": "^5.30.0",
    "@ionic-native/facebook": "^5.30.0",
    "@ionic-native/fcm": "^5.30.0",
    "@ionic-native/firebase": "^5.30.0",
    "@ionic-native/qr-scanner": "^5.30.0",
    "@ionic-native/splash-screen": "^5.30.0",
    "@ionic-native/status-bar": "^5.30.0",
    "@ionic-native/stripe": "^5.30.0",
    "@ionic/angular": "^4.11.13",
    "card.io.cordova.mobilesdk": "2.1.0",
    "cordova-browser": "^6.0.0",
    "cordova-ios": "5.0.1",
    "cordova-plugin-add-swift-support": "2.0.2",
    "cordova-plugin-facebook4": "1.7.4",
    "cordova-plugin-fcm-with-dependecy-updated": "^3.2.0",
    "cordova-plugin-qrscanner": "3.0.1",
    "cordova-plugin-stripe": "1.5.3",
    "cordova-support-android-plugin": "1.0.1",
    "cordova-support-google-services": "1.3.2",
    "core-js": "^2.6.12",
    "firebase": "7.17.1",
    "node-sass": "^4.12.0",
    "nodemailer": "^6.4.16",
    "rxjs": "^6.6.3",
    "tslib": "^1.14.1",
    "zone.js": "~0.8.29"
  },
  "devDependencies": {
    "@angular-devkit/architect": "~0.13.8",
    "@angular-devkit/build-angular": "~0.13.8",
    "@angular-devkit/core": "~7.3.8",
    "@angular-devkit/schematics": "~7.3.8",
    "@angular/cli": "7.3.9",
    "@angular/compiler": "^7.2.16",
    "@angular/compiler-cli": "^7.2.16",
    "@angular/language-service": "^7.2.16",
    "@ionic/angular-toolkit": "~1.5.1",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "^2.0.8",
    "@types/node": "~12.0.0",
    "codelyzer": "~4.5.0",
    "cordova-android": "9.0.0",
    "cordova-plugin-device": "^2.0.3",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-ionic-webview": "^4.1.3",
    "cordova-plugin-splashscreen": "^5.0.3",
    "cordova-plugin-statusbar": "^2.4.3",
    "cordova-plugin-whitelist": "^1.3.4",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^5.2.3",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^2.0.6",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~5.17.0",
    "typescript": "~3.1.6"
  }

I have spend several hours trying to fix that problem to build my application with no success. Any help would be greatly appreciated !

Solution

So after some research, I found the problem. I was trying to use the Barcode scanner along with the QR code scanner from Ionic modules. Those are not compatible.

What i did was remove the Barcode scanner and implement this pull request to my QR code module in order to be able to use Barcode with the QR code module : pull request in QR code module to support barcode

At the end of the day everything worked fine.

Answered By – Aion

Leave a Comment