简体   繁体   English

Nativescript tns run android(应用程序未在设备上运行)

[英]Nativescript tns run android (application is not running on device)

When i do tns run ios, all is fine but tns run android just gives me error like this.当我执行 tns run ios 时,一切都很好,但 tns run android 只是给我这样的错误。 I tried both device and emulator but the same result.我尝试了设备和模拟器,但结果相同。


i have done:我已经做好了:

  • reinstall platforms,node_module,hooks.重新安装平台、节点模块、挂钩。 tns doctor has no error done tns医生没有做错
  • clearing cache on webstorm(android studio project has no problem清除webstorm上的缓存(android studio项目没有问题
  • running) created new {N} file with tns create but same error occured running) 使用 tns create 创建了新的 {N} 文件但发生了同样的错误
  • putting 'applicationId = "org.nativescript.fagck_app"' on my把 'applicationId = "org.nativescript.fagck_app"' 放在我的
  • app.gradle file. app.gradle 文件。 restarted PC/adb multiple times.多次重启 PC/adb。 ran `tns debug运行`tns调试
  • android --debug-brk` but still same error occured android --debug-brk` 但仍然发生同样的错误
  • reinstall brew jdk8重新安装brew jdk8

error code:错误代码:

Installing on device 2744b499...
Successfully installed on device with identifier '2744b499'.
Application org.nativescript.fagck_app is not running on device 2744b499.
This issue may be caused by:
        * crash at startup (try `tns debug android --debug-brk` to check why it crashes)
        * different application identifier in your package.json and in your gradle files (check your identifier in `package.json` and in all *.gradle files in your App_Resources directory)
        * device is locked
        * manual closing of the application
Unable to apply changes on device: 2744b499. Error is: Application org.nativescript.fagck_app is not running.

The problem for me was that the Application id was different in both:对我来说,问题是两者的应用程序ID不同:

package.json package.json

}
  ...
    "nativescript": {
    "id": "org.nativescript.myApp"
  }
}

And nativescript.config.tsnativescript.config.ts

export default {
  id: 'org.nativescript.myApp',
  appResourcesPath: 'App_Resources',
  android: {
    v8Flags: '--expose_gc',
    markingMode: 'none'
  }
} as NativeScriptConfig;

It must be the same.它必须是相同的。 After that, it works just fine.之后,它工作得很好。

Try this commands while your cable is connected to your phone:在电缆连接到手机时尝试以下命令:

  1. adb kill-server adb 杀死服务器
  2. sudo adb start-server sudo adb 启动服务器
  3. sudo adb reconnect须藤亚行重新连接

then retry running NativeScript command.然后重试运行 NativeScript 命令。

try with changing the application ID to "com.example.myapp" where example is your domain name.尝试将应用程序 ID 更改为“com.example.myapp”,其中 example 是您的域名。

In may case, i have installed a software in my mac that also runs adb.在可能的情况下,我在我的 mac 中安装了一个也运行 adb 的软件。 The main prob really was its conflicting with the android adb.主要问题确实是它与 android adb 冲突。 uninstall that software solved the problem卸载那个软件解决了问题

I faced the same problem:我遇到了同样的问题:

>>> ns run android
(...)
Project successfully built.
The build result is located at: /Users/krzysztof/dev/surfcloud-mobile-apps/bizApp/platforms/android/app/build/outputs/apk/debug/app-debug.apk
Installing on device ce12171cd1a920bd0d...
Successfully installed on device with identifier 'ce12171cd1a920bd0d'.
Application app.surfcloud.bizApp is not running on device ce12171cd1a920bd0d.
This issue may be caused by:
    * crash at startup (try `tns debug android --debug-brk` to check why it crashes)
    * different application identifier in your package.json and in your gradle files (check your identifier in `package.json` and in all *.gradle files in your App_Resources directory)
    * device is locked
    * manual closing of the application
Unable to apply changes on device: ce12171cd1a920bd0d. Error is: Application app.surfcloud.bizApp is not running.

In my case the solution was to change:在我的例子中,解决方案是改变:

<activity android:exported="false" (...)/>

to:到:

<activity android:exported="true" (...)/>

in AndroidManifest.xml .AndroidManifest.xml中。 After setting exported to true the app launches normally.exported设置为true后,应用程序正常启动。

in my case, this did not work due to an overflow of the device's memory.在我的情况下,由于设备的 memory 溢出,这不起作用。 Clean memory and try install again清理 memory 并再次尝试安装

For me, it was just that I had a previous version of the app already installed on the device.对我来说,只是我已经在设备上安装了以前版本的应用程序。 Uninstalling that fixed the problem.卸载解决了这个问题。

In my case, I ran out of disk space on my phone... tns showed it connected to my phone and starting to install it, but then crashed with the same msg as above.就我而言,我的手机磁盘空间不足...... tns显示它已连接到我的手机并开始安装它,但随后崩溃并显示与上述相同的消息。

So I've started to remove apps and pictures, and it's just worked.所以我已经开始删除应用程序和图片,而且很管用。

Because that error appeared on a brand new project (w/o any changes) and also to an app that was already done and I know it was working as it was installed already on my phone...因为这个错误出现在一个全新的项目(没有任何更改)以及一个已经完成的应用程序中,而且我知道它正在运行,因为它已经安装在我的手机上......

  • Check if Application id is same in package.json and androidMenifest.xml检查 package.json 和 androidMenifest.xml 中的应用程序 ID 是否相同
  • If looks good then open android studio: Tools > AVD Manager > Wipe Data of existing device.如果看起来不错,则打开 android 工作室:工具 > AVD 管理器 > 擦除现有设备的数据。
  • Restart the application: tns run android.重启应用程序:tns run android。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM