can't build with Ionic2 - ionic-framework

I'm developing an Ionic2 application and now I want to make a build but I get an error.
ionic info returns this:
Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.1
Ionic CLI Version: 2.1.1
Ionic App Lib Version: 2.1.1
Ionic App Scripts Version: 0.0.36
OS: Distributor ID: Ubuntu Description: Ubuntu 16.04.1 LTS
Node Version: v4.2.6
my main.prod.ts looks like this:
import { platformBrowser } from '#angular/platform-browser';
import { enableProdMode } from '#angular/core';
import { AppModuleNgFactory } from './app.module.ngfactory';
enableProdMode();
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
Everytime I try to do ionic build android I get this:
bundle failed: Could not resolve './app.module.ngfactory' from /home/xxx/Desktop/myApp/.tmp/app/main.prod.ts
ionic-app-script task: "build"

Ionic2 uses the Ahead-Of-Time-Compilation of Angular2 (by using ngc). What ngc does, is creating a factory out of your normal app-module and renames this module by adding NgFactory to the modules' Name.
So for example if you have an app-module called MySuperAwesomeApp, ngc creates a file which exports a factory called MySuperAwesomeAppNgFactory. And when building your Android app, ionic will search for MySuperAwesomeAppNgFactory instead of MySuperAwesomeApp, thus throwing an error, when not finding it.
In your case I suppose that you renamed your app-module (located in ./app.module.ts) but didn't change the factory name in the main.prod.ts.
For further reading on AOT, please refer to the Angular2 AOT Doc.

Related

ionic 2 navControl push issue

i am using ionic 2 for my android application. For page routing i am using
this.nav.push(LoginPage);
When i push from one page to another it's showing previous page some sections in current page. Because of this my pages are not showing as expected.
Cordova CLI: 6.5.0
Ionic Framework Version: 3.6.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 2.0.2
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.10.0
Xcode version: Not installed
Please help. I cant find any errors in my console. I don't know why its happening. Please suggest need to follow any particular standard for routing.
Thanks
Add loginPage import to app.module.ts file.
import { NavController} from 'ionic-angular';
Add in constructor like constructor(private navCtrl: NavController)
And push the page on stack
this.navCtrl.push(LoginPage);

Ionic link does not work with Ionic v2

When I run ionic link command inside ionic project folder I got following error message
"You cannot run this command unless you are in an Ionic Project folder"
My system info.
Cordova CLI: 6.3.1
Gulp version: CLI version 1.2.1
Gulp local: Local version 3.9.1
Ionic Framework Version: 2.0.0-beta.11
Ionic CLI Version: 2.0.0-beta.36
Ionic App Lib Version: 2.0.0-beta.19
OS: Distributor ID: Ubuntu Description: Ubuntu 14.04.4 LTS
Node Version: v6.4.0
You can use following command to setup app linking with Ionic IO.
ionic io init
this will update ionic.config.json with app_id and generate .io-config.json file with app_id and api_key.
ionic io init
is no longer available in cli 3. Create a new app from apps.ionic.io dashboard and then run
ionic link
which will list down apps from your ionic.io account and let you choose an app to which you want to link your local app. You have to run 'ionic login' if you haven't done so already.

Modals not showing when I use soundcloud api with typings in my Ionic2 project

PROBLEM: no modals are showing and no DOM update is automatically triggered (I need to call changeDetectorRef.detectChanges() ), when I import and use SoundCloud API with typings in my Ionic2 project.
How I am importing SoundCloud API to my Ionic2 project:
In command prompt:
npm install soundcloud
typings install soundcloud --save
In my TS:
import * as SC from 'soundcloud';
or
import SC = require('soundcloud');
The soundcloud api itself works perfectly (audio streaming, tracks listing). But, no modal will show up in my ionic2 project while this code is inserted in any ts file of my project. Also, no DOM update is automatically triggered.
My ionic info:
Cordova CLI: 6.3.0
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Framework Version: 2.0.0-beta.10
Ionic CLI Version: 2.0.0-beta.32
Ionic App Lib Version: 2.0.0-beta.18
OS:
Node Version: v6.2.2
NOTE:
If I remove soundcloud code, modals will show up again. Also, DOM updates will get triggered again.
No errors/warnings are shown in console.
Any ideas?

ionic2 - Cannot resolve all parameters error

I'm having the following ts code.
#home.ts
import {Page, NavController} from 'ionic-framework/ionic';
#Page({
templateUrl: 'build/pages/home/home.html'
})
export class HomePage {
constructor(nav: NavController){
}
}
and I'm getting the following error.
Error: Cannot resolve all parameters for 'HomePage'(?). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'HomePage' is decorated with Injectable.
at NoAnnotationError.BaseException [as constructor]
I've had a look on the FAQ, ionic NavController example and the documentation. But I cannot spot an error on why its complaining. For me it seems like Im importing everything correctly.
What I could be doing wrong?
Below are my system info
Your system information:
Cordova CLI: 5.4.1
Gulp version: CLI version 3.9.0
Gulp local:
Ionic Version: 2.0.0-beta.1
Ionic CLI Version: 2.0.0-beta.17
Ionic App Lib Version: 2.0.0-beta.8
ios-deploy version: Not installed
ios-sim version: 5.0.2
OS: Mac OS X El Capitan
Node Version: v4.1.1
Xcode version: Xcode 7.0.1 Build version 7A1001
Try with:
constructor(#Inject(NavController) nav:NavController)

Missing ionic.project file

I just updated nodejs ionic and cordova. Create new ionic project as before:
ionic start myApp blank
In terminal, go to myApp directory, and input:
ionic state
I got message:
You cannot run any state commands on a project that is not an Ionic
project. Try adding an ionic.project file or running ionic start to
get an application to save or restore (CLI v1.7.10)
My system information:
Cordova CLI: 5.4.0
Ionic Version: 1.1.1
Ionic CLI Version: 1.7.10
Ionic App Lib Version: 0.6.5
ios-deploy version: 1.8.3
ios-sim version: 5.0.4
OS: Mac OS X El Capitan
Node Version: v5.1.0
Xcode version: Xcode 7.1.1 Build version 7B1005
Question: Where ionic.project file, I don't remember there was this file in project before. How to add ionic.project file?
How do I find this problem? Because I check out source from git, I try to use ionic state restore command to restore application for building. But I got same message, missing ioinc.project. So I create a new ionic project to find reason, but I'm still confused.
If use
ionic start
You will got
Invalid command (CLI v1.7.10)
Of course, there is not directory argument for this command. If you give directory as ./, this command only create and overwrite all project file.
screen shot
The new name of this file is ionic.config.json
I was facing the same issue.
just run the command
ionic serve
ionic.project file gets auto generated
EDIT
ionic.project is replace by ionic.config.json. So you should change in ionic.config.json
If you are happened to use ionic#beta, it won't install it until you downgrade it to ionic V1 then "ionic setup sass" or "ionic serve".
Most simple/easy solution to this problem to install a chrome extension named CORS. and everything will work perfectly.