错误:在 Android SDK 中找不到 gradle 包装器.可能需要更新您的 Android SDK - Android [英] Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK - Android
问题描述
我知道有很多与此类似的问题,但我无法在其中任何一个问题中找到解决方案.此外,我将提供我的具体案例的详细信息.
I know there are lots of questions similiar to this one, but i couldn't find a solution for my problem in any of those. Besides, I'll provide details for my specific case.
我在 Ubuntu 16.04 LTS 中编写了一个 Ionic 项目,现在我必须构建它以进行发布.所以我运行命令:
I coded an Ionic project in Ubuntu 16.04 LTS, and now I have to build it for release. So I run the command:
cordova build --release android
我看到了以下错误:
Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
Looked here: /home/user/Android/Sdk/tools/templates/gradle/wrapper
- 我没有这个
templates/gradle/wrapper
目录. - 我的 Android Studio 是 2.3,目前是最新版本
- Android SDK 平台工具 25.0.3
- Android SDK 工具 25.3.1
- 从 2.1 (Eclair) 到 7.1.1 (Nougat) 的所有 Android 版本
经过大量研究,我将所有与 Android Studio 相关的环境变量放在文件 /etc/environment
中.所以现在看起来像这样:
After extensive research, I put all the Android Studio-related environment variables in the file /etc/environment
. So now it looks like this:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/game:/home/<user>/Android/Sdk:/home/<user>/Android/Sdk/tools:/home/<user>/Android/Sdk/platform-tools"
ANDROID_HOME=/home/<user>/Android/Sdk
export ANDROID_HOME
JAVA_HOME=/usr/lib/jvm/java-8-oracle
export JAVA_HOME
GRADLE_HOME=/opt/android-studio/gradle/gradle-3.2
export GRADLE_HOME
现在,为了测试环境变量,我运行以下命令:
Now, for the sake of testing the environment variables, I run the following commands:
source /etc/environment
echo $PATH
echo $ANDROID_HOME
echo $JAVA_HOME
echo $GRADLE_HOME
并且所有路径变量都正确显示.
And all the path variables are correctly displayed.
所以,根据各种类似的问题和我搜索过的教程,环境变量看起来应该是这样.有谁知道我做错了什么?为什么我仍然收到 Gradle Wrapper 错误?
推荐答案
我刚刚遇到了同样的问题.
I just experienced the same problem.
这可能是关于如何安装(或升级)Android Studio 和所有 SDK 工具的说明中的一个障碍,你和我都错过了,或者可能是由新版本的 Studio 创建的错误,它不遵循相同的文件约定为旧版本.我倾向于后者,因为许多 SO 帖子 在这个话题上似乎指向一个 ANDROID_PATH,其中有一个名为 android-sdk 的文件夹,它没有出现在最新的 (2.3.0.8) 版本中.
It may be an occlusion in the instructions regarding how to install (or upgrade) Android Studio with all the SDK Tools which both you and I missed or possibly a bug created by a new release of Studio which does not follow the same file conventions as the older versions. I lean towards the latter since many of the SO posts on this topic seems to point to an ANDROID_PATH with a folder called android-sdk which does not appear in the latest (2.3.0.8) version.
似乎有一种解决方法,我刚开始在我的机器上工作.这是我所做的:
There appears to be a workaround though, which I just got to work on my machine. Here's what I did:
从 Android 下载.
在桌面上提取的 zip
Extracted zip on desktop
用提取的替换 C:UsersusernameAppDataLocalAndroidsdk ools子文件夹工具/
Replaced C:UsersusernameAppDataLocalAndroidsdk ools with extracted sub-folder tools/
在项目文件夹中:
$cordova 平台移除 android
$cordova 平台添加 android
$ cordova platforms remove android
$ cordova platforms add android
您可能还需要强制删除 android 中的 node_modules.希望这会有所帮助.
You may also need to force remove the node_modules in android. Hopefully this helps.
这篇关于错误:在 Android SDK 中找不到 gradle 包装器.可能需要更新您的 Android SDK - Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!