Error (IONIC CORDOVA RUN ANDROID --PROD --RELEASE


#1

image


Error on Android --prod. Error: Illegal state: symbol without members expected
#2

with command: ionic cordova run android works but with command: ionic cordova run android --prod --release not work


#3

Run npm start ionic:build --prod --verbose please.

Also post your ionic info output please.


#4


#5

Please post these as text, not as screenshots with tiny text.


#6

$ ionic info

cli packages:

@ionic/cli-plugin-cordova       : 1.5.0 (D:\Desenvolvimento\xampp\htdocs\reciklado\node_modules\@ionic\cli-plugin-cordova)
@ionic/cli-plugin-ionic-angular : 1.4.0 (D:\Desenvolvimento\xampp\htdocs\reciklado\node_modules\@ionic\cli-plugin-ionic-angular)
@ionic/cli-utils                : 1.6.0 (D:\Desenvolvimento\xampp\htdocs\reciklado\node_modules\@ionic\cli-utils)
ionic (Ionic CLI)               : 3.6.0 (D:\Desenvolvimento\xampp\htdocs\reciklado\node_modules\ionic)

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 2.1.3
Cordova Platforms  : android 6.2.3 browser 4.1.0 ios 4.4.0 windows 5.0.0
Ionic Framework    : ionic-angular 3.6.0

System:

Node : v6.11.1
OS   : Windows 10
npm  : 5.3.0

#7
$ npm start ionic:build --prod --verbose
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli   'C:\\Users\\Fred\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli   'start',
npm verb cli   'ionic:build',
npm verb cli   '--prod',
npm verb cli   '--verbose' ]
npm info using npm@5.3.0
npm info using node@v6.11.1
npm verb stack Error: missing script: start
npm verb stack     at run (C:\Users\Fred\AppData\Roaming\npm\node_modules\npm\lib\run-script.js:151:19)
npm verb stack     at C:\Users\Fred\AppData\Roaming\npm\node_modules\npm\lib\run-script.js:61:5
npm verb stack     at C:\Users\Fred\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:114:5
npm verb stack     at C:\Users\Fred\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:401:5
npm verb stack     at checkBinReferences_ (C:\Users\Fred\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:356:45)
npm verb stack     at final (C:\Users\Fred\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:399:3)
npm verb stack     at then (C:\Users\Fred\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:159:5)
npm verb stack     at C:\Users\Fred\AppData\Roaming\npm\node_modules\npm\node_modules\read-package-json\read-json.js:347:12
npm verb stack     at C:\Users\Fred\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16
npm verb stack     at tryToString (fs.js:456:3)
npm verb cwd D:\Desenvolvimento\xampp\htdocs\reciklado
npm verb Windows_NT 10.0.14393
npm verb argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Fred\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start" "ionic:build" "--prod" "--verbose"
npm verb node v6.11.1
npm verb npm  v5.3.0
npm ERR! missing script: start
npm verb exit [ 1, true ]

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Fred\AppData\Roaming\npm-cache\_logs\2017-08-01T10_30_09_388Z-debug.log

#8

Sorry, npm run ... instead of npm start ....


#9
$ npm run ionic:build --prod --verbose
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli   'C:\\Users\\Fred\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli   'run',
npm verb cli   'ionic:build',
npm verb cli   '--prod',
npm verb cli   '--verbose' ]
npm info using npm@5.3.0
npm info using node@v6.11.1
npm verb run-script [ 'preionic:build', 'ionic:build', 'postionic:build' ]
npm info lifecycle Reciklado@0.0.1~preionic:build: Reciklado@0.0.1
npm info lifecycle Reciklado@0.0.1~ionic:build: Reciklado@0.0.1

> Reciklado@0.0.1 ionic:build D:\Desenvolvimento\xampp\htdocs\reciklado
> ionic-app-scripts build

