如何编译和使用批处理文件,而不是IDE运行Android应用程序? [英] how to compile and run android application using a batch file and not IDE?

查看:219
本文介绍了如何编译和使用批处理文件,而不是IDE运行Android应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何可以编译和使用批处理文件,而不是任何其他的IDE中运行Android应用程序?是有可能这样做?如果有可能,你能不能教我如何制作一个批处理文件?我没有任何想法,我只知道如何使用Eclipse IDE中运行ID。谢谢。


解决方案

机器人DOC ,我只需添加调试模式:

调试模式


  

有关直接的应用测试和调试,你可以建立你
  在调试模式,并立即申请安装在模拟器上。
  在调试模式下,构建工具自动登录你的应用程序
  使用调试键和的zipalign优化包。


  
  

要建立在调试模式:


  
  

打开命令行并导航到你的项目的根
  目录。


  
  

使用Ant来编译在调试模式下项目:蚂蚁调试
  这将创建项目的bin /目录内调试.apk文件,
  命名-debug.apk。该文件已经与签约
  调试密钥和已用的zipalign对齐。你每次改变
  源文件或资源,则必须以包再次运行Ant
  起来的应用程序的最新版本。


  
  

要安装并在模拟器上运行应用程序,请参见以下
  关于运行模拟器部分。


如何运行


  

在可以运行在设备上的应用程序,你必须执行一些
  为您的设备基本设置:


  
  

在设备上启用USB调试。在运行Android大多数设备
  3.2或以上,你可以找到下设置>应用程序>开发的选项。在Android 4.0及更高版本,它在设置>开发
  选项​​。


  
  

请注意:在Android 4.2及更高版本,开发人员选项隐藏
  默认。


  
  

要使其可用,进入设置>关于手机和自来水
  版本号七次。
  返回到previous屏幕找到
  开发人员选项。


  
  

确保您的开发计算机可以检测
  当你通过USB读取连接的设备设置为设备
  发展以获取更多信息。


  
  

一旦你的设备已经设置并且通过USB连接,浏览到您的
  SDK的平台工具/目录,并在设备上安装的.apk文件:


  
  

ADB -d安装路径/到/你/ app.apk


  
  

-d标志指定您
  要使用连接的设备(如果你也有一个模拟器
  运行)。


一个简单的批处理调试模式可以是:

 设置PROJECT_ROOT =Your_project_root
设置ADB_LOCATION =您的ADB位置
设置PROJECT_NAME =项目名称
CD%PROJECT_ROOT%
蚂蚁调试
CD%ADB_LOCATION%
亚行-d安装%PROJECT_ROOT%/斌/%PROJECT_NAME%-debug.apk


在释放模式

编译更久一点,所以我要说的阅读文档。

How can i compile and run android application using a batch file and not any other IDE? is it possible to do? and if it is possible, can you teach me how to make a batch file? I don't have any idea to it, I only know how to run id using eclipse ide. thank you.

解决方案

From android doc, i'll just add debug mode:

Debug mode

For immediate application testing and debugging, you can build your application in debug mode and immediately install it on an emulator. In debug mode, the build tools automatically sign your application with a debug key and optimize the package with zipalign.

To build in debug mode:

Open a command-line and navigate to the root of your project directory.

Use Ant to compile your project in debug mode: ant debug This creates your debug .apk file inside the project bin/ directory, named -debug.apk. The file is already signed with the debug key and has been aligned with zipalign. Each time you change a source file or resource, you must run Ant again in order to package up the latest version of the application.

To install and run your application on an emulator, see the following section about Running on the Emulator.

How to run

Before you can run your application on a device, you must perform some basic setup for your device:

Enable USB debugging on your device. On most devices running Android 3.2 or older, you can find the option under Settings > Applications > Development. On Android 4.0 and newer, it's in Settings > Developer options.

Note: On Android 4.2 and newer, Developer options is hidden by default.

To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options.

Ensure that your development computer can detect your device when connected via USB Read Setting up a Device for Development for more information.

Once your device is set up and connected via USB, navigate to your SDK's platform-tools/ directory and install the .apk on the device:

adb -d install path/to/your/app.apk

The -d flag specifies that you want to use the attached device (in case you also have an emulator running).

A simple batch for debug mode could be:

set PROJECT_ROOT="Your_project_root"
set ADB_LOCATION="Your ADB Location"
set PROJECT_NAME="Your project name"
cd %PROJECT_ROOT%
ant debug
cd %ADB_LOCATION%
adb -d install %PROJECT_ROOT%/bin/%PROJECT_NAME%-debug.apk


Compile in release mode is a bit more longer, so i would say read the documentation.

这篇关于如何编译和使用批处理文件,而不是IDE运行Android应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