[英]How to run .apk file generated using Cordova on device instead of emulator?
I am using Sencha Touch 2.3.1 for developing cross platform application and to deploy it to native platforms I am using Cordova 3.3.0 我正在使用Sencha Touch 2.3.1开发跨平台应用程序并将其部署到我使用Cordova 3.3.0的本机平台
I followed this tutorial. 我按照本教程。 Following the tutorial I was able to run the .apk file in the emulator.
在本教程之后,我能够在模拟器中运行.apk文件。 Now I want to run the application on my device.
现在我想在我的设备上运行该应用程序。 Even though I connect my device to the laptop using a usb, I am not able to run the application on my device.
即使我使用USB将设备连接到笔记本电脑,我也无法在设备上运行该应用程序。 Any help will be appreciated.
任何帮助将不胜感激。
To have the project run on your device instead of in the emulator, you basically only have to plug in your device before you run cordova run android
. 要让项目在您的设备上而不是在模拟器中运行,您基本上只需在运行
cordova run android
之前插入设备。
Cordova will run the emulator only if it can't find a device connected. 只有在找不到连接的设备时,Cordova才会运行仿真器。
Before you run cordova run android
, I advise you to run the command adb devices
to check if your device is found by the android sdk tools. 在你运行
cordova run android
之前,我建议你运行命令adb devices
来检查你的设备是否是由android sdk工具找到的。
If it's not, you need to enable USB debugging on the device and install an adb driver for your device. 如果不是,则需要在设备上启用USB调试并为您的设备安装adb驱动程序。
As this answer seems to get up votes, I think it would be a good idea to improve it a little... 由于这个答案似乎得到了投票,我认为稍微改善它是个好主意......
There's actually a --device
option you can add when you run cordova run android
to force to start on the device (without that an emulator is started if no device is found, that can sometime be annoying). 实际上你可以添加一个
--device
选项,当你运行cordova run android
强制在设备上启动时(如果没有找到设备就会启动模拟器,这有时会很烦人)。
You should go to cordova/platforms and check if there is ios or android folder depending on what you want to run the app. 您应该去cordova /平台并检查是否有ios或android文件夹,具体取决于您要运行应用程序的内容。 If the folder is not there you should add it from the command line like so:
如果文件夹不存在,您应该从命令行添加它,如下所示:
cordova platform add android
or 要么
cordova platform add ios
of course I am assuming you have the cordova command line utilities installed 当然我假设你已经安装了cordova命令行实用程序
EDIT: 编辑:
once you've got the project folder for the platform you need you can open the project using Eclipse, IntelliJ or xCode depending on your platform. 一旦获得了所需平台的项目文件夹,就可以使用Eclipse,IntelliJ或xCode打开项目,具体取决于您的平台。 Once you've got it opened in the IDE you should be able to install it on your device.
一旦你在IDE中打开它,你就可以在你的设备上安装它。 Note that the process is different for each IDE - Eclipse, IntelliJ, xCode ( btw you can also use Android Studio for android apps )
请注意,每个IDE的过程都不同 - Eclipse,IntelliJ,xCode(顺便说一句,你也可以使用Android Studio for Android apps)
Also to be able to install it on an Android phone you need to enable USB Debugging from your settings. 另外,为了能够在Android手机上安装它,您需要从您的设置启用USB调试。
take that .apk file instal in your device. 将.apk文件安装在您的设备中。 you will get your apps.
你会得到你的应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.