25

I upgraded my windows and reinstalled Android studio 0.3.2. I am using windows8.1 Pro now and installed java x64, I also did set up JAVA_HOME EV to C:\Program Files\Java\jdk1.7.0_45 and Android studio is installed in D:\Android Stutio\

When I try to run my project I get the Following Error

Cannot run program "C:\Program Files (x86)\Java\jdk1.7.0_40\bin\java" (in directory "D:\Android Stutio\system\compile-server"): CreateProcess error=2, The system cannot find the file specified

Android studio is installed in D:\Android Stutio\

How to fix this one

dmSherazi
  • 3,743
  • 5
  • 37
  • 62
  • also I get this error `Failed to import Gradle project: Could not fetch model of type 'IdeaProject' using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.8-bin.zip'.` – dmSherazi Nov 09 '13 at 09:58
  • In case none of the other answers work, take a look here and let me know if this solves your problem: http://stackoverflow.com/a/27284746/3866013 (The problem might be your COMPSEC environtment variable) – d9n Dec 05 '14 at 01:15
  • That question is now more than a year old – dmSherazi Dec 05 '14 at 01:28
  • Sorry for the confusion. I was actually going to remove my comment here because re-reading your question, you were probably getting CreateProcess error=2 for a different reason. However, some users are still running into this problem now (see: https://code.google.com/p/android/issues/detail?id=79954), and I'm hoping to get the word out for such users - especially as the COMSPEC answer doesn't seem to show up anywhere when you Google for this problem. – d9n Dec 05 '14 at 02:06
  • 1
    I have faced this issue, This attached solution link is saved me. https://stackoverflow.com/a/50316120/1404798 – Thirumalvalavan May 15 '18 at 10:02

7 Answers7

29

Since android studio is still referring to jdk1.7.0_40 change its path

  1. Goto Files->Other Settings->Default Project Structure.

  2. Under Platform Settings Select Android sdk...under JDK location change C:\Program Files (x86)\Java\jdk1.7.0_40 to C:\Program Files\Java\jdk1.7.0_45

That should do the trick :)

user3235168
  • 316
  • 3
  • 4
3

Try the following: Open a new commandline (Win+R => cmd.exe) and enter "java". I predict that you'll get an error that says something like "command not found". The reason for this is that you don't have an windows environment variable set for your java.exe.

Do so by Win+X => System => Advanced System Settings => Advanced => Environment variables => search for PATH under the system variables => edit => append the path to your java.exe sperarated by ;

For example: ../other/pathes/with/file.exe;C:\Program Files (x86)\Java\jdk1.6.0_45\bin

Save,close,restart

muetzenflo
  • 5,653
  • 4
  • 41
  • 82
3

I got this same error on android studio 3.1 which I've just now updated. user3235168's answer worked for me.

Additionally I had to remove the check mark from 'Use embedded JDK(recommended)' Then browse to jdk's path - C:\Program Files\Java\jdk1.8.0_144

Abu Sufian
  • 41
  • 3
3

I hope this answer can be a reference for new comer!

I got same issue and I stuck for this error!

Finally I got solution here!

After I explore the error detail, I got message that there are issue with NDK. Try to disable NDK or add the following code in your gradle.build

packagingOptions{
    doNotStrip '*/mips/*.so'
    doNotStrip '*/mips64/*.so'
}
Ajie Kurniyawan
  • 393
  • 2
  • 18
2

proper solution of this

  1. Download old ndk from here

  2. Extract to your SDK file path like mine is H:\SDK\ndk-bundle16

  3. Now show it in gradle.properties folder.

Mahdi Younesi
  • 6,889
  • 2
  • 20
  • 51
Tab Soft
  • 21
  • 1
1

I am getting this because of ndk path .

Check the ndk path in local.properties file & also check the sdk path . Delete the build file , sometimes it makes the error in case you are migrating the project from Linux to windows or vice versa .

Then click invalidate cache and restart .

Mine this solved this issue . Hope this will help you .

RANAJEET BARIK
  • 185
  • 2
  • 7
-1

I had exactly the same error: CreateProcess error=2, The system cannot find the file specified [Android studio] No changes, just started Android Studio (3.6.2) in the morning and the bug appeared.

Anyway, I fixed this one by reinstalling Android Studio from scratch. I know it sounds stupid, but neither option worked for me, I just didn't have another hour to play with it.

Andrew
  • 2,438
  • 1
  • 22
  • 35