android icon indicating copy to clipboard operation
android copied to clipboard

tns run android - Error: Application is already started.

Open Husky931 opened this issue 5 years ago • 2 comments
trafficstars

I keep getting this error when i start tns run android:

My connected device is:

# │ Device Name            │ Platform  │ Device Identifier │ Type     │ Status    │ Connection Type
1 │ Galaxy Nexus API 25    │ Android   │ emulator-5554     │ Emulator │ Connected │ Local  

The error i keep getting is:

System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Error calling module function 
System.err: Error: Application is already started.
System.err: File: (file: node_modules/@nativescript/core/application/application.android.js:123:0)
System.err: 
System.err: StackTrace: 
System.err: run(file: node_modules/@nativescript/core/application/application.android.js:123:0)
System.err:     at (file:///data/data/technology.sveltenative.template/files/app/bundle.js:2109:65)
System.err:     at ./app.ts(file:///data/data/technology.sveltenative.template/files/app/bundle.js:2124:30)
System.err:     at __webpack_require__(file: app/webpack/bootstrap:750:0)
System.err:     at checkDeferredModules(file: app/webpack/bootstrap:43:0)
System.err:     at webpackJsonpCallback(file: app/webpack/bootstrap:30:0)
System.err:     at (file:///data/data/technology.sveltenative.template/files/app/bundle.js:2:57)
System.err:     at require(:1:266)
System.err: 
System.err: 
System.err: Error: Application is already started.
System.err: 
System.err: StackTrace:
System.err: java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Error calling module function 
System.err: Error: Application is already started.
System.err: File: (file: node_modules/@nativescript/core/application/application.android.js:123:0)
System.err: 
System.err: StackTrace: 
System.err: run(file: node_modules/@nativescript/core/application/application.android.js:123:0)
System.err:     at (file:///data/data/technology.sveltenative.template/files/app/bundle.js:2109:65)
System.err:     at ./app.ts(file:///data/data/technology.sveltenative.template/files/app/bundle.js:2124:30)
System.err:     at __webpack_require__(file: app/webpack/bootstrap:750:0)
System.err:     at checkDeferredModules(file: app/webpack/bootstrap:43:0)
System.err:     at webpackJsonpCallback(file: app/webpack/bootstrap:30:0)
System.err:     at (file:///data/data/technology.sveltenative.template/files/app/bundle.js:2:57)
System.err:     at require(:1:266)
System.err: 
System.err: 
System.err: Error: Application is already started.
System.err:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5406)
System.err:     at android.app.ActivityThread.-wrap2(ActivityThread.java)
System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
System.err:     at android.os.Looper.loop(Looper.java:154)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6119)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
System.err: Caused by: com.tns.NativeScriptException: Error calling module function 
System.err: Error: Application is already started.
System.err: File: (file: node_modules/@nativescript/core/application/application.android.js:123:0)
System.err: 
System.err: StackTrace: 
System.err: run(file: node_modules/@nativescript/core/application/application.android.js:123:0)
System.err:     at (file:///data/data/technology.sveltenative.template/files/app/bundle.js:2109:65)
System.err:     at ./app.ts(file:///data/data/technology.sveltenative.template/files/app/bundle.js:2124:30)
System.err:     at __webpack_require__(file: app/webpack/bootstrap:750:0)
System.err:     at checkDeferredModules(file: app/webpack/bootstrap:43:0)
System.err:     at webpackJsonpCallback(file: app/webpack/bootstrap:30:0)
System.err:     at (file:///data/data/technology.sveltenative.template/files/app/bundle.js:2:57)
System.err:     at require(:1:266)
System.err: 
System.err: 
System.err: Error: Application is already started.
System.err:     at com.tns.Runtime.runModule(Native Method)
System.err:     at com.tns.Runtime.runModule(Runtime.java:674)
System.err:     at com.tns.Runtime.run(Runtime.java:666)
System.err:     at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
System.err:     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
System.err:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5403)
System.err:     ... 8 more

Could not find any related "application already started" open or closed issue

I have tried the suggested steps of removing node_modules/platform/hooks and tns plugin remove tns-core-modules + tns plugin add tns-core-modules

Husky931 avatar Aug 31 '20 02:08 Husky931

Can you give me a sample project that does this?

NathanaelA avatar Oct 16 '20 07:10 NathanaelA

I had the same problem. While Git merging, the following line moved twice to main.ts/app.ts. remove the duplicate entry.

platformNativeScriptDynamic().bootstrapModule(AppModule);

adrianzwergel avatar Jan 21 '21 10:01 adrianzwergel

I will suggest trying what @adrianzwergel mentioned but this issue here is your app is calling the boot method 2x

triniwiz avatar Sep 29 '22 14:09 triniwiz