69

When I try to run an Android emulator, I get the following error screen. The same occurs when I export the apk. When I go to the directory where the apk will be saved, the apk file is not there.

Thank you,
christophe

enter image description here

Daryl Bennett
  • 462
  • 10
  • 22
user3142817
  • 787
  • 2
  • 9
  • 15
  • 2
    What happens if you run `gradlew clean build` from the command line? – Bryan Herbst Dec 10 '14 at 18:08
  • from the terminal? "gradlew not recognize" – user3142817 Dec 10 '14 at 19:02
  • Are you in your project's root? Are you using the Gradle wrapper? If you're using a local Gradle distribution, try `gradle clean build`. – Bryan Herbst Dec 10 '14 at 19:04
  • i am new white android studio, i come from eclipse. a long time ago i have made a app in eclipse but i have delete all the files. now i want do it again but eclipse not working, so i come to android studio. – user3142817 Dec 10 '14 at 19:09
  • It seems that there's quite a lot of the similar question. Check out my answer here and see if it helps: http://stackoverflow.com/a/31447763/3338439 – Mingsheng Oct 22 '15 at 16:16
  • 1
    If you get a "gradlew not recognize", simply append the "./" it will look like `./gradlew clean build` – Herb Meehan Nov 27 '15 at 06:32
  • Hello guys please add '--offline' in vm option then hit apply and ok. also restart AS through file>Invalidate Cached/Restart option. That's it. this works for me. – Sandeep Devhare Aug 05 '16 at 05:22

19 Answers19

82

I had the same issue, this problem will be fixed by doing the below step.

Go to

File->Setting->Gradle->Gradle Vm Option

For Android Studio 1.2

File->Setting->Build, Deployment &Execution->Build Tools->Gradle->Gradle Vm Option

, Now put this value -Xmx256m in the box, and hit the Apply button.

Crawler
  • 1,988
  • 3
  • 21
  • 42
A J
  • 3,684
  • 2
  • 19
  • 24
26
  1. Click "Gradle Console" for the log from Gradle.
  2. Debug from the error messages
    • Mac: In Android Studio, go to:
      • "Preference"
      • "Build, Execution, Deployment"
      • "Compiler"
      • Add "--stacktrace" to "Command-line Options"

Note the error will usually be listed as the first line (improperly formatted for Android Studio Gradle console such as:

AGPBI: {"kind":"error","text":"Float types not allowed (at \u0027icon_alpha_active\u0027 with value \u00270.75\u0027).","sources":[{"file":"/Users/mingsheng/path/to/my/errenous/integers.xml","position":{"startLine":5,"startColumn":38,"startOffset":272,"endColumn":42,"endOffset":276}}],"original":""}

Where "text" = error message, "sources: file" = errenous filepath/name

In this example, I have entered a Float value in the integers file.

Mingsheng
  • 1,031
  • 10
  • 16
  • Best answer imo, because if layout view isn't detecting errors, as in my case, the possible layout problems are too numerous to know without the log. For instance, my preview was rendering fine, no typos, but two elements were the wrong way round. – LordParsley Jul 22 '15 at 12:19
  • I had an issue in one of my layout files which crashed the gradle process. Thanks to this tip I could find it in no time and gradle finished. – KeepAlive Aug 19 '15 at 10:41
19

This dialog box with empty cause also comes when there is some error in your resource(res) directory. Check for any error in layout files etc.

sv_jan5
  • 1,543
  • 16
  • 42
  • 1
    That's was my case! Had a typo in a hex color value "##FF33DD" – Thalis Vilela Jun 23 '15 at 21:20
  • Verify your XML files. Likely one line is causing the error. For me, (not sure why) but it was caused by a fragment layout line: android:layout_bottom="@id/my_list" Simply switching from this line from one fragment to use layout_top on another fragment solved it...... retarded i know – Mingsheng Jul 08 '15 at 14:45
  • 1
    Check your `.xml` files for any type of errors. I was using a `drawable` file which is deleted from `drawable` folder. – Prabs Feb 11 '16 at 07:11
6

I had this issue too. It caused by mistake in dimens.xml (git helps me found it).

I used

<dimen name="map_search_view_top_margin">100</dimen>

instead

<dimen name="map_search_view_top_margin">100dp</dimen>

Hope it helps.

SiavA
  • 424
  • 5
  • 12
5

This is a mistake somewhere in your xml files. Check

values.xml
colors.xml
strings.xml
dimens.xml

Something wrong with opening closing bracket or something you missed in these files.

Viktor Petrovski
  • 796
  • 5
  • 14
  • This was what worked for me. Some of the other answers might be part of it, but in my case it was a bad tag in a layout. I wish the message was less cryptic. – sigmazero13 Apr 13 '16 at 22:30
1

Honestly speaking, to me none of the above solutions worked and i almost fought over this for 3 days. Finally ultimate solution was to backup my project, uninstall studio and its trace files completely, clear files from temp, %temp% and prefetch folders and then reinstall all over again and finally it worked.

Pls discard my above answer which i taught was one of the solutions. I faced this problem repeatedly because 1 of my teammate forgot to include git.ignore file while pushing code to bitbucket and everytime i used to pull that code and then gradle used to pop the above problem. And after figuring out that, i have added proper git.ignore file and now there's no any problem on any1's pc :)

