330

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. Commented Jan 31, 2016 at 12:00
  • 8
    sucki android studio demands such silly questions to be upvoted.. :) Commented Apr 4, 2018 at 6:55
  • maybe it's the idea of IDEA to hide errors ideally (SCNR) Commented Nov 18, 2018 at 11:37
  • I have also same issue when i update plugin . I use Android Studio 3.4 Canary 6 Commented 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. Commented Jun 15, 2019 at 14:52

17 Answers 17

565

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.

Sign up to request clarification or add additional context in comments.

11 Comments

What Icon is that, I can't seem to find it, nor can I find a build window
It's sad that I had to google and dig through stackoverflow to find out how to see the compiler output. Thank you @boiledwater
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
There seems to be no such icon in AS 4.0
that Icon is missing on Android studio 4.0
|
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 Comments

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 Same problem here, I started a new question: stackoverflow.com/questions/17108393/…
Ok, I'm going to see what happens and reply in the new question if I find something.
I don't have that "messages make" panel... wtf?
I do not see these options now. I am running Android Studio 1.2.1.1
|
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 Comments

If it were really straightforward like you say, this thread wouldn't exist.
@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
In AS 4.0, I set this --stacktrace. But where is the output? That was the original question.
@SteveWhite in the output of the console while building.
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.
|
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 Comments

beautiful! Now if only that output could be integrated into the Android Studio
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.
"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
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.
19

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

enter image description here

2 Comments

@Pamblam Use ./gradlew
This is the only answer I found on this page that works in AS 4.0
18

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

enter image description here

Comments

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.

1 Comment

In Android Studio Giraffe | 2022.3.1 to see "build" command it should be manually enabled in Experimental Settings (Preferences -> Experimental -> Configure all Gradle tasks during Gradle Sync). However, after enabling and adding `--scan`` command line option I still can't see cause of the error
9

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

1 Comment

In AS 4.0, where is this Gradle Console?
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 Comment

I tried this in AS 4.0. I don't know were to look for any output it might have produced.
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 Comments

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.
I dont have gradlew installed am i supposed to install a third party app just to check logs
you don't need to install anything, the file [gradlew] exists in the project main directory just run it.
i missed this ( targetCompatibility JavaVersion.VERSION_1_8 ) thank you its work
5

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.

Comments

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 Comment

The question was not how to make the error go away. The question was how to see the error messages.
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 Comments

This is AS 4.0. It still fails the same way. No stacktrace.
Did you add the --stacktrack --debug --info flags ?
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.
1

Update 2023/2024: this is quite an old question, but for people having this issue in late 2023 the main conclusion from all the answers here and my personal experience is that it's an Android Studio bug that is unable, for some odd reason, to identify an unresolved import which causes the build to fail. The challenge here is to identify manually which import it is that's failing since your IDE friend is leaving you alone at the ring.

You will need to manually go over all of your recent changes backwards until the last point the compilation work and check your imports for a red one which can't be resolved and fix it.

There seems to be multiple reasons causing this issue but it seems to be generally speaking a rare one. For me I was dealing with a couple of conflicts harder than a usual fight between left and right wing political argument. For other people it will be some refactoring in Navigation Component that is not covered by traditional Android Studio refactoring mechanism. Quite annoying, but should not happen often.

1 Comment

This was the problem for me, though not the navigational component
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 Comment

This does not address the OP's question: how to see the compilation errors.
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.

Comments

-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 Comments

Where exactly is the line of code supposed to be added? Could you rephrase?
This does not answer the original question: how to see the compiler error messages.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.