通过命令行构建 Android Studio 应用 [英] Build Android Studio app via command line

查看:42
本文介绍了通过命令行构建 Android Studio 应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想构建一个 Android Studio 应用程序(Gradle 构建系统),但我想通过命令行执行此操作.

I want to build an Android Studio app (the Gradle build system), but I want to do this via the command line.

推荐答案

Android Studio 自动创建一个 Gradle wrapper 位于项目的根目录中,这就是它调用 Gradle 的方式.包装器基本上是一个脚本,它调用实际的 Gradle 二进制文件,并允许您使 Gradle 保持最新,这使得使用版本控制更容易.要运行 Gradle 命令,您可以简单地使用位于项目根目录(或 Windows 上的 gradlew.bat)中的 gradlew 脚本,后跟您要执行的任务的名称.想跑.例如,要构建 Android 应用程序的调试版本,您可以从存储库的根目录运行 ./gradlew assembleDebug.在默认项目设置中,生成的 apk 可以在 app/build/outputs/apk/app-debug.apk 中找到.在 *nix 机器上,您也可以只运行 find .-name '*.apk' 找到它,如果它不存在.

Android Studio automatically creates a Gradle wrapper in the root of your project, which is how it invokes Gradle. The wrapper is basically a script that calls through to the actual Gradle binary and allows you to keep Gradle up to date, which makes using version control easier. To run a Gradle command, you can simply use the gradlew script found in the root of your project (or gradlew.bat on Windows) followed by the name of the task you want to run. For instance, to build a debug version of your Android application, you can run ./gradlew assembleDebug from the root of your repository. In a default project setup, the resulting apk can then be found in app/build/outputs/apk/app-debug.apk. On a *nix machine, you can also just run find . -name '*.apk' to find it, if it's not there.

这篇关于通过命令行构建 Android Studio 应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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