Code Monkey home page Code Monkey logo

Comments (26)

RajkumarRepo avatar RajkumarRepo commented on June 1, 2024 3

I'm also face the same issue in android when update native script 6.0

from nativescript-loading-indicator.

nikoTM avatar nikoTM commented on June 1, 2024 1

@Sartori-RIA @edyrkaj it should be working without installing platform-declarations, try adding "skipLibCheck": true to your tsconfig.json -> compilerOptions. Although, the error mentioned in the initial comment sounds like a runtime error, so this is not a solution, just a workaround so you don't have to install platform declarations.

from nativescript-loading-indicator.

prajilshresthaiw avatar prajilshresthaiw commented on June 1, 2024 1

@beeman thank you for the clarification, will try to create a PR if I can find the issue first.

from nativescript-loading-indicator.

bradmartin avatar bradmartin commented on June 1, 2024

Best guess, is the actual instance of loader is not the same when it's being accessed in the second page (submodule).

from nativescript-loading-indicator.

nikoTM avatar nikoTM commented on June 1, 2024

@Sartori-RIA make sure you are not calling it earlier than OnInit

from nativescript-loading-indicator.

Sartori-RIA avatar Sartori-RIA commented on June 1, 2024

@nikoTM I'm trying to call inside AfterViewInit and make loader receive null after hide(). Inside submodule works fine but inside my app.component inside tabview throws error
obs: before I was using inside OnInit and to test i change to AfterViewInit

    ngAfterViewInit(): void {
      this.fetchPets();
    }

    private fetchPets(): void {
        let loader = new LoadingIndicator();
        const [t] = useT();
        loader.show({message: t('loading_fetching_pets')});
        this.pets$ = this.petService.all();
        this.pets$.subscribe(() => {
            loader.hide();
            loader = null;
        }, (error) => {
            loader.hide();
            loader = null;
            console.error(error)
        }
   }

from nativescript-loading-indicator.

Sartori-RIA avatar Sartori-RIA commented on June 1, 2024

maybe helps, my tabview is using lazy-loading to tabs, and this component is using inside zapetTab

const routes: Routes = [
{
        path: 'default',
        component: TabsComponent,
        children: [
            {
                path: 'guardian',
                outlet: 'guardianTab',
                component: NSEmptyOutletComponent,
                loadChildren: '~/app/guardian/guardian.module#GuardianModule',
            }, {
                path: 'zapet',
                outlet: 'zapetTab',
                component: NSEmptyOutletComponent,
                loadChildren: '~/app/zapet/zapet.module#ZapetModule',
            }, {
                path: 'review',
                outlet: 'reviewTab',
                component: NSEmptyOutletComponent,
                loadChildren: '~/app/review/review.module#ReviewModule',
            }
        ]
    }
];

from nativescript-loading-indicator.

amlibtest avatar amlibtest commented on June 1, 2024

I have a very similar problem (I'm sorry if this was the wrong place to write this, I don't know if it would be better to create another issue)

JS: **ERROR**  Error: Uncaught (in promise): TypeError: Cannot read property 'android' of undefined
JS: TypeError: Cannot read property 'android' of undefined
JS:     at LoadingIndicator.push.../node_modules/@nstudio/nativescript-loading-indicator/loading-indicator.js.LoadingIndicator._createPopOver file:///node_modules/@nstudio/nativescript-loading-indicator/loading-indicator.js:217:0
JS:     at LoadingIndicator.push.../node_modules/@nstudio/nativescript-loading-indicator/loading-indicator.js.LoadingIndicator.show file:///node_modules/@nstudio/nativescript-loading-indicator/loading-indicator.js:38:0

This error is pointing to this line

var view = frame_1.topmost().android.rootViewGroup || frame_1.topmost().currentPage.android;

My code was working with the previous version, but I added the changes:

import { LoadingIndicator, Mode, OptionsCommon } from '@nstudio/nativescript-loading-indicator';

export class Test{

        loadingIndicator: LoadingIndicator;
	public constructor(){
                  this.loadingIndicator = new LoadingIndicator();
                  ...
         }

    public showLoadingIndicator(msg, cancel=false){
        this.loadingIndicator.show({ 
            message : msg,
            mode: Mode.Indeterminate,
            android: {
                cancelable: cancel
            }
        });
    }

...
}

from nativescript-loading-indicator.

edyrkaj avatar edyrkaj commented on June 1, 2024

Hi,
try to install from node packages:
npm i tns-platform-declarations

After installing package, the main thing is to create a references.d.ts file in the root of your project with the following:

/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />

from nativescript-loading-indicator.

Sartori-RIA avatar Sartori-RIA commented on June 1, 2024

hi @edyrkaj with your solution, in iOS everything works very well, but in android don't

from nativescript-loading-indicator.

edyrkaj avatar edyrkaj commented on June 1, 2024

@Sartori-RIA did you tried to remove / add platform from beginning? You can post here what is the next error on your side ;)

from nativescript-loading-indicator.

Sartori-RIA avatar Sartori-RIA commented on June 1, 2024

@edyrkaj I try removing: node_modules, hooks and platforms
the error i get is just TypeError: Cannot read property 'android' of undefined with no stack trace :/

from nativescript-loading-indicator.

NathanWalker avatar NathanWalker commented on June 1, 2024

This appears to be related to androidx changes and can occur when the loadingindicator is called early during a boot cycle especially with angular integrations. The android setup needs to be revised and cleaned up to resolve this condition.

/cc @bradmartin @triniwiz

from nativescript-loading-indicator.

Sartori-RIA avatar Sartori-RIA commented on June 1, 2024

@nikoTM I'm already using skiLibCheck in my tsconfig.json


{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "skipLibCheck": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "noEmitHelpers": true,
        "noEmitOnError": true,
        "lib": [
            "es6",
            "dom",
            "esnext",
            "es2015.iterable"
        ],
        "baseUrl": ".",
        "paths": {
            "~/*": [
                "src/*"
            ]
        }
    },
    "exclude": [
        "node_modules",
        "platforms"
    ]
}

from nativescript-loading-indicator.

david-mart avatar david-mart commented on June 1, 2024

I had the same issue, loader was failing when loader was called very early in the app loading cycle. My workaround for now

let loader = new LoadingIndicator();

const loaderOptions = {
  ios: {
    userInteractionEnabled: false,
    dimBackground: true,
    backgroundColor: "#000000",
    color: "#FFF"
  }
};

export const showLoader = message => {
  try {
    loader.show(R.mergeDeepLeft(loaderOptions, { message }));
  } catch (error) {
    console.log(error);
  }
};

export const hideLoader = () => {
  try {
    loader.hide();
  } catch (error) {
    console.log(error);
  }
};

from nativescript-loading-indicator.

GrEg00z avatar GrEg00z commented on June 1, 2024

From my side, the problem only happen when I put my app in the background (in pause), and when I resume the app :

  • if the app is still awaken, there is no problem with the loader
  • if the app was killed by gc, the app is restarted from 0 and the loader will not working at all, while getting the error Cannot read property 'android' of undefined when I call the show() method

So the problem on the loader seems to come from the restart on application, when the app is already in pause in the background

from nativescript-loading-indicator.

erkanarslan avatar erkanarslan commented on June 1, 2024

I also have this problem with Android. On iOS, it works fine. I use NS with Angular.

I show the loading indicator on the ngOnInit method of the first page shown when app starts.
I tried calling the show method with delay in setTimeout to check if something is not initialized.

  • If I try a delay of 1 second, it works.
  • If I try a delay of 100 ms, I get a different error:
JS: ERROR Error: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
JS:     android.view.ViewRootImpl.setView(ViewRootImpl.java:798)
JS:     android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:356)
JS:     android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
JS:     android.widget.PopupWindow.invokePopup(PopupWindow.java:1434)
JS:     android.widget.PopupWindow.showAtLocation(PopupWindow.java:1203)
JS:     android.widget.PopupWindow.showAtLocation(PopupWindow.java:1170)
JS:     com.tns.Runtime.callJSMethodNative(Native Method)
JS:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1209)
JS:     com.tns.Runtime.callJSMethodImpl(Runtime.java:1096)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:1083)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:1063)
JS:     com.tns.Runtime.callJSMethod(Runtime.java:1055)
JS:     com.tns.gen.java.lang.Runnable.run(Runnable.java:17)
JS:     android.os.Handler.handleCallback(Handler.java:873)
JS:     android.os.Handler.dispatchMess...

This plugin worked in the previous repository. But I upgraded to NS 6 and also switched to this repository. Since then, I have this problem.

from nativescript-loading-indicator.

Unity-G avatar Unity-G commented on June 1, 2024

Same issue here:

JS: ERROR TypeError: Cannot read property 'android' of null

