Skip to content

Error destroy activity when I close the app with the back button #8667

@Jean45612

Description

@Jean45612

Environment

Component nativescript has 6.7.4 version and is up to date. tns-core-modules: 6.5.5 tns-android: 6.5.1 tns-ios: 6.5.0 

Describe the bug
Hello friends, I need your help, I am new to nativescript, and I am creating a native angular application, but when I close the application with the Back button, this error appears, I have looked for similar errors in this repository but I have not been able to solve them, please help me to solve it, it is very urgent, I would really appreciate it

System.err: An uncaught Exception occurred on "main" thread. System.err: Unable to destroy activity {org.nativescript.GAFStore/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onDestroy failed System.err: Error: View not added to this instance. View: ProxyViewContainer(8) CurrentParent: Page(4) ExpectedParent: AppHostView(1) System.err: System.err: StackTrace: System.err: java.lang.RuntimeException: Unable to destroy activity {org.nativescript.GAFStore/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onDestroy failed System.err: Error: View not added to this instance. View: ProxyViewContainer(8) CurrentParent: Page(4) ExpectedParent: AppHostView(1) System.err: at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4720) System.err: at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4743) System.err: at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:39) System.err: at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145) System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70) System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1960) System.err: at android.os.Handler.dispatchMessage(Handler.java:106) System.err: at android.os.Looper.loop(Looper.java:214) System.err: at android.app.ActivityThread.main(ActivityThread.java:7094) System.err: at java.lang.reflect.Method.invoke(Native Method) System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975) System.err: Caused by: com.tns.NativeScriptException: Calling js method onDestroy failed System.err: Error: View not added to this instance. View: ProxyViewContainer(8) CurrentParent: Page(4) ExpectedParent: AppHostView(1) System.err: at com.tns.Runtime.callJSMethodNative(Native Method) System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1286) System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1173) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1160) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1138) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1134) System.err: at com.tns.NativeScriptActivity.onDestroy(NativeScriptActivity.java:39) System.err: at android.app.Activity.performDestroy(Activity.java:7697) System.err: at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1310) System.err: at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4705) System.err: ... 11 more

To Reproduce
tns-run-android

then launch the mobile app on the device and finally go back with the back button, and you will see this error come out

Package.json

{ "nativescript": { "id": "org.nativescript.GAFStore", "tns-ios": { "version": "6.5.0" }, "tns-android": { "version": "6.5.1" } }, "description": "NativeScript Application", "license": "SEE LICENSE IN <your-license-filename>", "repository": "<fill-your-repository-here>", "scripts": { "ngcc": "ngcc --properties es2015 module main --first-only", "postinstall": "npm run ngcc" }, "dependencies": { "@angular/animations": "~9.1.0", "@angular/common": "~9.1.0", "@angular/compiler": "~9.1.0", "@angular/core": "~9.1.0", "@angular/forms": "~9.1.0", "@angular/platform-browser": "~9.1.0", "@angular/platform-browser-dynamic": "~9.1.0", "@angular/router": "~9.1.0", "@nativescript/angular": "~9.0.0", "@nativescript/theme": "~2.3.0", "nativescript-drop-down": "^5.0.5", "nativescript-mapbox": "^5.0.1", "nativescript-toast": "^2.0.0", "reflect-metadata": "~0.1.12", "rxjs": "^6.5.0", "tns-core-modules": "~6.5.0", "zone.js": "~0.10.3" }, "devDependencies": { "@angular/compiler-cli": "~9.1.0", "@ngtools/webpack": "~9.1.0", "@types/file-saver": "^2.0.1", "@types/jasmine": "^3.5.10", "nativescript-dev-webpack": "~1.5.0", "tns-platform-declarations": "^6.5.8", "typescript": "~3.8.3" }, "gitHead": "3153594d609d66fab71745c881d617ac1328ea1b", "readme": "NativeScript Application" } 

app.module.ts

import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; import { NativeScriptModule, NativeScriptHttpClientModule, NativeScriptFormsModule, registerElement } from "@nativescript/angular"; import { AppRoutingModule } from "./app-routing.module"; import { AppComponent } from "./app.component"; import { LoginComponent } from './components/login/login.component'; import { HeaderComponent } from './components/partials/header/header.component'; import { FooterComponent } from './components/partials/footer/footer.component'; import { IndexComponent } from './components/index/index.component'; import { RegistrarComponent } from './components/registrar/registrar.component'; import { DashboardComponent } from './components/dashboard/dashboard.component'; import { CategoriasComponent } from './components/categorias/categorias.component'; registerElement("DropDown", () => require("nativescript-drop-down/drop-down").DropDown); registerElement("Mapbox", () => require("nativescript-mapbox").MapboxView); @NgModule({ bootstrap: [ AppComponent ], imports: [ NativeScriptModule, AppRoutingModule, NativeScriptHttpClientModule, NativeScriptFormsModule, ], declarations: [ AppComponent, LoginComponent, HeaderComponent, FooterComponent, IndexComponent, RegistrarComponent, DashboardComponent, CategoriasComponent, ], providers: [], schemas: [ NO_ERRORS_SCHEMA ] }) /* Pass your application module to the bootstrapModule function located in main.ts to start your app */ export class AppModule { } 

app.routing.module.ts

import { NgModule } from "@angular/core"; import { Routes } from "@angular/router"; import { NativeScriptRouterModule } from "@nativescript/angular"; import { LoginComponent } from "./components/login/login.component"; import { IndexComponent } from "./components/index/index.component"; import { RegistrarComponent } from "./components/registrar/registrar.component"; import { DashboardComponent } from "./components/dashboard/dashboard.component"; import { CategoriasComponent } from "./components/categorias/categorias.component"; const routes: Routes = [ { path: "", redirectTo: "/index", pathMatch: "full" }, { path: "index", component: IndexComponent }, { path: "login", component: LoginComponent }, { path: "registrar", component: RegistrarComponent }, { path: "dashboard", component: DashboardComponent }, { path: "categorias", component: CategoriasComponent } ]; @NgModule({ imports: [NativeScriptRouterModule.forRoot(routes)], exports: [NativeScriptRouterModule] }) export class AppRoutingModule { } 

android manifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"	package="__PACKAGE__"	android:versionCode="1"	android:versionName="1.0">	<supports-screens	android:smallScreens="true"	android:normalScreens="true"	android:largeScreens="true"	android:xlargeScreens="true"/>	<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>	<uses-permission android:name="android.permission.INTERNET"/>	<application	android:name="com.tns.NativeScriptApplication"	android:allowBackup="true"	android:icon="@drawable/icon"	android:label="@string/app_name"	android:theme="@style/AppTheme">	<activity	android:name="com.tns.NativeScriptActivity"	android:label="@string/title_activity_kimera"	android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode"	android:theme="@style/LaunchScreenTheme">	<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />	<intent-filter>	<action android:name="android.intent.action.MAIN" />	<category android:name="android.intent.category.LAUNCHER" />	</intent-filter>	</activity>	<activity android:name="com.tns.ErrorReportActivity"/>	</application> </manifest> 

please help me, I would really appreciate it

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions