181

I was trying to investigate the project build error in the console output as follow:

:myapp:processDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
...
...

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

I suspect it has something to do with resource not found error. My question is, at IDE level how can I add --stacktrace or --debug option so that it can produce more information for me to debug?

Neoh
  • 15,906
  • 14
  • 66
  • 78

13 Answers13

250

You can use GUI to add these gradle command line flags from

File > Settings > Build, Execution, Deployment > Compiler

For MacOS user, it's here

Android Studio > Preferences > Build, Execution, Deployment > Compiler

like this (add --stacktrace or --debug)

enter image description here

Note that the screenshot is from before 0.8.10, the option is no longer in the Compiler > Gradle section, it's now in a separate section named Compiler (Gradle-based Android Project)

piotrek1543
  • 19,130
  • 7
  • 81
  • 94
Piyush Agarwal
  • 25,608
  • 8
  • 98
  • 111
  • 4
    This is gone in 0.8.12. Anyone know more? – nmr Oct 14 '14 at 20:11
  • 4
    They took Compiler option on root I think, checked in Android Studio 0.8.10. Now studio calling it Compiler (Gradle-based Android Project). Check once and update. – Piyush Agarwal Oct 16 '14 at 11:09
  • 2
    I think I understand what you're saying, but I am talking about something else. In the Gradle section of the "Project Settings" they have removed the "Command-line Options" field. So there's no place to add flags to Gradle. (The "VM Options" field is still there, though.) – nmr Oct 16 '14 at 18:32
  • 2
    @nmr: Do not refer to "Gradle." Instead, check the "Compiler (Gradle-based Android Projects)". There you will find the "Comand-line Options." – Behnam Mar 14 '15 at 07:50
  • 7
    In Android Studio 1.2.2 (on Windows) it's `File > Settings > Build, Execution, Deployment > Compiler` where you can add the flags in `Command-line Options:`. – chRyNaN Aug 27 '15 at 16:19
  • 2
    In Android Studio 1.5.1 (on Mac) it's now `Android Studio > Preferences > Build, Execution, Deployment > Compiler` – auspicious99 Feb 03 '16 at 01:45
  • In Android Studio 2.2.3, (on Windows) it is still Android Studio > Preferences > Build, Execution, Deployment > Compiler. – Jason Jan 20 '17 at 21:52
  • Latest documentation https://developer.android.com/studio/run/index.html#gradle-console – Michael Osofsky Mar 14 '18 at 22:00
  • found it on 3.2.1 – DoruChidean Oct 16 '18 at 11:50
  • if this is not working try https://stackoverflow.com/a/65132651/10505343 – Wimukthi Rajapaksha Aug 22 '21 at 08:42
40

On the Mac version of Android Studio Beta 1.2, it's under

Android Studio->preferences->Build, Execution, Deployment->Compiler

codingEnthusiast
  • 3,800
  • 2
  • 25
  • 37
jpa57
  • 587
  • 4
  • 11
  • 3
    This answer is correct as of Android Studio 2.0 as well. – Will Vanderhoef Apr 25 '16 at 15:16
  • 1
    In the latest versions of AS (2.2 and 2.3) to see Compiler option you need to be out of open project, go to AS begin (where the recent project are visible) and click Configure -> Preferences->Build, Execution,Deployment. Otherwise Compiler is not visible – Stoycho Andreev Mar 13 '17 at 15:15
34

What I use for debugging purposes is running the gradle task with stacktrace directly in terminal. Then you don't affect your normal compiles.

From your project root directory, via terminal you can use:

./gradlew assembleMyBuild --stacktrace
Francois
  • 10,465
  • 4
  • 53
  • 64
  • Tip for WINDOWS users if the terminal not working simply click ctrl twice(a popup window of run appears) and paste the above there. – Ammar Feb 23 '23 at 10:23
26

In Android Studios 2.1.1, the command-line Options is under "Build, Execution, Deployment">"Compiler"

enter image description here

Angel Koh
  • 12,479
  • 7
  • 64
  • 91
9

To add a stacktrace click on the Gradle on the right side of Android project screen;

  1. Click on the settings icon; this will open the settings page,

  2. Then click on compiler

  3. Then add the command --stacktrace or --debug as shown;

  4. Run the application again to get the gradle report.

Community
  • 1
  • 1
user1551978
  • 91
  • 1
  • 1
6

(edited Dec 2018: Android Studio 3.2.1 on Mac too)

For Android Studio 3.1.3 on a Mac, it was under

Android Studio -> Preferences -> Build, Execution, Deployment -> Compiler

and then, to view the stack trace, press this button

button to show stack trace

auspicious99
  • 3,902
  • 1
  • 44
  • 58
  • I followed the steps given in the solutions below, but I still get the prompt -" Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights." – Nishita Aug 10 '18 at 13:18
  • @Nishita , did you type in `--stacktrace` and/or `--info` and/or `--debug` and/or `--scan` under command-line options? – auspicious99 Aug 11 '18 at 15:12
  • 1
    yes I did. Enabling it in preferences settings did not help. I had to manually run the command on terminal to see the stacktrace. – Nishita Aug 13 '18 at 06:04
2

For Android Studio 3.1.3 it was under

File -> Settings -> Build, Execution, Deployment -> Compiler

gmetax
  • 3,853
  • 2
  • 31
  • 45
1

my solution is this:

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:27.1.0'
    }
}
1

In case you use fastlane, additional flags can be passed with

gradle(
   ...
   flags: "{your flags}"
)

More information here

Vladyslav Zavalykhatko
  • 15,202
  • 8
  • 65
  • 100
0

my solution is this:

cd android

and then:

./gradlew assembleMyBuild --stacktrace
Kourosh Neyestani
  • 781
  • 2
  • 9
  • 16
0

Go into your project.

install Gradle.

https://docs.gradle.org/current/userguide/installation.html

On a mac: brew install gradle

Then gradle build --stacktrace

Byusa
  • 2,279
  • 1
  • 16
  • 21
-1

To Increase Maximum heap: Click to open your Android Studio, look at below pictures. Step by step. ANDROID STUDIO v2.1.2

Click to navigate to Settings from the Configure or GO TO FILE SETTINGS at the top of Android Studio.

enter image description here

check also the android compilers from the link to confirm if it also change if not increase to the same size you modify from the compiler link.

Note: You can increase the size base on your memory capacity and remember this setting is base on Android Studio v2.1.2

A J
  • 3,970
  • 14
  • 38
  • 53
-3

bro it is very easy download an apk file of any game from browser and double click it whet it open than your pc would have the capability to make any apk file and then try it. solution got after 1 year

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 21 '23 at 20:15