我用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.
更多推荐
发布评论