[08:01:38]  ionic-app-scripts 2.1.3
[08:01:38]  build prod started ...
[08:01:38]  clean started ...
[08:01:38]  clean finished in 26 ms
[08:01:38]  copy started ...
[08:01:38]  ngc started ...
[08:01:42]  ionic-app-script task: "build"
[08:01:42]  Error: Illegal state: symbol without members expected, but got
            {"filePath":"D:/Desenvolvimento/xampp/htdocs/reciklado/src/app/app.component.ts","name":"MyApp","members":["loader"]}.
Error: Illegal state: symbol without members expected, but got {"filePath":"D:/Desenvolvimento/xampp/htdocs/reciklado/src/app/app.component.ts","name":"MyApp","members":["loader"]}.
    at StaticSymbol.assertNoMembers (D:\Desenvolvimento\xampp\htdocs\reciklado\node_modules\@angular\compiler\bundles\compiler.umd.js:523:19)
    at AotSummaryResolver.resolveSummary (D:\Desenvolvimento\xampp\htdocs\reciklado\node_modules\@angular\compiler\bundles\compiler.umd.js:24557:22)
    at CompileMetadataResolver._loadSummary (D:\Desenvolvimento\xampp\htdocs\reciklado\node_modules\@angular\compiler\bundles\compiler.umd.js:14204:66)
    at CompileMetadataResolver._getInjectableMetadata (D:\Desenvolvimento\xampp\htdocs\reciklado\node_modules\@angular\compiler\bundles\compiler.umd.js:14737:49)
    at CompileMetadataResolver.getProviderMetadata (D:\Desenvolvimento\xampp\htdocs\reciklado\node_modules\@angular\compiler\bundles\compiler.umd.js:15031:40)
    at D:\Desenvolvimento\xampp\htdocs\reciklado\node_modules\@angular\compiler\bundles\compiler.umd.js:14960:49
    at Array.forEach (native)
    at CompileMetadataResolver._getProvidersMetadata (D:\Desenvolvimento\xampp\htdocs\reciklado\node_modules\@angular\compiler\bundles\compiler.umd.js:14921:19)
    at D:\Desenvolvimento\xampp\htdocs\reciklado\node_modules\@angular\compiler\bundles\compiler.umd.js:14496:63
    at Array.forEach (native)
