Search code examples
cordovabuildionic-framework

cordova build android and ionic build android results in "SyntaxError: Unexpected token" after bluescreen


I've built my app (cordova, ionic) using cordova build android. But while it was building I got a blue screen... Now I can't build the app, neither with ionic build... nor cordova build...

I've updated nodeJS, cordova, and ionic using npm.. but still get the same error. I even restored my daily backup from today morning, but the error remains.

Error:

C:\***\DEV\App\flugdeck>cordova build android

Running command: "C:\Program Files\nodejs\node.exe" "C:\***\DEV\App\flugdeck\hooks\before_prepare\01_jshint.js" "C:\***\DEV\App\flugdeck"

Linting www/js/app.js
File www/js/app.js has no errors.
-----------------------------------------
Linting www/js/config.js
File www/js/config.js has no errors.
-----------------------------------------
Linting www/js/controllers.js
File www/js/controllers.js has no errors.
-----------------------------------------
Linting www/js/controller_flightlog.js
File www/js/controller_flightlog.js has no errors.
-----------------------------------------
Linting www/js/controller_infotools.js
File www/js/controller_infotools.js has no errors.
-----------------------------------------
Linting www/js/controller_timetools.js
File www/js/controller_timetools.js has no errors.
-----------------------------------------
Linting www/js/directives.js
File www/js/directives.js has no errors.
-----------------------------------------
Linting www/js/factories.js
File www/js/factories.js has no errors.
-----------------------------------------
Linting www/js/filters.js
File www/js/filters.js has no errors.
-----------------------------------------
Linting www/js/mymodules.js
File www/js/mymodules.js has no errors.
-----------------------------------------
Linting www/js/services.js
File www/js/services.js has no errors.
-----------------------------------------
Linting www/js/templates.js
File www/js/templates.js has no errors.
-----------------------------------------

SyntaxError: Unexpected token
    at Object.parse (native)
    at Function.PlatformJson.load (C:\Users\MyUserName\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\util\PlatformJson.js:35:21)
    at Object.handlePrepare (C:\Users\MyUserName\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\prepare.js:48:37)
    at C:\Users\MyUserName\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\prepare.js:105:21
    at Array.map (native)
    at C:\Users\MyUserName\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\prepare.js:70:40
    at _fulfilled (C:\Users\MyUserName\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:787:54)
    at self.promiseDispatch.done (C:\Users\MyUserName\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:816:30)
    at Promise.promise.promiseDispatch (C:\Users\MyUserName\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:749:13)
    at C:\Users\MyUserName\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:557:44

Solution

  • I've found a workaround:

    1. Backup your complete app directory
    2. Remove Android support from the app with the command cordova platform remove android
    3. Delete the directory root/platforms/android
    4. Add platform support with the command cordova platform add android
    5. Run it once with the command cordova run android
    6. Copy and overwrite the existing AndroidManifest.xml from your backup into the directory root/platforms/android
    7. Run the command cordova build android