joe_deniable
joe_deniable

Reputation: 2572

Android studio - deploy the release apk instead of debug

The run configurations in Android Studio only let you deploy the default (debugging) APK, but I have built a release APK by running gradle assembleDebug from within Android Studio (as an external tool) and would like to deploy that instead. But it doesn't seem like you can change the APK which Android Studio installs. There is an option to deploy a custom artifact, but I'm not sure what that is, or if it would help, and anyway, there doesn't seem to be an option to create a new artifact in the Android Studio Project Structure dialog.

Does anyone know how I can specify the path of the APK which Android Studio deploys? I know I can install from the command line with adb, but it would speed things up if I could just click a button. Thanks.

Upvotes: 93

Views: 52179

Answers (6)

li ki
li ki

Reputation: 372

Finding the "Build Variations" tab is one way to change it, but what if I've accidentally hidden it?

To change the build variant Android Studio uses, do one of the following:

  • Select Build > Select Build Variant in the menu.
  • Select View > Tool Windows > Build Variants in the menu.
  • Click the Build Variants tab on the tool window bar.

Copied from: Change the build variant § Build and run your app  |  Android Studio  |  Android Developers

This is a screenshot of the first approach:

re-open the "Build Variations" tab from the menu of IntelliJ IDEA

.

Upvotes: 0

zhang san
zhang san

Reputation: 11

If you can't find 'Build Variants' tab anyway, here are two methods:

You can:

  • Double press shift, search 'Build Variants'.

Or you can:

  • Click 'More tool windows' (icon looks like three dots) on the left top of the IDE, then select 'Build Variants'1

Image of location of 'Build Variants' in 'More tool windows'

Once you found the 'Build Variants' tab, you can switch between 'release' and 'debug' mode.

Upvotes: 1

Pankaj Lilan
Pankaj Lilan

Reputation: 4453

Build Variants can be changed as mentioned in the below image:

enter image description here

But other than that I was facing one more issue. If we keep the Build Variant as Release in the tab and set the below property in build.gradle file.

debuggable true

Our project will be considered debuggable even though the Build Variant is selected as Release. So, once the testing is done. We can set the debuggable as false or we can remove the property itself. I hope this answers your question.

Upvotes: 0

yoAlex5
yoAlex5

Reputation: 34175

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

Upvotes: 12

Automatico
Automatico

Reputation: 12896

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

Upvotes: 65

nenick
nenick

Reputation: 7438

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.

Upvotes: 159

Related Questions