java Android studio jdk 和 gradle 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30750317/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 17:35:55  来源:igfitidea点击:

Android studio jdk and gradle errors

javaandroidandroid-studio

提问by End.Game

It's about the 10 time i try to install and run Android Studio but i have always a problem! I can't work with it! But i want to migrate from Eclipse. I solved a problem that not recognized the sdk path, i solved the problem that not recognized my device and then i have another two propblems!

这大约是我尝试安装和运行 Android Studio 的 10 次,但我总是遇到问题!我不能用它!但我想从 Eclipse 迁移。我解决了一个无法识别 sdk 路径的问题,我解决了无法识别我的设备的问题,然后我还有另外两个问题!

1)Error:Gradle version 1.10 is required. Current version is 2.2.1. If using the gradle wrapper

1) 错误:需要 Gradle 1.10 版。当前版本是 2.2.1。如果使用 gradle 包装器

2)Error:The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: C:\Users\Admin\Desktop\adt-bundle-windows-x86_64-20140702\sdk\bin\java.exe

2) 错误:提供的 javaHome 似乎无效。我找不到 java 可执行文件。尝试过的位置:C:\Users\Admin\Desktop\adt-bundle-windows-x86_64-20140702\sdk\bin\java.exe

And i can't solve them. The second one it's incredible!!! I don't have the jdk there! I set the jdk path in Project Structureand the jdk location is:

而我无法解决它们。第二个太不可思议了!!!我那里没有jdk!我在Project Structure中设置jdk路径,jdk位置为:

C:\Program Files\Java\jdk1.7.0_71

C:\Program Files\Java\jdk1.7.0_71

Anyone can help me please?

任何人都可以帮助我吗?

回答by Garima Mathur

Solution of first is:

第一种解决方法是:

You have to change this line in build.gradle (this is the gradle plugin for Android)

您必须在 build.gradle 中更改这一行(这是 Android 的 gradle 插件)

classpath 'com.android.tools.build:gradle:1.1.+'

The version of Android gradle plugin needs to be compatible with the version of Gradle.

Android gradle 插件版本需要与Gradle 版本兼容。

Make sure the distributionUrl is specified as gradle-1.10-all.zip at the Gradle-wrapper properties file within the Android project.

确保在 Android 项目中的 Gradle-wrapper 属性文件中将 distributionUrl 指定为 gradle-1.10-all.zip。

This line in gradle-wrapper.properties (this is the gradle version)

gradle-wrapper.properties 中的这一行(这是 gradle 版本)

distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip

enter image description here

在此处输入图片说明

Solution of second is:

第二个解决办法是:

  1. if you do not have JAVA_HOME Variable into environment variables then
  1. 如果您没有将 JAVA_HOME 变量设置为环境变量,则

Set the JAVA_HOME Variable

设置 JAVA_HOME 变量

Once you have the JDK installation path:

一旦你有了 JDK 安装路径:

Right-click the My Computer icon on your desktop and select Properties. Click the Advanced tab. Click the Environment Variables button. Under System Variables, click New. Enter the variable name as JAVA_HOME. Enter the variable value as the installation path for the Java Development Kit. Click OK. Click Apply Changes.

右键单击桌面上的“我的电脑”图标,然后选择“属性”。单击高级选项卡。单击环境变量按钮。在系统变量下,单击新建。输入变量名作为 JAVA_HOME。输入变量值作为 Java Development Kit 的安装路径。单击确定。单击应用更改。

  1. If you have JAVA_HOME value then
  1. 如果你有 JAVA_HOME 值,那么

Change the value of environment variable JAVA_HOME to C:\Program Files (x86)\Java\Jre7\ instead of C:\Program Files (x86)\Java\Jre7\bin\java.exe

将环境变量 JAVA_HOME 的值更改为 C:\Program Files (x86)\Java\Jre7\ 而不是 C:\Program Files (x86)\Java\Jre7\bin\java.exe

JAVA_HOME should be always pointing to the parent directory of JDK or JRE installation inside of which, we find the bin directory containing the java, javac, etc. binaries

JAVA_HOME应该一直指向JDK或JRE安装的父目录,在里面,我们找到bin目录下有java、javac等二进制文件