Android 工作室-部署发布 apk 而不是调试

Android Studio 中的运行配置只允许部署默认的(调试) APK,但是我已经通过在 Android Studio 中运行 gradle Assembly Debug (作为一个外部工具)构建了一个发行版 APK,并且想要部署它。但似乎不能改变 Android Studio 安装的 APK。有一个选项可以部署定制工件,但我不确定那是什么,或者它是否有帮助,而且,似乎没有一个选项可以在 Android Studio 项目结构对话框中创建一个新的工件。

有人知道如何指定 Android Studio 部署的 APK 的路径吗?我知道我可以用 adb 从命令行安装,但是如果我只需要点击一个按钮就可以加快速度。谢谢。

46769 次浏览

On the left should be a "Build Variants" tab. There you can switch between your build types. If there no tabs visible than look left buttom for a monitor symbol and click it. Then you should find the build types. The selected one will be installed.

Click the Build Variation tab on the far left side. If it is not there, press the monitor icon in the far left corner (the darker gray area):

Monitor Icon

In the build variation tab change from debug to release by clicking the list item.

Build Variation

Run a command

./gradlew assemble<variant_name>
//for example
./gradlew assembleRelease

[package aar]

After success build you can find .apk file at

project_path/app/build/outputs/apk/<variant_name>/
//for example
project_path/app/build/outputs/apk/release/

or just install via adb

adb install apk_path

Read more here