Unfortunately, App has stopped while NFC reading and writing


#1

In my app , first I am erasing NFC tag then writing data on it , but some time my app is crashing.
After crashing Its showing message "Unfortunately, [App Name] has stopped.

  1. How can i debug this crashing ?
  2. what i am doing wrong ?

My ionic info is as follows

cli packages: (/usr/lib/node_modules)
@ionic/cli-utils  : 1.19.0
ionic (Ionic CLI) : 3.19.0

global packages:

cordova (Cordova CLI) : 7.1.0 

local packages:

@ionic/app-scripts : 3.1.5
Cordova Platforms  : android 6.2.3
Ionic Framework    : ionic-angular 3.7.1

System:

Android SDK Tools : 26.0.1
Node              : v6.12.2
npm               : 3.10.10 
OS                : Linux 4.4

My code is as follows ,

  this.subscriptions.push(     this.nfc.addNdefListener(onSuccess=>{

                  }, onFailure=>{

                  }).subscribe((nfcdata)=>{

                    this.nfc.erase().then((onSuccess)=>{
                      
                            console.log("erased NFC Tag Successfully");
                            this.writeonnfc(complete_string, vtrip_id);
                            
        
                          },(onerror)=>{ 
                                             
                                             console.log(onerror);

                                       });  

                })

              );

writeonnfc(complete_string, vtrip_id){
let message = this.ndef.textRecord(complete_string, “en”, vtrip_id);

                    this.nfc.write([message]).then((data)=>{


                        this.subscriptions.forEach(sub => {
                            sub.unsubscribe();
                          });

             
                        });

}


#2

Is this problem related to NFC plugin or Its Android Phone’s problem ?