How to Add Stacktrace or debug Option when Building Android Studio Project

AndroidAndroid StudioStack Trace

Android Problem Overview


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?

Android Solutions


Solution 1 - Android

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)

Solution 2 - Android

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

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

Solution 3 - Android

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

Solution 4 - Android

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

enter image description here

Solution 5 - Android

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.

Solution 6 - Android

(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

Solution 7 - Android

For Android Studio 3.1.3 it was under

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

Solution 8 - Android

my solution is this:

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

Solution 9 - Android

To be able to run options like --stacktrace within a gradle command, you need to put it at the beginning, like:

./gradlew --stacktrace assembleMyBuild

E.g,

./gradlew --stacktrace assembleDebug

Solution 10 - Android

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

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

More information here

Solution 11 - Android

my solution is this:

cd android

and then:

./gradlew assembleMyBuild --stacktrace

Solution 12 - Android

Go into your project.

install Gradle.

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

On a mac: brew install gradle

Then gradle build --stacktrace

Solution 13 - Android

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNeohView Question on Stackoverflow
Solution 1 - AndroidPiyush AgarwalView Answer on Stackoverflow
Solution 2 - Androidjpa57View Answer on Stackoverflow
Solution 3 - AndroidFrancoisView Answer on Stackoverflow
Solution 4 - AndroidAngel KohView Answer on Stackoverflow
Solution 5 - Androiduser1551978View Answer on Stackoverflow
Solution 6 - Androidauspicious99View Answer on Stackoverflow
Solution 7 - AndroidgmetaxView Answer on Stackoverflow
Solution 8 - AndroidFredy sanchez .mView Answer on Stackoverflow
Solution 9 - AndroidAnthony CannonView Answer on Stackoverflow
Solution 10 - AndroidVladyslav ZavalykhatkoView Answer on Stackoverflow
Solution 11 - AndroidKourosh NeyestaniView Answer on Stackoverflow
Solution 12 - AndroidByusaView Answer on Stackoverflow
Solution 13 - AndroidUmar PharoukView Answer on Stackoverflow