Amit Tumkur
  • 2,752
  • 26
  • 27
1

I am often getting that error when I have a typo in my xml. Open the gradle console and scroll up to the first red lines that appear. It will tell you the exact problem.

Bella Yordanova
  • 133
  • 1
  • 6
1

I have this problem, too. I used Gradle v.1.3.1 but Android Studio version is v1.2.2. Just update Android Studio to v.1.3.2 solved my problem.

Simon Pan
  • 76
  • 5
0

In my case the root of the problem was, I deleted some resources that some xml files were refering to, and in that case neither of "Clear Project" "Rebuild Project" "Gradle VM Option" or "deleting .gradle folder" helped at all.

What more to say is, none of the mentioned xml files were in use, and no error was displayed anywhere. I only detected the problem when (in desperate) sync'ed Gradle, and then opened the Gradle console and scrolled up and read the red error lines.

Mr. Kro
  • 138
  • 9
0

None of the solutions worked for me. So I found this solution here:

My Android Studio was using JDK 1.8, so I switched back to JDK 1.7 and now it is working!

Go to

File > Project Structure > SDK Location

I had JDK Location set as jdk1.8.0_05. I just changed it to jdk1.7.0_79 and everything works fine now.

Rodrigo Venancio
  • 1,284
  • 1
  • 12
  • 17
0

I had the same issue. After an hour of struggle, it's finally fixed.

First I updated Android Studio to 1.3.2. That did not fix the problem immediately, but at least it gave a proper error when trying to run the application.

(for me, there was something wrong with JAR dependencies so I removed them and it's running now, but that's probably irrelevant)

Iman Akbari
  • 2,167
  • 26
  • 31
0

When you have an error like this. Just move to your BOTTOM RIGHT corner of the screen there is something known as GRADLE CONSOLE open that and read what went wrong. That helped me.

Sagar Devanga
  • 2,815
  • 27
  • 30
0

Try to upgrade your android studio, and when you run your project again, it will tell you where the problem is.

For me, I encountered this problem several times, the first time is something wrong with the style.xml, and the second time is string.xml file. Anyway, It seems Android studio could not find something wrong with .xml file.

But anyway, try to "refresh" your Android studio and let it tell you where are the problems, even reinstall it.

good luck!

RobotCharlie
  • 1,180
  • 15
  • 19
0

I had the same problem, and the problem was gone after upgrading my Android Studio from 1.2.1 to 1.5.1. There was no error even after adding --stacktrace --info to VM options. Gradle tasks would finish successfully, but the application just wouldn't launch (and studio would gray out the run button forever, probably waiting for a response from emulator). I had tried everything else mentioned here.

n0rm1e
  • 3,796
  • 2
  • 28
  • 37
0

On newer version of AS 2.0 File->Setting->Build, Deployment &Execution-Compilers->Android Compilers->Gradle->Gradle Vm Option

put this as an option -Xmx256m

vishal dharankar
  • 7,536
  • 7
  • 57
  • 93
0

This can be because you have specified any command line option in android studio settings. You can check this by going to

File > Settings > Build, Execution, Deployment > Compiler

and see "Command-line-options" and check if anything is give. (In your case -x). If so remove it and click Apply and Ok. It worked for me...

Jasmine John
  • 873
  • 8
  • 12
0

I accidentally deleted string from string.xml and I didn't know it was specified in manifest for activity name, so spent one hour to discovered that out

blackHawk
  • 6,047
  • 13
  • 57
  • 100
0

I cleaned up the project, tried again and the problem was gone.

-1

I had a "Run" problem in Android Studio due to multiple instances of Android Studio were opened. So I closed all instances and opened only on instances for which I wanted to generate APK.And It worked well. May be it had a problem with RAM.

Kush Patel
  • 1,228
  • 1
  • 13
  • 34