Search code examples
androidandroid-gradle-plugingradle-pluginandroid-studio-3.3

How to run an application in debug mode inside android studio 3.3.1?


Prior to this i would run android apps in debug mode using debug icon in android studio or by pressing Shift+F9. Doing this in my android studio after some updates lead to installation of debug version (not running it). Even if no emulator or no device are connected and online, it does not prompt for target device selection window (to select something or run new emulator).

I want to know which command should be used to install debug version, run it and attach debugger to application for debugging?

Currently I need to do this steps: installDebug, then run app manually inside device and then attach debugger to it.

My current configuration of software is as below:

  • Android Studio 3.3.1 - Built on 29 Jan 2019
  • Gradle Plugin: 3.3.1
  • distributionUrlis set to https\://services.gradle.org/distributions/gradle-4.10.3-all.zip inside gradle-wrapper.properties.

Here is list of available gradle tasks:

------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------

Android tasks
-------------
androidDependencies - Displays the Android dependencies of the project.
signingReport - Displays the signing info for the base and test modules
sourceSets - Prints out all the source sets defined in this project.

Build tasks
-----------
assemble - Assemble main outputs for all the variants.
assembleAndroidTest - Assembles all the Test applications.
build - Assembles and tests this project.
buildDependents - Assembles and tests this project and all projects that depend on it.
buildNeeded - Assembles and tests this project and all projects it depends on.
bundle - Assemble bundles for all the variants.
clean - Deletes the build directory.
cleanBuildCache - Deletes the build cache directory.
compileDebugAndroidTestSources
compileDebugSources
compileDebugUnitTestSources
compileReleaseNonObfuscatedSources
compileReleaseNonObfuscatedUnitTestSources
compileReleaseSources
compileReleaseUnitTestSources

Build Setup tasks
-----------------
init - Initializes a new Gradle build.
wrapper - Generates Gradle wrapper files.

Cleanup tasks
-------------
lintFix - Runs lint on all variants and applies any safe suggestions to the source code.

Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'myproject'.
components - Displays the components produced by root project 'myproject'. [incubating]
dependencies - Displays all dependencies declared in root project 'myproject'.
dependencyInsight - Displays the insight into a specific dependency in root project 'myproject'.
dependentComponents - Displays the dependent components of components in root project 'myproject'. [incubating]
help - Displays a help message.
model - Displays the configuration model of root project 'myproject'. [incubating]
projects - Displays the sub-projects of root project 'myproject'.
properties - Displays the properties of root project 'myproject'.
tasks - Displays the tasks runnable from root project 'myproject' (some of the displayed tasks may belong to subprojects).

Install tasks
-------------
installDebug - Installs the Debug build.
installDebugAndroidTest - Installs the android (on device) tests for the Debug build.
uninstallAll - Uninstall all applications.
uninstallDebug - Uninstalls the Debug build.
uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Debug build.
uninstallRelease - Uninstalls the Release build.
uninstallReleaseNonObfuscated - Uninstalls the ReleaseNonObfuscated build.

Verification tasks
------------------
check - Runs all checks.
connectedAndroidTest - Installs and runs instrumentation tests for all flavors on connected devices.
connectedCheck - Runs all device checks on currently connected devices.
connectedDebugAndroidTest - Installs and runs the tests for debug on connected devices.
deviceAndroidTest - Installs and runs instrumentation tests using all Device Providers.
deviceCheck - Runs all device checks using Device Providers and Test Servers.
lint - Runs lint on all variants.
lintDebug - Runs lint on the Debug build.
lintRelease - Runs lint on the Release build.
lintReleaseNonObfuscated - Runs lint on the ReleaseNonObfuscated build.
lintVitalRelease - Runs lint on just the fatal issues in the release build.
test - Run unit tests for all variants.
testDebugUnitTest - Run unit tests for the debug build.
testReleaseNonObfuscatedUnitTest - Run unit tests for the releaseNonObfuscated build.
testReleaseUnitTest - Run unit tests for the release build.

Solution

  • Option 1 - launch

    Press Ctrl+Alt+F5 (or Shift+F9) to launch the app in debug mode.


    Option 2 - attach

    Choose Run -> Attach to process and select the signature of an app to enable the debug mode, which is already installed via adb.