30

Just now I have installed and started working on Android Studio, and created new project after configuring everything I needed to start working on project. In newly created project, I have not changed anything and then tried to run the project. But it is not working and throwing some dependency error I guess. Here is it

Gradle: 
 FAILURE: Build failed with an exception.
  • What went wrong: A problem was found with the configuration of task ':StudioTest2:packageDebug'.

    File 'C:\Users\StudioTest2\StudioTest2\build\libs\StudioTest2-debug.dex' specified for property 'dexFile' does not exist.

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

    Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.

JNI_OnLoad
  • 5,472
  • 4
  • 35
  • 60
  • 1
    I have yet not tried Android Studio, but because it still is in preview release, several features are either incomplete or not yet implemented and you may therefore encounter bugs, which aren't necessarily your fault. – Janman May 16 '13 at 06:54
  • 8
    True, but atleast a simple hello world project should run even if it is preview release.. – JNI_OnLoad May 16 '13 at 06:56
  • This can happen when running on a JRE instead of a JDK. Studio ought to have warned you if this were the case, but it's still possible. Could you check what JVM it is running the build with? – Nick May 16 '13 at 08:59
  • I checked it, it is running on JDK only, I believe it is because of not getting some supported binary life at run time.. – JNI_OnLoad May 16 '13 at 09:04
  • No I have tried almost everything from given help and also filed the bug to their system (IntelliJ IDEA). if interested you can give it try also here is link http://confluence.jetbrains.com/display/IntelliJIDEA/Getting+Started+with+Android+Development – JNI_OnLoad May 17 '13 at 03:35
  • 3
    Could you run `gradlew packageDebug` from a commandline at the root of your project, and see if the output is any more enlightening? Possibly adding the suggested `--info` or `--debug` options for more detail. The `gradlew` script is within the created project so you shouldn't need to install anything to do this. – Nick May 18 '13 at 09:51
  • Nick, thank you for that answer, it helped me with this problem! – joe_deniable May 20 '13 at 19:56
  • My project suddenly wouldn't compile anymore, with error: Gradle: FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':Colorize:compileDebug'. > Compilation failed; see the compiler error output for details. – Moberg May 21 '13 at 04:20
  • @Moberg thats normal syntax error or something. Check IDE for errors. Not related to this issue. – Martin Nuc May 21 '13 at 08:15
  • The problem arised when I tried importing import org.jetbrains.annotations.NotNull; – Moberg May 22 '13 at 10:39
  • @Jeet Was there a solution for this? This is so annoying... – Terence Chow Aug 08 '13 at 01:18

12 Answers12

6

One thing I found that helped was to import the project after creating it, I was getting the same issue but once I imported the project (as opposed to just opening it), it built fine.

adefran83
  • 653
  • 7
  • 10
3

Any of the following may work:

1) clean project
2) File -> invalidate caches/ restart.
3) Restart computer.
4) See if some other project is compiling but not the current one. Notice the difference between the two and modify things in the current project if required.

I have wasted my 5 hours on this error.

Vasudev
  • 1,936
  • 19
  • 17
2

Install Android Studio to the default installer location. Something like C:\Users\<user>\AppData\Local\Android\android-studio. When you run it create your project again.

Martin Nuc
  • 5,604
  • 2
  • 42
  • 48
  • In my case I did this but also had to relocate the JDK to something that doesn't have a space in the path. Actually, I used Junction.exe (Google it) to create an alias to the program files directory from c:\dev\java_home, and changed %JAVA_HOME% to point to that. Problem solved. – Jon Davis Aug 20 '13 at 00:10
  • In my case it works with spaces in JDK path. Strange bug indeed. – Martin Nuc Aug 20 '13 at 00:58
1

I did not want to use the AppData location to store the program (although that would work), and none of the other solutions worked.

What ended up working was simply using a path that did not have spaces for my Android Studio install location.

For example, I was using:

E:/dev/Android Studio/

I then changed it to:

E:/dev/android-studio/

When I was using Fedora for development, applications compiled, and I noticed the application zip extracted to android-studio. Furthermore, using running gradle packageDebug within my project directory on windows did not work, even with --stacktrace --debug.

Further observations: This problem might not have anything to do with android studio. It might just be that the sdk folder in android-studio needs to be in a path without spaces.

I am under the impression that this would work for people using an alternate sdk location without spaces in the path.

Finally, projects not using build.gradle imported from eclipse worked just fine. Only projects created in android studio using gradle refused to compile and returned the curious dexFile packageDebug error.

Gradle projects now compile. Hope this helps someone.

youanden
  • 376
  • 2
  • 12
0

This error because something is going wrong that must be take in knowlegde.

First of all download the gradle from this link

Then Extract it to anywhere in your PC. After that Right click on My Computer icon --> Properties --> Advanced Setting --> Environment Variable --> System Variable

add the new path here like below.

Variable name : GRADLE_HOME. Variable Value : path to your gradle.

After that run command promt then type gradle check that it properly works.

Set path to your Project root directory which content gradlew file. After setting the path just type the folloeing command in your command promt.

gradle compileDebug

Hope this will helps you.

Jitesh Dalsaniya
  • 1,917
  • 3
  • 20
  • 36
0

Use your console to navigate to your project root directory where you will find gradlew script. run it with "compileDebug" option to see the exact error. There are other options to use as well, "gradlew help" will tell you more

Chris
  • 4,593
  • 1
  • 33
  • 37
0

I request apologizes about my bad English.

The solutions proposed did not worked in my case, but I managed to solve it myself.

My scenario was the following: created a project in an XP computer with eclipse, imported it to android studio, then I commited it to my SVN repository.

Later, I downloaded it to another computer with Windows 7 and Android Studio, and I obtained the discussed error (debug.dex' specified for property 'dexFile' does not exist).

I tried all the proposed solutions without sucess. What worked for me? Two steps:

  • first, correct the JDK path under "File->Project Structure->Project". At computer number I had JDK_1.6_016 and at computer number 2 I have JDK_7.

  • second: deleted (you can rename it if you dont want to delete it) the file "local.properties" in the project folder. It was pointing to the Android SDK folder in the Windows XP path style (documents and settings and so on instead of "users").

Then my project compiled with sucess.

Best regards.

Edited: better than deleting the file local.properties, edit it and correct the path to the android sdk file

R. Campos
  • 947
  • 1
  • 10
  • 26
0

I seem to face this problem when I try to run the project in debug mode. Then it starts giving Gradle errors. I try the menu option "invalidate cache restart", sometimes it works sometimes it doesn't. I just close the android studio and try to run it after a while later, it works. I'm not sure what's happening inside the software's brain.

Faraz Azhar
  • 562
  • 9
  • 28
0

What you need to do as Nick was saying on the comments above:

for windows users: open cmd as administrator and run:

gradlew.bat packageDebug

for unix like os:

go to the root directory of the project and run:

sudo gradlew packageDebug

In case you are getting errors you are missing some repos from maven.org go to /Applications/Android Studio.app/sdk/tools or the the android studio directory on Program files, and run android in unix or android.bat on windows.

0x90
  • 39,472
  • 36
  • 165
  • 245
0

i upgrade android studio from 0.3.1 to 0.3.2 and recreate project solved this problem.

travaller2
  • 351
  • 1
  • 2
  • 12
0

Updating to latest build tool and restarting studio fixed the issue for me

Jeevan
  • 8,532
  • 14
  • 49
  • 67
-2

Try this

Tools > Android > Monitor (DDMS included)

You will see SDK welcome message, and then go back to editor, and try to rebuild again.