简体   繁体   English

如何在设备而不是模拟器上运行使用Cordova生成的.apk文件?

[英]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驱动程序。

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强制在设备上启动时(如果没有找到设备就会启动模拟器,这有时会很烦人)。

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.

相关问题 如何在 Web 浏览器上运行 apk 文件,使 apk 知道它是在真实设备上而不是在模拟器上 - How to run an apk file on a web browser making the apk know that it is on a real device and not on a emulator 无法使用Calabash Android安装程序在模拟器/设备上运行android apk文件 - Not able to run android apk file on emulator/device using calabash android setup 如何在 android 仿真器中运行(不安装).apk 文件 - How to run (not install) .apk file in android emulator 如何使用 Android 模拟器在 Saucelas 上运行 .apk? - How to run .apk on Saucelabs using Android emulator? 如何使用adb在模拟器中安装apk文件? - how to install apk file in emulator using adb? 我们可以使用apk文件在eclipse模拟器中运行android应用吗 - Can we run android app in eclipse emulator by using the apk file 在使用Cordova Run命令行时签署调试APK文件 - Sign a debug APK file while using cordova run command line 如何在真实的Android设备上安装Eclipse生成的APK文件 - How to install Eclipse generated apk file on real android device 如何使用 Cordova 运行 Android 模拟器? - How to run the Android Emulator with Cordova? 如何使用dockerfile在模拟器上构建和运行android apk - how to build and run android apk on emulator using dockerfile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM