Android 如何在设备而不是模拟器上运行使用 Cordova 生成的 .apk 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21401047/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to run .apk file generated using Cordova on device instead of emulator?
提问by user3213851
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 thistutorial. Following the tutorial I was able to run the .apk file in the emulator. 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. Any help will be appreciated.
我跟着 这个教程。按照教程,我能够在模拟器中运行 .apk 文件。现在我想在我的设备上运行该应用程序。即使我使用 USB 将我的设备连接到笔记本电脑,我也无法在我的设备上运行该应用程序。任何帮助将不胜感激。
回答by QuickFix
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 驱动程序。
Edit:
编辑:
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
以强制在设备上启动时,您可以添加一个选项(如果未找到设备,则不会启动模拟器,这有时会很烦人)。
回答by Petar Vasilev
You should go to cordova/platforms and check if there is ios or android folder depending on what you want to run the app. If the folder is not there you should add it from the command line like so:
您应该转到cordova/platforms并根据您要运行的应用程序检查是否有ios或android文件夹。如果文件夹不存在,您应该从命令行添加它,如下所示:
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. Once you've got it opened in the IDE you should be able to install it on your device. Note that the process is different for each IDE - Eclipse, IntelliJ, xCode ( btw you can also use Android Studio for android apps )
获得所需平台的项目文件夹后,您可以根据平台使用 Eclipse、IntelliJ 或 xCode 打开项目。在 IDE 中打开它后,您应该可以将它安装到您的设备上。请注意,每个 IDE 的过程都不同 - Eclipse、IntelliJ、xCode(顺便说一句,您也可以将 Android Studio 用于 android 应用程序)
Also to be able to install it on an Android phone you need to enable USB Debugging from your settings.
此外,为了能够在 Android 手机上安装它,您需要从您的设置中启用 USB 调试。
回答by Sport
take that .apk file instal in your device. you will get your apps.
将该 .apk 文件安装到您的设备中。你会得到你的应用程序。