npm verb lifecycle Reciklado@0.0.1~ionic:build: unsafe-perm in lifecycle true
npm verb lifecycle Reciklado@0.0.1~ionic:build: PATH: C:\Users\Fred\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin;D:\Desenvolvimento\xampp\htdocs\reciklado\node_modules\.bin;C:\Users\Fred\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Fred\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Intel\Shared Files\cpp\bin\Intel64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\HashiCorp\Vagrant\bin;D:\Desenvolvimento\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Program Files (x86)\Skype\Phone;C:\PostgreSQL\pg96\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\GnuWin32\bin;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\PuTTY;C:\Program Files (x86)\GnuWin32\bin;C:\Users\Fred\AppData\Local\Android\sdk\tools;C:\Users\Fred\AppData\Local\Android\sdk\tools\bin;C:\Program Files\nodejs;C:\Program Files\Java\jdk1.8.0_144\bin;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\Fred\AppData\Local\Microsoft\WindowsApps;C:\Users\Fred\AppData\Roaming\Composer\vendor\bin;C:\Users\Fred\AppData\Local\atom\bin;C:\Users\Fred\AppData\Roaming\npm;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
npm verb lifecycle Reciklado@0.0.1~ionic:build: CWD: D:\Desenvolvimento\xampp\htdocs\reciklado
npm info lifecycle Reciklado@0.0.1~ionic:build: Failed to exec ionic:build script
npm verb stack Error: Reciklado@0.0.1 ionic:build: `ionic-app-scripts build`
npm verb stack Exit status 1
npm verb stack     at EventEmitter.<anonymous> (C:\Users\Fred\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js:289:16)
npm verb stack     at emitTwo (events.js:106:13)
npm verb stack     at EventEmitter.emit (events.js:191:7)
npm verb stack     at ChildProcess.<anonymous> (C:\Users\Fred\AppData\Roaming\npm\node_modules\npm\lib\utils\spawn.js:40:14)
npm verb stack     at emitTwo (events.js:106:13)
npm verb stack     at ChildProcess.emit (events.js:191:7)
npm verb stack     at maybeClose (internal/child_process.js:891:16)
npm verb stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
npm verb pkgid Reciklado@0.0.1
npm verb cwd D:\Desenvolvimento\xampp\htdocs\reciklado
npm verb Windows_NT 10.0.14393
npm verb argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Fred\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "ionic:build" "--prod" "--verbose"
npm verb node v6.11.1
npm verb npm  v5.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Reciklado@0.0.1 ionic:build: `ionic-app-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Reciklado@0.0.1 ionic:build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Fred\AppData\Roaming\npm-cache\_logs\2017-08-01T12_01_42_389Z-debug.log

#10
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\Fred\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'ionic:build',
1 verbose cli   '--prod',
1 verbose cli   '--verbose' ]
2 info using npm@5.3.0
3 info using node@v6.11.1
4 verbose run-script [ 'preionic:build', 'ionic:build', 'postionic:build' ]
5 info lifecycle Reciklado@0.0.1~preionic:build: Reciklado@0.0.1
6 info lifecycle Reciklado@0.0.1~ionic:build: Reciklado@0.0.1
7 verbose lifecycle Reciklado@0.0.1~ionic:build: unsafe-perm in lifecycle true
8 verbose lifecycle Reciklado@0.0.1~ionic:build: PATH: C:\Users\Fred\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin;D:\Desenvolvimento\xampp\htdocs\reciklado\node_modules\.bin;C:\Users\Fred\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Fred\bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Intel\Shared Files\cpp\bin\Intel64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\HashiCorp\Vagrant\bin;D:\Desenvolvimento\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Program Files (x86)\Skype\Phone;C:\PostgreSQL\pg96\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\GnuWin32\bin;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\PuTTY;C:\Program Files (x86)\GnuWin32\bin;C:\Users\Fred\AppData\Local\Android\sdk\tools;C:\Users\Fred\AppData\Local\Android\sdk\tools\bin;C:\Program Files\nodejs;C:\Program Files\Java\jdk1.8.0_144\bin;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\Fred\AppData\Local\Microsoft\WindowsApps;C:\Users\Fred\AppData\Roaming\Composer\vendor\bin;C:\Users\Fred\AppData\Local\atom\bin;C:\Users\Fred\AppData\Roaming\npm;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
9 verbose lifecycle Reciklado@0.0.1~ionic:build: CWD: D:\Desenvolvimento\xampp\htdocs\reciklado
10 silly lifecycle Reciklado@0.0.1~ionic:build: Args: [ '/d /s /c', 'ionic-app-scripts build' ]
11 silly lifecycle Reciklado@0.0.1~ionic:build: Returned: code: 1  signal: null
12 info lifecycle Reciklado@0.0.1~ionic:build: Failed to exec ionic:build script
13 verbose stack Error: Reciklado@0.0.1 ionic:build: `ionic-app-scripts build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Users\Fred\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js:289:16)
13 verbose stack     at emitTwo (events.js:106:13)
13 verbose stack     at EventEmitter.emit (events.js:191:7)
13 verbose stack     at ChildProcess.<anonymous> (C:\Users\Fred\AppData\Roaming\npm\node_modules\npm\lib\utils\spawn.js:40:14)
13 verbose stack     at emitTwo (events.js:106:13)
13 verbose stack     at ChildProcess.emit (events.js:191:7)
13 verbose stack     at maybeClose (internal/child_process.js:891:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
14 verbose pkgid Reciklado@0.0.1
15 verbose cwd D:\Desenvolvimento\xampp\htdocs\reciklado
16 verbose Windows_NT 10.0.14393
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Fred\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "ionic:build" "--prod" "--verbose"
18 verbose node v6.11.1
19 verbose npm  v5.3.0
20 error code ELIFECYCLE
21 error errno 1
22 error Reciklado@0.0.1 ionic:build: `ionic-app-scripts build`
22 error Exit status 1
23 error Failed at the Reciklado@0.0.1 ionic:build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

#11

I changed your post to format your code or error message correctly. Please use the </> button above the post input field to format your code or error message or wrap it in ``` (“code fences”) manually. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.


#12

Show us that file please.


#13
import { Component, ViewChild 	} from '@angular/core';
import { Platform, MenuController, Nav } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { GoogleAnalytics } from '@ionic-native/google-analytics';
import { Geolocation } from '@ionic-native/geolocation';
import { TranslateService } from '@ngx-translate/core';
import { AuthProvider } from "../providers/auth/auth";
import { RedirectorProvider } from "../providers/redirector/redirector";
import { md5 } from 'crypto-md5';

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  @ViewChild(Nav) nav: Nav;

  rootPage: any = 'LoginPage';

  pages: Array<{title: string, icon: string, component: any}>;
  user:any;

  gravatarUrl:string = 'https://www.gravatar.com/avatar/nouser.jpg';

  constructor(
    public platform: Platform,
    public menu: MenuController,
    public splashScreen: SplashScreen,
    public statusBar: StatusBar,
    private ga: GoogleAnalytics,
  	private geolocation: Geolocation,
    private translate: TranslateService,
    public auth: AuthProvider,
    public redirector: RedirectorProvider

	) {


    this.initializeApp();

    // used for an example of ngFor and navigation
    this.pages = [
        { title: 'Início', icon: 'home', component: 'AccountPage' },
        { title: 'Indicar', icon: 'person-add', component: 'InviteFriendsPage' },
        { title: 'Conta', icon: 'cash', component: 'AccountPage' },
        { title: 'Perfil', icon: 'person', component: 'ProfilePage' },
        { title: 'Redes Sociais', icon: 'planet', component: 'SociaisNetworksPage' },
        { title: 'Termos de Uso', icon: 'ribbon', component: 'TermsPage' },
        { title: 'Privacidade', icon: 'flag', component: 'PrivacyPage' },
        { title: 'Contato', icon: 'paper-plane', component: 'ContactPage' },
        { title: 'Idioma', icon: 'globe', component: 'LanguagePage' },
        { title: 'Configurações', icon: 'settings',component: 'SettingsPage' },
        { title: 'Problema', icon: 'bug', component: 'BugPage' },
        { title: 'Sobre', icon: 'information-circle', component: 'AboutPage' },
        { title: 'Ajuda', icon: 'help-buoy', component: 'HelpPage' },
        { title: 'Sair', icon: 'log-out', component: 'LogoutPage' }
    ];

  }

    initializeApp() {

        this.auth.userSubject().subscribe(user =>{
            this.user = user;
            this.gravatar();
        });

        this.platform.ready().then(() => {
            // Okay, so the platform is ready and our plugins are available.
            // Here you can do any higher level native things you might need.
            this.statusBar.styleDefault();
            this.splashScreen.hide();
        });

        this.translate.addLangs(["br", "en", "es"]);
        this.translate.setDefaultLang('br');

        this.geolocation.getCurrentPosition().then((resp) => {
            console.log(resp);
        }).catch((error) => {
            console.log('Error getting location', error);
        });

        let watch = this.geolocation.watchPosition();
        watch.subscribe((data) => {
            console.log(data)
        });
    }

    gravatar(){

      if(this.user) {
          this.gravatarUrl = `https://www.gravatar.com/avatar/${md5(this.user.email, 'hex')}`;
      }

    }

    ngAfterViewInit(){
        this.redirector.config(this.nav);
    }

    openPage(page) {
        // close the menu when clicking a link from the menu
        this.menu.close();
        // navigate to the new page if it is not the current page
        this.nav.setRoot(page.component);
    }
}