JS: ERROR CONTEXT {
JS:   "view": {
JS:     "def": {
JS:       "nodeFlags": 37863425,
JS:       "rootNodeFlags": 33554433,
JS:       "nodeMatchedQueries": 0,
JS:       "flags": 0,
JS:       "nodes": [

JS:         {

JS:           "nodeIndex": 0,
JS:           "parent": null,
JS:           "renderParent": null,

JS:           "bindingIndex": 0,
JS:           "outputIndex": 0,

JS:           "checkIndex": 0,
JS:           "flags": 33554433,
JS:           "childFlags": 4308992,
JS:           "directChildFlags": 4308992,
JS:           "childMatchedQueries": 0,

JS:           "matchedQueries": {},

JS:           "matchedQueryIds": 0,

JS:           "references": {},

JS:           "ngContentIndex": null,

JS:           "childCount": 1,
JS:           "bindings": [],
JS:           "bindingFlags": 0,

JS:           "outputs": [],

JS:           "element": {

JS:             "ns": "",
JS:             "name": "Login",
JS:             "attrs": [],
JS:             "template": null,
JS:             "componentProvider": {
JS:               "nodeIndex": 1,
JS:               "parent": "[Circular]",
JS:               "renderParent": "[Circular]",
JS:               "bindingIndex": 0...

from nativescript-loading-indicator.

kriefsacha avatar kriefsacha commented on June 1, 2024

Someone succeeded to resolve this issue ?

from nativescript-loading-indicator.

keithgulbro avatar keithgulbro commented on June 1, 2024

Any update on this android bug? This loading indicator is a significant value add to most applications so I feel like we should at least continue the discussion.

from nativescript-loading-indicator.

GrEg00z avatar GrEg00z commented on June 1, 2024

I had this problem when I was upgrading my app from nativescript 5.0 to 6.0.

On NS 6.0.0, I was forced to upgrade the plugin loading indicator (old repository on 2.3.2) to @nstudio/nativescript-loading-indicator (new repository 1.0.0), and then the problem appeared.

Its only when I upgraded to nativescript 6.2.0 that I resolved the problem, but I had also to change some parts on my code to make the loader OK :

  • I was using in main.ts :
platformNativeScriptDynamic({
	createFrameOnBootstrap : true
}).bootstrapModule(AppModule);

If you have this, you must remove createFrameOnBootstrap

  • In my app starting page (app.component.html), I was using a <router-outlet> for all my app
    You must change your router to <page-router-outlet>

After all of this changes, I didn't get any other problem with the loading plugin (on version 1.0.0)

from nativescript-loading-indicator.

bradmartin avatar bradmartin commented on June 1, 2024

The demo apps work properly so we would need a project to see this issue if it's still occurring with the latest versions which contains a lot of fixes for timing issues.

from nativescript-loading-indicator.

kandangit avatar kandangit commented on June 1, 2024

I face the same issue with NS 6.4.0
Using the latest version of the plugin: 3.0.4

Have a NS application with Angular. This is the flow where I end up calling the show() method of LoadingIndicator:
Application starts -> go to home component
Guard executes for home component.
An action is dispatched to load an array of data from the server.
An effect will call a service to load data.
An HTTP interceptor intercepts the request. The intercept() method calls a LoadingService where I call the show() method.

To my opinion, it seems may be related to the fact of calling the indicator before loading any component. But I don´t know the best way to fix though will try to remove the guard.

Error log: Error creating Loading Indicator Pop Over: Cannot read property 'android' of null

With 3.0.1 the error was: nativescript android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?

Thanks.

from nativescript-loading-indicator.

arodiani avatar arodiani commented on June 1, 2024

I'm using NS 6.5.0 and plugin 3.0.4 with an NS angular application.

I had the same issue and I solved changing in app.component.html from to

Can this be the root cause of the bug?

from nativescript-loading-indicator.

prajilshresthaiw avatar prajilshresthaiw commented on June 1, 2024

Why is no-one attending to this thread? Are the maintainers not active for this plugin?

from nativescript-loading-indicator.

beeman avatar beeman commented on June 1, 2024

@prajilshresthaiw open source software does not give any guarantee that people will actively maintain it. It's generally considered best-effort.

The maintainers have probably tons of other things to do, generally working on projects that make money to feed them and pay their rent.

So in order to fix this issue, feel free to shoot in pull request that fixes it, or fork the project and publish your fixed version.

Alternatively, when your company relies on it there is probably some money and you can hire one of the maintainers to fix the issue for you.

from nativescript-loading-indicator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.