ionic-cli: ionic cordova build android --release --prod,this command to build app have a lots bug

From @zengyufang on November 9, 2017 5:59

Ionic version: (check one with “x”) (For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1) [ ] 2.x [ ] 3.x

I’m submitting a … (check one with “x”) [ ] bug report [ ] feature request

Please do not submit support requests or “How to” questions here. Instead, please use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:

Expected behavior:

Steps to reproduce:

Related code:

insert short code snippets here

image

Other information:

I can’t get the device information with the app I packaged with the release command,but debugger command is geted the device information,I don’t know Why is that???and other bug of slides on android app used release command

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

insert the output from ionic info here

image

Copied from original issue: ionic-team/ionic#13372

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 2
  • Comments: 24 (11 by maintainers)

Most upvoted comments

remove import ‘rxjs/Rx’; and add specific import

my solution was to remove the import and add the specific import from: import { BehaviorSubject } from 'rxjs/Rx';

to:

import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import 'rxjs/add/operator/first';

did you try the solution above?

I receive the error when building with --prod flag (ionic).

Error: ./node_modules/rxjs/observable/BoundNodeCallbackObservable.js
Module build failed: TypeError: Cannot read property 'type' of undefined
    at Object.getEffectiveTypeAnnotationNode (D:\tmp\ionic2\ezpart-mobile-svn\no
de_modules\typescript\lib\typescript.js:9341:17)
    at assignContextualParameterTypes (D:\tmp\ionic2\ezpart-mobile-svn\node_modu
les\typescript\lib\typescript.js:41652:25)
    at checkFunctionExpressionOrObjectLiteralMethod (D:\tmp\ionic2\ezpart-mobile
-svn\node_modules\typescript\lib\typescript.js:41948:29)
    at checkExpressionWorker (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\types
cript\lib\typescript.js:42959:28)
    at checkExpression (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typescript\
lib\typescript.js:42898:42)
    at checkExpressionCached (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\types
cript\lib\typescript.js:42779:38)
    at checkReturnStatement (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typesc
ript\lib\typescript.js:45418:54)
    at checkSourceElement (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typescri
pt\lib\typescript.js:46763:28)
    at Object.forEach (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typescript\l
ib\typescript.js:1506:30)
    at checkBlock (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typescript\lib\t
ypescript.js:44563:16)
 @ ./node_modules/rxjs/observable/bindNodeCallback.js 2:36-76
 @ ./node_modules/rxjs/add/observable/bindNodeCallback.js
 @ ./node_modules/rxjs/Rx.js
 @ ./src/providers/loginProvider.ts
 @ ./src/app/app.module.ngfactory.js
 @ ./src/app/main.ts,./node_modules/rxjs/observable/BoundCallbackObservable.js
Module build failed: TypeError: Cannot read property 'type' of undefined
    at Object.getEffectiveTypeAnnotationNode (D:\tmp\ionic2\ezpart-mobile-svn\no
de_modules\typescript\lib\typescript.js:9341:17)
    at assignContextualParameterTypes (D:\tmp\ionic2\ezpart-mobile-svn\node_modu
les\typescript\lib\typescript.js:41652:25)
    at checkFunctionExpressionOrObjectLiteralMethod (D:\tmp\ionic2\ezpart-mobile
-svn\node_modules\typescript\lib\typescript.js:41948:29)
    at checkExpressionWorker (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\types
cript\lib\typescript.js:42959:28)
    at checkExpression (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typescript\
lib\typescript.js:42898:42)
    at checkExpressionCached (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\types
cript\lib\typescript.js:42779:38)
    at checkReturnStatement (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typesc
ript\lib\typescript.js:45418:54)
    at checkSourceElement (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typescri
pt\lib\typescript.js:46763:28)
    at Object.forEach (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typescript\l
ib\typescript.js:1506:30)
    at checkBlock (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typescript\lib\t
ypescript.js:44563:16)
 @ ./node_modules/rxjs/observable/bindCallback.js 2:32-68
 @ ./node_modules/rxjs/add/observable/bindCallback.js
 @ ./node_modules/rxjs/Rx.js
 @ ./src/providers/loginProvider.ts
 @ ./src/app/app.module.ngfactory.js
 @ ./src/app/main.ts
    at BuildError.Error (native)
    at new BuildError (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\@ionic\app-s
cripts\dist\util\errors.js:16:28)
    at callback (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\@ionic\app-scripts
\dist\webpack.js:121:28)
    at emitRecords.err (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\webpack\lib
\Compiler.js:269:13)
    at Compiler.emitRecords (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\webpac
k\lib\Compiler.js:375:38)
    at emitAssets.err (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\webpack\lib\
Compiler.js:262:10)
    at applyPluginsAsyncSeries1.err (D:\tmp\ionic2\ezpart-mobile-svn\node_module
s\webpack\lib\Compiler.js:368:12)
    at next (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\tapable\lib\Tapable.js
:218:11)
    at Compiler.compiler.plugin (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\we
bpack\lib\performance\SizeLimitsPlugin.js:99:4)
    at Compiler.applyPluginsAsyncSeries1 (D:\tmp\ionic2\ezpart-mobile-svn\node_m
odules\tapable\lib\Tapable.js:222:13)
    @ionic/cli-utils  : 1.18.0
    ionic (Ionic CLI) : 3.18.0

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.0
    Cordova Platforms  : android 6.2.3
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 25.2.5
    Node              : v6.9.0
    npm               : 3.10.8
    OS                : Windows 7

Environment Variables:

    ANDROID_HOME : C:\Users\anton\AppData\Local\Android\sdk

Misc:

    backend : pro


On my side, I had to modify the import of Rxjs (commented line with import ‘rxjs/Rx’;, and added specific import resolved my issue) Avoid import 'rxjs/Rx

//import 'rxjs/Rx'; // adds ALL RxJS statics & operators to Observable

// Statics
import 'rxjs/add/observable/throw';

// Operators
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/toPromise';
import 'rxjs/add/observable/of';
import 'rxjs/add/observable/forkJoin';
import 'rxjs/add/operator/timeout;

See –build-optimizer errors “Cannot read property ‘type’ of undefined”

and it avoids loading all Rxjs

it is not possible to use typescript 2.6.1 with angular5.0. Or did I miss something?

WARN @angular/compiler-cli@5.0.0 requires a peer of typescript@>=2.4.2 <2.5

upgrade typescript to 2.6.1 fix the bug for me the bug is about rxjs with typescript , but the release log suggest us to use typescript@2.4.2

From @Sampath-Lokuge on November 9, 2017 7:13

Why can’t you test this in debug mode first on your device?

ionic cordova run android --prod --device

From @zengyufang on November 9, 2017 7:0

I’m sorry ,I didn’t express myself clearly before.I used “ionic doctor check” to check errors.but before I’m used “ionic cordova build android --release --prod” build app can’t get the device info, used"ionic cordova build android --release" build app can get the device info

From @Sampath-Lokuge on November 9, 2017 6:48

If you use ionic doctor check then it’ll show any errors in your app. Run it and see that. This CLI is not for releasing the app. Just for checking errors and etc.

From @Sampath-Lokuge on November 9, 2017 6:29

You can run ionic doctor check and see the latest updates which you need to do and errors on your project.