美文网首页
Minimum supported Gradle version

Minimum supported Gradle version

作者: 徐小丘 | 来源:发表于2020-07-15 21:32 被阅读0次

使用ionic编译项目时 有的项目会提示

 Minimum supported Gradle version is 6.1.1. Current version is 4.10.3. If using the gradle wrapper, try editing the distributionUrl in /Users/jason/develop/industics/ibrain-app/in-mom-pda/gradle/wrapper/gradle-wrapper.properties to gradle-6.1.1-all.zip

为什么自己明明安装了5.6.3 还是报4.10.3这个错呢.
一直没搞清楚原因, 今天感觉搞不下去了.

就在项目里搜索了4.10.3


截屏2020-07-15 21.19.51.png

在node_moules的ProjectBuilder.js中 发现如下代码

prepEnv (opts) {
        var self = this;
        return check_reqs.check_gradle()
            .then(function (gradlePath) {
                return self.runGradleWrapper(gradlePath);
            }).then(function () {
                return self.prepBuildFiles();
            }).then(function () {
                // If the gradle distribution URL is set, make sure it points to version we want.
                // If it's not set, do nothing, assuming that we're using a future version of gradle that we don't want to mess with.
                // For some reason, using ^ and $ don't work.  This does the job, though.
                var distributionUrlRegex = /distributionUrl.*zip/;
                var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-4.10.3-all.zip';
                var gradleWrapperPropertiesPath = path.join(self.root, 'gradle', 'wrapper', 'gradle-wrapper.properties');
                shell.chmod('u+w', gradleWrapperPropertiesPath);
                shell.sed('-i', distributionUrlRegex, 'distributionUrl=' + distributionUrl, gradleWrapperPropertiesPath);

                var propertiesFile = opts.buildType + SIGNING_PROPERTIES;
                var propertiesFilePath = path.join(self.root, propertiesFile);
                if (opts.packageInfo) {
                    fs.writeFileSync(propertiesFilePath, TEMPLATE + opts.packageInfo.toProperties());
                } else if (isAutoGenerated(propertiesFilePath)) {
                    shell.rm('-f', propertiesFilePath);
                }
            });
    }

其中又一行代码

 var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-4.10.3-all.zip';

感觉问题就处在这.
感觉应该要将其设置为环境变量.可是要设置什么值呢?
上网搜索下CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL" 果然在 https://www.jianshu.com/p/7a465d169486 找到了答案
在~/.bash_profile 或者 ~/.zshrc [如果使用ohmyzsh的话]

 export GRADLE_HOME=$HOME/apps/gradle-5.6.4
export CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL=file://$GRADLE_HOME
export PATH=$GRADLE_HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH

注意 GRADLE_HOME 前面的 file:// 本身需要的是file:///User/..... 但是GRADLE_HOME 是/开头的 所以这里要加上file://

相关文章

网友评论

      本文标题:Minimum supported Gradle version

      本文链接:https://www.haomeiwen.com/subject/qvtshktx.html