The above problem is mainly the Java path problem, here is the main solution, as for why so solve, you can learn the bat language. If you want to ask me, you can leave a message.
Dx.bat according to the installation directory, my is D:\Program Files (x86) \android\android-studio\sdk\build-tools\android-4.2.2\dx.bat. Then open with a notebook, in the 29~33 line (I use the edit plus,txt may not be the actual number of rows, we can find the following corresponding on the line).
Then replace the following code with the
------------------------the original Code---------------------------------------
REM Check we have a valid Java.exe in the path.
Set java_exe=
if exist. \tools\lib\find_java.bat call. \tools\lib\find_java.bat
if exist. \.. \tools\lib\find_java.bat call. \.. \tools\lib\find_java.bat
If not defined Java_exe goto:eof
---------------------------------------------------------------------
Replaced by
----------------------------------------------------------------------
REM Check we have a valid Java.exe in the path.
Set java_exe= "C:\Program Files (x86) \java\jdk1.6.0\bin\java.exe"
if exist. \tools\lib\find_java.bat call. \tools\lib\find_java.bat
:: if exist.. \.. \tools\lib\find_java.bat call. \.. \tools\lib\find_java.bat
:: If not defined Java_exe goto:eof
----------------------------------------------------------------------
Then find the Android.bat file under \android\android-studio\sdk\tools. 35~38 line code, as follows:
------------------------the original Code---------------------------------------
REM Check we have a valid Java.exe in the path.
Set java_exe=
Call Lib\find_java.bat
If not defined Java_exe goto:eof
--------------------------------------------------------------------
Replaced by
------------------------the original Code---------------------------------------
REM Check we have a valid Java.exe in the path.
Set java_exe= "C:\Program Files (x86) \java\jdk1.6.0\bin\java.exe"
:: Call Lib\find_java.bat
:: If not defined Java_exe goto:eof
--------------------------------------------------------------------
The above "C:\Program Files (x86) \java\jdk1.6.0\bin\java.exe" is my JDK installation path, just modify it. I wish you success!
[Turn] Gradle: There should be no androidandroid-studiosdk oolslib\find_java.exe at this time. Workaround