#14

@Sujan12

run command:
ionic cordova run android --env=prod

show splash and after show white screen

but no continue


#15

So you solved your initial problem?
Is this a new problem?

That is not a valid command. The correct one would be:

ionic cordova run android --prod


#16
$ ionic cordova run android --prod
Running app-scripts build: --prod --address 0.0.0.0 --port 8100 --p 8100 --livereload-port 35729 --r 35729 --iscordovaserve --nobrowser

[05:35:44]  build prod started ...
[05:35:44]  clean started ...
[05:35:44]  clean finished in 1 ms
[05:35:44]  copy started ...
[05:35:44]  ngc started ...
[WARN] Error occurred during command execution from a CLI plugin (@ionic/cli-plugin-cordova).
Error: Illegal state: symbol without members expected, but got {"filePath":"D:/Desenvolvimento/xampp/htdocs/reciklado/src/app/app.component.ts","name":"MyApp","members":["loader"]}.

#17

Is running ionic cordova run android different from the broken command you just posted?

What happens on ionic serve?


#18

ionic cordova run android (work fine)

ionic serve (work fine)

my problem is with --prod


#19

update node modules to latest for all

now show another error

$ ionic cordova run android --prod --release
Running app-scripts build: --prod --address 0.0.0.0 --port 8100 --p 8100 --livereload-port 35729 --r 35729 --iscordovaserve --nobrowser

