Skip to content

Cannot start my app after upgrading to 2.2 #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
NickIliev opened this issue Aug 12, 2016 · 20 comments
Closed

Cannot start my app after upgrading to 2.2 #397

NickIliev opened this issue Aug 12, 2016 · 20 comments

Comments

@NickIliev
Copy link

From @tomylee001001 on August 12, 2016 15:7

Hi ,
i upgraded the tns-core-modules to 2.2 and nativescript-angular 0.3 but after upgrading my apps login screen opens but when i click the login button i get the following error.

com.tns.NativeScriptException:
Calling js method onClick failed

EXCEPTION: Error in pages/login/login.html:6:49
ORIGINAL EXCEPTION: Error: not implemented
ORIGINAL STACKTRACE:
Error: not implemented
at NativeScriptDomAdapter.Parse5DomAdapter.getCookie (/data/data/org.nativescript.platformtest/files/app/tns_modules/@angular/platform-server/src/parse5_adapter.js:619:68)
at CookieXSRFStrategy.configureRequest (/data/data/org.nativescript.platformtest/files/app/tns_modules/@angular/http/src/backends/xhr_backend.js:150:82)
at XHRBackend.createConnection (/data/data/org.nativescript.platformtest/files/app/tns_modules/@angular/http/src/backends/xhr_backend.js:165:28)
at httpRequest (/data/data/org.nativescript.platformtest/files/app/tns_modules/@angular/http/src/http.js:22:20)
at Http.post (/data/data/org.nativescript.platformtest/files/app/tns_modules/@angular/http/src/http.js:78:16)
at UserService.login (/data/data/org.nativescript.platformtest/files/app/pages/shared/user/user_service.js

My login html

<StackLayout #container>

<TextField hint="E-Posta" keyboardType="email" [(ngModel)]="user.email"
autocorrect="false" autocapitalizationType="none">
<TextField hint="Şifre" secure="true" [(ngModel)]="user.password">

  <Button text="Giriş" class="submit-button" (tap)="submit()"></Button>

</StackLayout>

and my codes for submit

submit()
{
  if (!this.user.isValidEmail()) {
    alert("Enter a valid email address.");
    return;
  }
  this._userService.login(this.user)
.subscribe(
  () =>
  {
    console.log(Config.apiUrl);
    console.log("|"+Config.user_.id+"|");
  //alert("Giriş işlemi başarılı");
  this._router.navigate(["/boardlist"]);
  }

  ,
  (error) => alert("Giriş işlemi başarısız."+error)
);
}

i had no problem before the upgrade.

Copied from original issue: NativeScript/NativeScript#2575

@jolee11
Copy link

jolee11 commented Aug 13, 2016

In main.ts, I add NS_HTTP_PROVIDERS.

import {NS_HTTP_PROVIDERS} from 'nativescript-angular/http';
...
nativeScriptBootstrap(AppComponent, [NS_HTTP_PROVIDERS, APP_ROUTER_PROVIDERS]);

@kozakvoj
Copy link

After adding NS_HTTP_PROVIDERS a get following error:

node_modules/nativescript-angular/http/ns-http.d.ts(8,22): error TS2415: Class 'NSHttp' incorrectly extends base class 'Http'.
  Types of property 'get' are incompatible.
    Type '(url: string, options?: RequestOptionsArgs) => Observable<any>' is not assignable to type '(url: string, options?: RequestOptionsArgs) => Observable<Response>'.
      Type 'Observable<any>' is not assignable to type 'Observable<Response>'.
        Property 'source' is protected but type 'Observable<T>' is not a class derived from 'Observable<T>'.

@areiterer
Copy link

areiterer commented Aug 17, 2016

@kozakvoj I can confirm this. I added NS_HTTP_PROVIDERS in main.ts which resulted in that error message

@NathanWalker
Copy link
Contributor

In your package.json file, please use this for now:

"nativescript-angular": "next"

Until a new version is released.

@jolee11
Copy link

jolee11 commented Aug 18, 2016

Edit tsconfig.json
Change the setting:

    "noEmitOnError": false

@TruckerG
Copy link

After applying the fixes proposed here I´m getting this error:

`java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:
Error calling module function

TypeError: global.moduleMerge is not a function
File: ", line: 1, column: 265

StackTrace:
Frame: function:'', file:'/data/data/org.nativescript.groceries/files/app/tns_modules/utils/utils.js', line: 3, column: 8
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.groceries/files/app/tns_modules/file-system/file-system-access.js', line: 2, column: 13
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.groceries/files/app/tns_modules/file-system/file-system.js', line: 1, column: 86
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.groceries/files/app/tns_modules/nativescript-angular/file-system/ns-file-system.js', line: 2, column: 21
Frame: function:'require', file`

The stacktrace continues - I´m not getting the complete trace from the clipboard for some reason - and includes ns-http.js and http.js.
Any ideas?

@tomylee001001
Copy link

@NathanWalker i tried the "nativescript-angular": "next" but i still get the same error.

@kozakvoj
Copy link

@NathanWalker It works for me. Thanks.
@tomylee001001 Maybe try to recompile your npm dependecies?

@tomylee001001
Copy link

i already do that i even try the re-install "nativescript-angular" as next but i am still getting the error at the top. because of that i had to downgrade both my "nativescript-angular" and "tns-core-modules" for my app to work again. but i do need to upgrade.

@kozakvoj
Copy link

@tomylee001001 I've got the experience that sometimes the recompilation gets stuck for some reason. When it does the safest way out is to delete platforms, node_modules and run tns run adroid again for a full recompilation. My current nativescript-angular version is 0.3.1-2016-08-08-788. The other dependecies include:

"dependencies": {
    "@angular/common": "2.0.0-rc.4",
    "@angular/compiler": "2.0.0-rc.4",
    "@angular/core": "2.0.0-rc.4",
    "@angular/http": "2.0.0-rc.4",
    "@angular/platform-browser": "2.0.0-rc.4",
    "@angular/platform-browser-dynamic": "2.0.0-rc.4",
    "@angular/platform-server": "2.0.0-rc.4",
    "@angular/router": "3.0.0-beta.2",
    "@angular/router-deprecated": "2.0.0-rc.2",
    "nativescript-angular": "next",
    "reflect-metadata": "^0.1.5",
    "tns-core-modules": "2.2.0"
  }

main.ts looks like:

import {nativeScriptBootstrap} from "nativescript-angular/application";
import {NS_HTTP_PROVIDERS} from 'nativescript-angular/http';
import {AppComponent} from "./app.component";
import {APP_ROUTER_PROVIDERS} from "./app.routes";

nativeScriptBootstrap(AppComponent, [NS_HTTP_PROVIDERS, APP_ROUTER_PROVIDERS]);

I hope this helps. It works for me this way.

@kozakvoj
Copy link

My previous comment wasn't really correct. I've just tried to recompile all and ended with the error again. But I've found a bizarre workaround.

  1. Compile with "nativescript-angular": "^0.3.0"
  2. Delete plaforms
  3. Compile with "nativescript-angular": "next"

@tomylee001001
Copy link

i am still getting the error and after trying some more my app became completely goes the wrong way and it dont even starts properly without giving me any error. at that poin i had to return my back up to start trying again.

my current package.json

"dependencies": {
"@angular/common": "2.0.0-rc.3",
"@angular/compiler": "2.0.0-rc.3",
"@angular/core": "2.0.0-rc.3",
"@angular/http": "2.0.0-rc.3",
"@angular/platform-browser": "2.0.0-rc.3",
"@angular/platform-browser-dynamic": "2.0.0-rc.3",
"@angular/platform-server": "2.0.0-rc.3",
"@angular/router": "3.0.0-alpha.7",
"@angular/router-deprecated": "2.0.0-rc.2",
"email-validator": "^1.0.4",
"nativescript-angular": "^0.2.0",
"nativescript-imagepicker": "0.0.6",
"nativescript-permissions": "^1.1.2",
"nativescript-pulltorefresh": "^1.1.7",
"nativescript-splashscreen": "^2.1.0",
"nativescript-videoplayer": "^1.0.0",
"tns-core-modules": "^2.1.0"
},

and my current main.ts

import "reflect-metadata";
import {HTTP_PROVIDERS} from "@angular/http";
import {nativeScriptBootstrap} from "nativescript-angular/application";
import {AppComponent} from "./app.component";
import {APP_ROUTER_PROVIDERS} from "./app.routes";

nativeScriptBootstrap(AppComponent, [HTTP_PROVIDERS, APP_ROUTER_PROVIDERS]);

@tomylee001001
Copy link

if i change import {HTTP_PROVIDERS} from "@angular/http"; to import {NS_HTTP_PROVIDERS} from 'nativescript-angular/http'; in my main.ts my app coudnt open my login page or splash screen just give me this error;

java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:
Error calling module function

TypeError: global.moduleMerge is not a function
File: ", line: 1, column: 265

StackTrace:
Frame: function:'', file:'/data/data/org.nativescript.platformtest/files/app/tns_modules/utils/utils.js', line: 3, column: 8
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.platformtest/files/app/tns_modules/file-system/file-system-access.js', line: 2, column: 13
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.platformtest/files/app/tns_modules/file-system/file-system.js', line: 1, column: 86
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.platformtest/files/app/tns_modules/nativescript-angular/file-system/ns-file-system.js', line: 2, column: 21
Frame: function:'re

@TruckerG
Copy link

@tommylee001001 I have the same issue (as you can see above in the posts). When I downgrade to tns 2.1.0 things work just fine.

@tomylee001001
Copy link

@TruckerG i know that after i downgrade my app continue working but i need to upgrade because this upgrade solve couple of my problems.

@TruckerG
Copy link

@tomylee001001: yeah me too!

@vakrilov
Copy link
Contributor

We just pushed v0.3.1 with the fix for the Class 'NSHttp' incorrectly extends base class 'Http' error (related to #393). You can try using this version.

Note: To be on the safe side you can try deleting platforms and node_modules after updating the package.json just to be absolutely sure.

@tomylee001001
Copy link

@vakrilov i also try that version as well as tried tns plugin add nativescript-angular@next to get the highest version but my problem isnt Class 'NSHttp' incorrectly extends base class 'Http' error . Currently as in the example of groceries angular i am using "@angular/http" both for "HTTP_PROVIDERS" in my main.ts and for http.post in my service to get data from my webservice.
My problem is this if i update the "tns-core-modules" and "nativescript-angular" to the "next" my splash screen comes and i reach my login page but after clikking the login button and trying to use http.post to try to login i get the following error

com.tns.NativeScriptException:
Calling js method onClick failed

EXCEPTION: Error in pages/login/login.html:6:49
ORIGINAL EXCEPTION: Error: not implemented
ORIGINAL STACKTRACE:
Error: not implemented
at NativeScriptDomAdapter.Parse5DomAdapter.getCookie (/data/data/org.nativescript.platformtest/files/app/tns_modules/@angular/platform-server/src/parse5_adapter.js:619:68)
at CookieXSRFStrategy.configureRequest (/data/data/org.nativescript.platformtest/files/app/tns_modules/@angular/http/src/backends/xhr_backend.js:150:82)
at XHRBackend.createConnection (/data/data/org.nativescript.platformtest/files/app/tns_modules/@angular/http/src/backends/xhr_backend.js:165:28)
at httpRequest (/data/data/org.nativescript.platformtest/files/app/tns_modules/@angular/http/src/http.js:22:20)
at Http.post (/data/data/org.nativescript.platformtest/files/app/tns_modules/@angular/http/src/http.js:78:16)
at UserService.login (/data/data/org.nativescript.platformtest/files/app/pages/shared/user/user_service.js

but if i change "@angular/http" to "nativescript-angular/http" both my main.ts and my service files not even my splash screen or login page open and i get the following error as soon as i open my app

java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:
Error calling module function

TypeError: global.moduleMerge is not a function
File: ", line: 1, column: 265

StackTrace:
Frame: function:'', file:'/data/data/org.nativescript.platformtest/files/app/tns_modules/utils/utils.js', line: 3, column: 8
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.platformtest/files/app/tns_modules/file-system/file-system-access.js', line: 2, column: 13
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.platformtest/files/app/tns_modules/file-system/file-system.js', line: 1, column: 86
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.platformtest/files/app/tns_modules/nativescript-angular/file-system/ns-file-system.js', line: 2, column: 21
Frame: function:'re

i need to upgrade my app because new version solve couple of my importanted problems but i cant upgrade because of these error.is there any workaround for these while waiting to the next stable version.
thanks.

@tomylee001001
Copy link

@TruckerG placing the import {nativeScriptBootstrap} from "nativescript-angular/application"; to the first line in my main.ts solve this problem for me.

@TruckerG
Copy link

@tomylee001001: yes it solves the problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants