NativeScript / nativescript-background-http

Background Upload plugin for the NativeScript framework
Apache License 2.0
101 stars 50 forks source link

Getting error on android #142

Closed anaszgh closed 6 years ago

anaszgh commented 6 years ago

TNS Version 3.4.1 Platform Android Template Angular Error

JS: ERROR Error: Uncaught (in promise): TypeError: Cannot set property 'NAMESPACE' of undefined
JS: TypeError: Cannot set property 'NAMESPACE' of undefined
JS:     at ensureUploadServiceNamespace (file:///data/data/com.eventrest.mobile/files/app/tns_modules/nativescript-background-http/background-http.js:97:57)
JS:     at Object.session (file:///data/data/com.eventrest.mobile/files/app/tns_modules/nativescript-background-http/background-http.js:103:5)
JS:     at new ProfilePicPage (file:///data/data/com.eventrest.mobile/files/app/pages/profilePic/profilePic.page.js:25:37)
JS:     at createClass (file:///data/data/com.eventrest.mobile/files/app/tns_modules/@angular/core/bundles/core.umd.js:12481:20)
JS:     at createDirectiveInstance (file:///data/data/com.eventrest.mobile/files/app/tns_modules/@angular/core/bundles/core.umd.js:12322:37)
JS:     at createViewNodes (file:///data/data/com.eventrest.mobile/files/app/tns_modules/@angular/core/bundles/core.umd.js:13780:53)
JS:     at createRootView (file:///data/data/com.eventrest.mobile/files/app/tns_modules/@angular/core/bundles/core.umd.js:13669:5)
JS:     at callWithDebugContext (file:///data/data/com.eventrest.mobile/files/app/tns_modules/@angular/core/bundles/core.umd.js:15094:42)
JS:     at Object.debugCreateRootView [as createRootView] (file:///data/data/com.eventrest.mobile/files/app/tns_modules/@angular/core/bundles/core.umd.js:14377:12)
JS:     at ComponentFactory_.create (file:///data/data/com.eventrest.mobile/files/app/tns_modules/@angular/core/bundles/core.umd.js:11274:46)
JS:     at ComponentFactoryBoundToModule.create (file:///data/data/com.eventrest.mobile/files/app/tns_modules/@angular/core/bundles/core.umd.js:4061:29)
JS:     at ViewContainerRef_.createComponent (file:///data/data/com.eventrest.mobile/files/app/tns_modules/@angular/core/bundles/core.umd.js:11471:62)
JS:     at DetachedLoader.loadWithFactory (file:///data/data/com.eventrest.mobile/files/app/tns_modules/nativescript-angular/common/detached-loader.js:41:34)
JS:     at PageRouterOutlet.activateOnGoForward (file:///data/data/com.eventrest.mobile/files/app/tns_modules/nativescript-angular/router/page-router-outlet.js:258:49)
JS:     at PageRouterOutlet.activateWith (file:///data/data/com.eventrest.mobile/files/app/tns_modules/nativescript-angular/router/page-router-outlet.js:234:14)
bniehuser commented 6 years ago

as with the other issue of the same name, i found this to be easily resolved with a tns update or presumably anything else that reinstalls the android platform.

radeva commented 6 years ago

Hi @anaszgh,

Is this still an issue?

anaszgh commented 6 years ago

@radeva Sorry, but i can't tell, because i stopped using this plugin.

thiagohagy commented 5 years ago

You just need to run "tns update" , that solved for me

westlakem commented 5 years ago

any idea what to do if it doesn't?

  private async putImageToS3(signedUrl, fileLocation) {
    const mimeType = mime.lookup(fileLocation);
    const session = bghttp.session('image-upload');
    const request: bghttp.Request = {
      url: signedUrl,
      method: 'PUT',
      headers: {
        'Content-Type': mimeType,
        'Authorization': await this.cognitoService.getAccessToken()
      },
      description: 'Upload Image'
    };
    const task = session.uploadFile(fileLocation, request);
    task.on('progress', progressHandler);
    task.on('error', errorHandler);
    task.on('responded', respondedHandler);
    task.on('complete', completeHandler);
    task.on('cancelled', cancelledHandler); // Android only
  }

ERROR:

JS: ERROR Error: Uncaught (in promise): TypeError: Cannot set property 'NAMESPACE' of undefined
JS: TypeError: Cannot set property 'NAMESPACE' of undefined
JS:     at ensureUploadServiceNamespace (file:///data/data/org.nativescript.MyProject/files/app/vendor.js:83763:57)
JS:     at Function.push.../node_modules/nativescript-background-http/background-http.js.Task.create (file:///data/data/org.nativescript.MyProject/files/app/vendor.js:83815:9)
JS:     at Session.push.../node_modules/nativescript-background-http/background-http.js.Session.uploadFile (file:///data/data/org.nativescript.MyProject/files/app/vendor.js:83795:21)