ionic-team / ionic-app-scripts

App Build Scripts for Ionic Projects
http://ionicframework.com/
MIT License
608 stars 304 forks source link

Can't build for Android after upgrade to 2.2.0 #812

Closed jthoms1 closed 7 years ago

jthoms1 commented 7 years ago

From @jgw96 on March 13, 2017 11:26

From @chrisbenseler on March 13, 2017 10:51

Ionic version: (check one with "x") [ ] 1.x [X] 2.x

I'm submitting a ... (check one with "x") [X] bug report [ ] feature request [ ] support request

Current behavior: ionic build android outputs:

ionic run android --device --prod

expressoapp@ ionic:build /home/christian/dev/projects/expresso-app-front ionic-app-scripts build "--device" "--prod"

[07:50:57] ionic-app-scripts 1.1.4 [07:50:57] build prod started ... [07:50:57] clean started ... [07:50:57] clean finished in 1 ms [07:50:57] copy started ... [07:50:57] ngc started ... [07:51:00] build prod failed: Error encountered resolving symbol values statically. Calling function 'NoOpAnimationDriver', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AnimationDriver.NOOP in /home/christian/dev/projects/expresso-app-front/node_modules/@angular/platform-browser/src/dom/animation_driver.d.ts, resolving symbol BrowserTestingModule in /home/christian/dev/projects/expresso-app-front/node_modules/@angular/platform-browser/testing/browser.d.ts, resolving symbol BrowserTestingModule in /home/christian/dev/projects/expresso-app-front/node_modules/@angular/platform-browser/testing/browser.d.ts

My package.json has

{ "dependencies": { "@angular/common": "2.4.8", "@angular/compiler": "2.4.8", "@angular/compiler-cli": "2.4.8", "@angular/core": "2.4.8", "@angular/forms": "2.4.8", "@angular/http": "2.4.8", "@angular/platform-browser": "2.4.8", "@angular/platform-browser-dynamic": "2.4.8", "@angular/platform-server": "2.4.8", "ionic-angular": "2.2.0", "ionic-native": "2.4.1", "ionicons": "3.0.0", "ng2-translate": "5.0.0", "rxjs": "5.0.1", "sw-toolbox": "3.4.0", "zone.js": "0.7.2" }, "devDependencies": { "@ionic/app-scripts": "1.1.4", "@types/jasmine": "2.5.38", "@types/node": "6.0.42", "angular-cli": "1.0.0-beta.26", "chai": "^3.5.0", "chai-as-promised": "^6.0.0", "codelyzer": "^2.0.0", "compodoc": "0.0.37", "core-js": "^2.4.1", "jasmine-core": "2.5.2", "jasmine-spec-reporter": "3.2.0", "karma": "1.4.0", "karma-chrome-launcher": "2.0.0", "karma-cli": "1.0.1", "karma-jasmine": "1.1.0", "karma-mocha-reporter": "2.2.2", "karma-remap-istanbul": "0.4.0", "mocha": "^3.0.2", "ts-node": "2.0.0", "tslint": "4.4.1", "tslint-eslint-rules": "3.4.0", "typescript": "2.0.9", "wdio-mocha-framework": "^0.5.4", "wdio-phantomjs-service": "^0.2.2", "wdio-spec-reporter": "0.0.5", "webdriverio": "^4.2.16", "yargs": "^6.0.0" }, "cordovaPlugins": [ "cordova-plugin-device", "cordova-plugin-console", "cordova-plugin-whitelist", "cordova-plugin-splashscreen", "cordova-plugin-statusbar", "ionic-plugin-keyboard", "cordova-open", "cordova-plugin-google-analytics", "cordova-plugin-camera", "cordova-plugin-crop", "cordova-plugin-file", "cordova-plugin-inappbrowser", "cordova-plugin-app-version", "cordova-plugin-datepicker", "com-sarriaroman-photoviewer", "onesignal-cordova-plugin" ], "cordovaPlatforms": [] }

My ionic info Your system information:

Cordova CLI: 6.3.1 Ionic Framework Version: 2.2.0 Ionic CLI Version: 2.2.0 Ionic App Lib Version: 2.2.0 Ionic App Scripts Version: 1.1.4 ios-deploy version: Not installed ios-sim version: Not installed OS: Linux 4.4 Node Version: v7.6.0 Xcode version: Not installed

Copied from original issue: driftyco/ionic#10754

Copied from original issue: driftyco/ionic-cli#1981

jthoms1 commented 7 years ago

From @chrisbenseler on March 13, 2017 11:37

The problem is the flag --prod Without it the build/run is ok(but then the app takes too long to load).

chrisbenseler commented 7 years ago

Seems that the problem is the BrowserTestingModule. I added my spec files to the 'exclude' array in tsconfig.json "exclude": [ "node_modules", "*/spec*", "test", "src/test.ts" ]

ionic build android --prod is ok

rajeevriitm commented 7 years ago

@chrisbenseler Looks like the problem is coming from tests being included in compilation . But simply adding it to exclude is not working for me. It seems like ngc ignores it.

rapropos commented 7 years ago

@rajeevriitm ngc does not ignore tsconfig.json. You have to be very vigilant, though. A single test-related file that is not excluded will break the build.

shawnlan commented 7 years ago

I don't have test files, but still see the same issue. ionic start doesn't generate any test file, right?

rapropos commented 7 years ago

@shawnlan please double-check that you really have the same issue. Specifically, make sure that your error messages reference "BrowserTestingModule" as OPs do.

shawnlan commented 7 years ago

@rapropos I have this line build prod failed: Error encountered resolving symbol values statically. for sure. Before upgraded to Ionic 2.2.0 and app-scripts 1.1.4, building with --prod is fine.

rapropos commented 7 years ago

@shawnlan That is not necessarily the same issue. Please open a topic on the support forums. Your situation does not appear to be a framework bug, but rather a problem in your app.

rajeevriitm commented 7 years ago

@rapropos You were right. I did miss some some specs. Once that was included things are fine. This is how my tsconfig.josn looks.

  "exclude": [
    "node_modules","src/test.ts","src/**/*.spec.ts"
  ],

Thanks a lot man.

shawnlan commented 7 years ago

@rapropos I see. Changing an arrow function into an exported function in my app.module.ts solves my issue. Looks like ngc is strict about some things. What are they? Where can I find the documentations?

danbucholtz commented 7 years ago

@shawnlan,

Please review the angular documentation on ngc for any questions related to ngc. Things must be statically analyzable to be used by ngc.

Thanks, Dan