question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

capacitor android "Unexpected token function" with ionic v4 type==angular

See original GitHub issue

Running a simple app (created with wizard) give an error on android platform.

error

error

SyntaxError: Unexpected token functioncapacitor.handleWindowError @ capacitor-runtime.js:324
capacitor-runtime.js:292 SyntaxError: Unexpected token functioncapacitor.handleError @ capacitor-runtime.js:292
vendor.js:65004 Uncaught SyntaxError: Unexpected token function

Tested with simpler startup: cd /tmp ionic start myApp tabs --type=angular

cd myApp npm run build npm install --save @capacitor/cli @capacitor/core npm uninstall --save cordova-plugin-splashscreen npx cap init myApp com.example.myapp npx cap add android npx cap copy … now open android studio on ./android and run app

package.json

{
  "name": "myApp",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "6.0.9",
    "@angular/core": "6.0.9",
    "@angular/forms": "6.0.9",
    "@angular/http": "6.0.9",
    "@angular/platform-browser": "6.0.9",
    "@angular/platform-browser-dynamic": "6.0.9",
    "@angular/router": "6.0.9",
    "@capacitor/android": "^1.0.0-beta.3",
    "@capacitor/cli": "^1.0.0-beta.3",
    "@capacitor/core": "^1.0.0-beta.3",
    "@ionic-native/core": "5.0.0-beta.14",
    "@ionic-native/splash-screen": "5.0.0-beta.14",
    "@ionic-native/status-bar": "5.0.0-beta.14",
    "@ionic/angular": "4.0.0-beta.0",
    "@ionic/ng-toolkit": "1.0.0",
    "@ionic/schematics-angular": "1.0.1",
    "core-js": "^2.5.3",
    "rxjs": "6.2.2",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/cli": "6.0.8",
    "@angular/compiler": "6.0.9",
    "@angular/compiler-cli": "6.0.9",
    "@angular/language-service": "6.0.9",
    "@angular-devkit/architect": "0.7.0-rc.3",
    "@angular-devkit/build-angular": "0.7.0-rc.3",
    "@angular-devkit/core": "0.7.0-rc.3",
    "@angular-devkit/schematics": "0.7.0-rc.3",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~10.5.2",
    "codelyzer": "~4.4.2",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.2",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~2.7.2"
  },
  "description": "An Ionic project"
}

Environment:

> node -v
v8.10.0
> npm list -g --depth=010:04:00 
 ├── ionic@4.0.3
 └── npm@6.3.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
jcesarmobilecommented, Aug 15, 2018

This is because of ES6 not being supported in some old browsers, it specially affects simulators (or VMs) because they don’t get updates. It shouldn’t really affect real devices if they have the System WebView(Android 5-6) or Chrome (Android 7-8) up to date. So @AsbjornRekve, make sure that device has latest version of Chrome.

Anyway, we are working on getting this fixed

0reactions
jcesarmobilecommented, Nov 28, 2018

Closing as the pending ionic issue was closed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected token ? during run ionic 6 application on android ...
... Msg: Uncaught SyntaxError: Unexpected token ? when I run the application in the android emulator. And the app does not want to...
Read more >
Ionic 6 : empty app white screen with android on real device
The app is just ionic start test blank --type=angular -capacitor ... http://localhost/ - Line 287 - Msg: SyntaxError: Unexpected token .
Read more >
Using Push Notifications with Firebase in an Ionic + Angular App
Learn how to get Firebase Cloud Messaging working on iOS and Android in an Ionic app.
Read more >
subprocess exited with error 1 - You.com | The search engine you ...
This is because the path to Android Sdk is not set correctly. ... when I put ionic start myapp tabs --type=angular --capacitor command...
Read more >
(PDF) Build Mobile Apps with Ionic 4 and Firebase Hybrid ...
The component supports phrase-aligned respeaking, translation, and commentary. This work extends the method of Basic Oral Language Documentation by prompting ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found