327

When I 'Run' my project in Android Studio, in the 'Messages' window, I get:

Gradle: 
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':play01:compileDebug'.
> Compilation failed; see the compiler error output for details.

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

It says > Compilation failed; see the compiler error output for details. So where is the "compiler error output"? And/Or how do I run with --stacktrace option?

5
  • 2
    I run Android Studio 1.3.2 and none of the solutions work. Jan 31, 2016 at 12:00
  • 8
    sucki android studio demands such silly questions to be upvoted.. :)
    – Siddharth
    Apr 4, 2018 at 6:55
  • maybe it's the idea of IDEA to hide errors ideally (SCNR)
    – bebbo
    Nov 18, 2018 at 11:37
  • I have also same issue when i update plugin . I use Android Studio 3.4 Canary 6 Dec 5, 2018 at 12:53
  • I have also faced this issue. In my case, The problem lie in entity class data. If your data members are private them must create getter and setter methods. Due to this method other binding issues are coming. Jun 15, 2019 at 14:52

16 Answers 16

564

For Android Studio 3.1, select the icon below the Build one in the Build window.

Android Studio 3.1 raw log toggle button

By Android Studio 3.3 (possibly in 3.2.1), the icon has changed, though the location is the same:

Android Studio 3.3 raw log toggle button

The build window should open when you run a build action (e.g. from the Build menu). If you don't see it, you can try the "Build" button along the bottom of the window (also visible in the above screenshots), or through the menus View → Tool Windows → Build.

11
  • 19
    What Icon is that, I can't seem to find it, nor can I find a build window
    – Sam
    Mar 15, 2018 at 4:45
  • 9
    It's sad that I had to google and dig through stackoverflow to find out how to see the compiler output. Thank you @boiledwater
    – spartygw
    Jul 30, 2018 at 13:21
  • 5
    Android's IDE simply says "toggle view".. toggle view of what ? +1 for this answer. Google still doing their best to obscure workflow for developers
    – angryITguy
    Sep 13, 2018 at 2:26
  • 8
    There seems to be no such icon in AS 4.0 Jun 16, 2020 at 9:45
  • 7
    that Icon is missing on Android studio 4.0
    – Niroshan
    Jun 24, 2020 at 11:25
66

This answer is outdated. For Android 3.1 Studio go to this answer

One thing you can do is deactivate the external build. To do so click on "compiler settings icon" in the "Messages Make" panel that appears when you have an error. You can also open the compiler settings by going to File -> Settings -> Compiler. (Thanx to @maxgalbu for this tip).

enter image description here

Uncheck "Use External build"

enter image description here

And you will see the errors in the console

EDIT: After returning to "internal build" again you may get some errors, you can solve them this way: Android Studio: disabling "External build" to display error output create duplicate class errors

6
  • Unchecking "Use External Build" introduces two errors when I try to build my project: error: duplicate class: com.moberg.colorgame.BuildConfig and error: duplicate class: com.moberg.colorgame.R
    – Moberg
    Jun 14, 2013 at 10:09
  • 3
    @Moberg Same problem here, I started a new question: stackoverflow.com/questions/17108393/…
    – Waza_Be
    Jun 14, 2013 at 12:30
  • Ok, I'm going to see what happens and reply in the new question if I find something. Jun 14, 2013 at 21:11
  • 7
    I don't have that "messages make" panel... wtf?
    – maxgalbu
    Jun 20, 2013 at 16:52
  • 9
    I do not see these options now. I am running Android Studio 1.2.1.1
    – Andrew S
    May 29, 2015 at 6:27
47

It's really straightforward to set up! Just go to the Compiler settings at Android Studio 2.2.3 and set the --stacktrace command:

Compiler settings to add --stacktrace command

Then run the app again

6
  • 15
    If it were really straightforward like you say, this thread wouldn't exist.
    – jungledev
    Jan 18, 2019 at 12:07
  • 2
    @jungledev it's really straightforward to set up, but it is not too obvious to know it :) Changing wording in my answer to make this clear
    – Antonio
    Jan 18, 2019 at 12:13
  • 1
    In AS 4.0, I set this --stacktrace. But where is the output? That was the original question. Jun 16, 2020 at 9:44
  • @SteveWhite in the output of the console while building.
    – Antonio
    Jun 17, 2020 at 18:00
  • Antonio, the expected output never appeared in the build console for me. I had to run gradlew by hand, as explained elsewhere on this page. Jun 21, 2020 at 13:46
32

Are you on Windows? Launch cmd, find your project folder and run "gradlew build". This should already give you more output than the IDE, you can also use --info, --stacktrace and --debug there.

4
  • 13
    beautiful! Now if only that output could be integrated into the Android Studio May 19, 2013 at 12:02
  • 4
    My thoughts exactly. An IDE without a window for compiler errors? I bet we are missing something, but this workaround should be enough until that's addressed. May 19, 2013 at 13:09
  • 4
    "Are you on windows?" - This also works under Ubuntu Linux too! Thanks! /[folder-where-you-installed-the-android-studio]/sdk/tools/templates/gradle/wrapper/gradlew build
    – geekQ
    Jul 15, 2013 at 12:37
  • I'm in the process of migrating a huge project from Eclipse to Android Studio. Best advise so far: get the command line gradle build working first, then worry about the new IDE. Oct 21, 2013 at 20:19