[06:18:05]  build prod started ...
[06:18:05]  clean started ...
[06:18:05]  clean finished in 22 ms
[06:18:05]  copy started ...
[06:18:05]  ngc started ...
[WARN] Error occurred during command execution from a CLI plugin (@ionic/cli-plugin-cordova).
Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 6:21 in the original .ts file), resolving symbol Auth in D:/Desenvolvimento/xampp/htdocs/reciklado/src/decorators/auth.decorator.ts, resolving symbol AccountPage in D:/Desenvolvimento/xampp/htdocs/reciklado/src/pages/account/account.ts, resolving symbol AccountPage in D:/Desenvolvimento/xampp/htdocs/reciklado/src/pages/account/account.ts

#20

account.ts

import { Component } from '@angular/core';
import {Platform, NavController, NavParams, IonicPage} from 'ionic-angular';
import { GoogleAnalytics } from '@ionic-native/google-analytics';
import { Auth } from '../../decorators/auth.decorator';
import { AuthProvider } from "../../providers/auth/auth";

@Auth()
@IonicPage(
    {
        name: 'AccountPage'
    }
)
@Component({
  selector: 'page-account',
  templateUrl: 'account.html'
})

export class AccountPage {

  constructor(public platform: Platform,
              public navCtrl: NavController,
              public navParams: NavParams,
              private ga: GoogleAnalytics,
              private auth: AuthProvider
              ) {


      this.platform.ready().then(() => {

          // Google Analytics
          this.ga.startTrackerWithId('UA-80919104-2')
              .then(() => {
                  this.ga.trackView('account');
                  // Tracker is ready
                  // You can now track pages or set additional information such as AppVersion or UserId
              })
              .catch(e => console.log('Error starting GoogleAnalytics', e));
      });
  }

}

auth.decorator.ts

import { appContainer } from "../app/app.container";
import { AuthProvider } from "../providers/auth/auth";
import { Nav } from "ionic-angular";
import { LoginPage } from "../pages/login/login";

export const Auth = () => {
  return (target: any) => {
    target.prototype.ionViewCanEnter = function() {
      let property =
          Object
            .keys(this)
            .find(value => this[value] instanceof Nav);

      if(typeof property === "undefined"){
        setTimeout(() => {
            throw new TypeError("Auth decorator needs NavController instance.");
        });
        return false;
      }
      let auth = appContainer().get(AuthProvider);
      return auth.check().then(isLogged => {
          if(!isLogged) {
            setTimeout(() => {
              let navCtrl = this[property];
              navCtrl.setRoot(LoginPage);
            });
            return false;
          }
          return true;
      })
    }
  }
};