错误:无法在Android Studio或系统上找到已安装的Gradle版本以安装gradle包装器(Error: Could not find an installed version of Gra

编程入门 行业动态 更新时间:2024-10-27 09:39:30
错误:无法在Android Studio或系统上找到已安装的Gradle版本以安装gradle包装器(Error: Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper)

我用cordova开发了一个混合应用程序。 当我试图构建我的应用程序的android版本时,我收到此错误:

错误:无法在Android Studio或系统上找到已安装的Gradle版本以安装gradle包装器。 请在您的路径中包含gradle,或安装Android Studio。

..尽管已经安装了Android Studio,但到目前为止一切正常。

有人知道这个问题的原因吗?

I develop a hybrid app usin cordova. While I was trying to build the android verion of my App, i got this error:

Error: Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper. Please include gradle in your path, or install Android Studio.

..although Android Studio is already installed and everything worked so far.

Does anybody know the reason for this issue?

最满意答案

问题出在文件:\ cordova \ lib \ check_reqs.js当cordova检查graddle的位置时这样做:var androidPath = path.join(process.env ['ProgramFiles'],'Android')+'/' ;

如果您没有安装在某个位置,则cordova无法找到该文件。 所以...编辑tcheck_reqs.js并执行此操作(我使用的是Windows 10和cordova 7.0.1):

return 'C:\\Android\\sdk\\gradle\\gradle-3.2\\bin\\gradle'; if (androidStudioPath !== null && fs.existsSync(androidStudioPath)) { var dirs = fs.readdirSync(androidStudioPath); if(dirs[0].split('-')[0] == 'gradle') { return path.join(androidStudioPath, dirs[0], 'bin', 'gradle'); } } else { //OK, let's try to check for Gradle! return forgivingWhichSync('gradle'); }

这不是一个真正的修复,但如果你确定你的gradle位置它会没事,希望cordova解决这个问题。

The problem is in the file: \cordova\lib\check_reqs.js When cordova checks the location of graddle is doing this: var androidPath = path.join(process.env['ProgramFiles'], 'Android') + '/';

If you don't have installed in certain location, cordova can't find the file. So... edit tcheck_reqs.js and do this (i'm using Windows 10 and cordova 7.0.1):

return 'C:\\Android\\sdk\\gradle\\gradle-3.2\\bin\\gradle'; if (androidStudioPath !== null && fs.existsSync(androidStudioPath)) { var dirs = fs.readdirSync(androidStudioPath); if(dirs[0].split('-')[0] == 'gradle') { return path.join(androidStudioPath, dirs[0], 'bin', 'gradle'); } } else { //OK, let's try to check for Gradle! return forgivingWhichSync('gradle'); }

It's not a real fix, but if you are sure of your gradle location it will be fine, hope cordova fix this.

更多推荐

本文发布于:2023-07-22 19:36:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1222822.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   版本   系统   Gradle   Studio

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!