18

In my case I prefer to open the Terminal window on the bottom left, and run gradlew build --info :

enter image description here

2
  • 5
    @Pamblam Use ./gradlew
    – Rhys
    Aug 31, 2016 at 17:25
  • 1
    This is the only answer I found on this page that works in AS 4.0 Jun 16, 2020 at 9:49
18

You can also see the error in the Build window by clicking on the toggle button.

enter image description here

0
12

For Android Studio v4.0

As others have mentioned, the "Messages" window that was evidently present in AS 3.* no longer exists in 4.0 (or else it's hidden very, very well). After wasting far too much time on this, I've found another way to view those compile errors:

  1. Open your Gradle tool window. By default, it's on the right edge toward the top:

enter image description here

If you don't see it there, use View > Tool Windows > Gradle.

  1. In the Gradle window, open your app's root option and run Tasks > build > build:

enter image description here

  1. The Run tool window should open automatically, where you'll see details about the cause of the build error:

enter image description here

If it doesn't open automatically, you can access it through View > Tool Windows > Run.

Hopefully that gives you all the info you need. If not though, try:

  1. Go to File > Settings > Build, Execution, Deployment > Compiler. In the Command-line Options, add --scan.

enter image description here

Apply and OK, then try the Gradle build over again.

9

In android studio 2.2.3 you can find output in the gradle console as shown below gradle console

1
  • 3
    In AS 4.0, where is this Gradle Console? Jun 16, 2020 at 9:39
6

I am building on what Jorge recommended. Goto File->Settings->compiler.

Here you will see a field to add compiler options where you plug in --stacktrace

1
  • I tried this in AS 4.0. I don't know were to look for any output it might have produced. Jun 16, 2020 at 9:39
5

Run

gradlew --stacktrace 

in a terminal to see the full report

for me it was

Task :app:compileDebugJavaWithJavac FAILED javacTask: source release 1.8 requires target release 1.8

so i added

 compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

in app.gradle file / android and the build completed successfully

4
  • When I do this in a terminal (within the project folder), it says BUILD SUCCESSFUL But when I build with Build -> Make Project, I see the same notice that there were compilation errors. Jun 16, 2020 at 9:33
  • I dont have gradlew installed am i supposed to install a third party app just to check logs
    – nikoss
    Jul 24, 2020 at 20:53
  • you don't need to install anything, the file [gradlew] exists in the project main directory just run it. Jul 27, 2020 at 6:34
  • 1
    i missed this ( targetCompatibility JavaVersion.VERSION_1_8 ) thank you its work Sep 17, 2020 at 6:11
4

Just click on the "Build" node in the Build Output

enter image description here

From some reason the "Compilation failed" node just started being automatically selected and for that the description window is very unhelpful.

1

If you are in android studio 3.1, Verify if file->Project Structure -> Source compatibility is empty. it should not have 1.8 set.

then press ok, the project will sync and error will disappear.

1
  • The question was not how to make the error go away. The question was how to see the error messages. Jun 16, 2020 at 9:29
1

In my case i had a findViewById reference to a view i had deleted in xml

if you are running AS 3.1 and above:

  1. go to Settings > Build, Execution and Deployment > compiler
  2. add --stacktrace to the command line options, click apply and ok
  3. At the bottom of AS click on Console/Build(If you use the stable version 3.1.2 and above) expand the panel and run your app again.

you should see the full stacktrace in the expanded view and the specific error.

3
  • This is AS 4.0. It still fails the same way. No stacktrace. Jun 16, 2020 at 9:27
  • Did you add the --stacktrack --debug --info flags ? Jun 17, 2020 at 10:03
  • Sure. But that wasn't the problem. The problem (near as I can tell) there is no longer a window where the stack trace appears. However, it is possible to run gradlew by hand in a terminal to get the info. In another comment on this page, I said which method worked. Jun 17, 2020 at 13:49
0

after the convert android to androidx.

change Import library problem will sol. Like this:

import androidx.appcompat.widget.Toolbar;  <<  like this

import androidx.annotation.NonNull; << like this

import androidx.appcompat.app.ActionBarDrawerToggle; << like this

import androidx.drawerlayout.widget.DrawerLayout; << like this

import androidx.recyclerview.widget.RecyclerView; << like this

import androidx.appcompat.app.AppCompatActivity; << like this

1
  • This does not address the OP's question: how to see the compilation errors. Jun 16, 2020 at 9:28
0

Follow these steps!

  1. Go to File

  2. Then click on Settings

  3. Then under "Build, Execution, Deployment" go to Compiler

  4. Add this in "Command-line Options" and press OK enter image description here

  5. Now normally run your test/app again and when you will encounter error this time, you will see highlighted messages like this : enter image description here

  1. Clicking on "Run with --scan" or "Run with --stacktrace" will give error in more detail.
-3

I solved this error "Compilation failed to see the compiler error output for details"

The solution is very Simple: Add in a Gradle below a line of code

implementation 'com.google.android.gms:play-services-ads:15.0.0'

2
  • Where exactly is the line of code supposed to be added? Could you rephrase? May 7, 2019 at 10:17
  • This does not answer the original question: how to see the compiler error messages. Jun 16, 2020 at 9:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.