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?

Pang
  • 9,564
  • 146
  • 81
  • 122
ChaseTheSun
  • 3,810
  • 3
  • 18
  • 16

16 Answers16

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.

outis
  • 75,655
  • 22
  • 151
  • 221
boiledwater
  • 10,372
  • 4
  • 37
  • 38
  • Nice to see that so many has voted for this answer, and Android Studio 3.1 is still in beta 3. :-) – Ove Stoerholt Feb 22 '18 at 13:14
  • 19
    What Icon is that, I can't seem to find it, nor can I find a build window – Sam Mar 15 '18 at 04:45
  • 10
    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 '18 at 13:21
  • 1
    @shikharbansal in case the image link ever breaks again, the icon is on the left edge of the build window. It looks kind of like a list view separated from "ab" by a slash. – Max Aug 14 '18 at 19:41
  • 6
    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 '18 at 02:26
  • I am android programmer for two years and I never knew this exists – Ahmed Ali Nov 26 '18 at 14:47
  • Thank you so much, I have been struggling with this issue for like four months... Million thanks, – amira Dec 03 '18 at 18:44
  • Thanks bro, finally among the many answers your answer saved me:) – anoop ghildiyal Aug 19 '19 at 12:51
  • 9
    There seems to be no such icon in AS 4.0 – Steve White Jun 16 '20 at 09:45
  • 8
    that Icon is missing on Android studio 4.0 – Niroshan Jun 24 '20 at 11:25
  • 1
    in AS 4.0, that icon is AWOL. It seems we are left to manually run the offending Gradle Task from the Gradle Tasks pane, then the Build log will display the log that the previous build log was referring to o.0 – straya Jul 17 '20 at 02:17
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

Jorge Fuentes González
  • 11,568
  • 4
  • 44
  • 64
  • 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 '13 at 10:09
  • 3
    @Moberg Same problem here, I started a new question: http://stackoverflow.com/questions/17108393/android-studio-disabling-external-build-to-display-error-output-create-duplic – Waza_Be Jun 14 '13 at 12:30
  • Ok, I'm going to see what happens and reply in the new question if I find something. – Jorge Fuentes González Jun 14 '13 at 21:11
  • 7
    I don't have that "messages make" panel... wtf? – maxgalbu Jun 20 '13 at 16:52
  • Thanks. I found an easier way to open the compiler options window: just go to preferences -> compiler, it's the same window – maxgalbu Jun 20 '13 at 17:18
  • 9
    I do not see these options now. I am running Android Studio 1.2.1.1 – Andrew S May 29 '15 at 06: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

Antonio
  • 11,413
  • 6
  • 34
  • 48
  • 15
    If it were really straightforward like you say, this thread wouldn't exist. – jungledev Jan 18 '19 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 '19 at 12:13
  • 1
    In AS 4.0, I set this --stacktrace. But where is the output? That was the original question. – Steve White Jun 16 '20 at 09:44
  • @SteveWhite in the output of the console while building. – Antonio Jun 17 '20 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. – Steve White Jun 21 '20 at 13:46
  • Oh, thanks for letting me know @SteveWhite. Maybe my solution is already out-of-date and not working. I haven't tried it myself lately, but if I come to do it again, I'll update this answer if needed – Antonio Jul 06 '20 at 10:19
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.

Hadi Kocabas
  • 429
  • 3
  • 4
  • 13
    beautiful! Now if only that output could be integrated into the Android Studio – ChaseTheSun May 19 '13 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. – Hadi Kocabas May 19 '13 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 '13 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. – Jerry Brady Oct 21 '13 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

RominaV
  • 3,335
  • 1
  • 29
  • 59
18

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

enter image description here

live-love
  • 48,840
  • 22
  • 240
  • 204
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.

kittykittybangbang
  • 2,380
  • 4
  • 16
  • 27
9

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

cahit beyaz
  • 4,829
  • 1
  • 30
  • 25
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

jai
  • 321
  • 3
  • 9
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

Falah H. Abbas
  • 512
  • 5
  • 11
  • 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. – Steve White Jun 16 '20 at 09:33
  • I dont have gradlew installed am i supposed to install a third party app just to check logs – nikoss Jul 24 '20 at 20:53
  • you don't need to install anything, the file [gradlew] exists in the project main directory just run it. – Falah H. Abbas Jul 27 '20 at 06:34
  • 1
    i missed this ( targetCompatibility JavaVersion.VERSION_1_8 ) thank you its work – MohammadReza Sep 17 '20 at 06: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.

Jan Málek
  • 531
  • 8
  • 21
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.

Logesh R
  • 185
  • 2
  • 9
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.

  • This is AS 4.0. It still fails the same way. No stacktrace. – Steve White Jun 16 '20 at 09:27
  • Did you add the --stacktrack --debug --info flags ? – Peterstev Uremgba Jun 17 '20 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. – Steve White Jun 17 '20 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

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.
oyeraghib
  • 878
  • 3
  • 8
  • 26
-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'