pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

為什么同一個版本的gradle會有多個副本

Why there are multiple copies for the same version of gradle(為什么同一個版本的gradle會有多個副本)
本文介紹了為什么同一個版本的gradle會有多個副本的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個android studio項目,文件gradle/wrapper/gradle-wrapper.properties配置如下.

I have an android studio project, with the file gradle/wrapper/gradle-wrapper.properties configured as following.

#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip

我的主目錄中安裝了 2.2.1-all 版本.

And I have the 2.2.1-all version installed in my home directory.

.gradle/wrapper/dists/gradle-2.2.1-all/c64ydeuardnfqctvr1gm30w53/gradle-2.2.1-all.zip

當我調用 ./gradlew 命令來構建項目時.我應該使用 gradle-2.2.1-all.zip 來構建.

When I invoke ./gradlew command to build the project. I should use the gradle-2.2.1-all.zip to build.

但它不會,即使是相同版本,它也會下載另一個 gradle.因此,版本 2.2.1-all 有兩個 gradle.因為我的網絡連接很慢,所以需要很長時間.

But it doesn't, it will download another gradle even for the same version instead. So, there are two gradles for the version 2.2.1-all. Because my internet connection is very slow, it takes too long.

.gradle/wrapper/dists/gradle-2.2.1-all/c64ydeuardnfqctvr1gm30w53/gradle-2.2.1-all.zip
.gradle/wrapper/dists/gradle-2.2.1-all/6dibv5rcnnqlfbq9klf8imrndn/gradle-2.2.1-all.zip

這很煩人,因為每次我調用命令來構建我的項目時,它都必須為同一版本下載一個新版本.

It's very annoying since it has to download a new one for the same version very time I invoke the command to build my project.

為什么 gradle 構建系統無法選擇已安裝的系統?

Why the gradle build system couldn't pick the installed one?

推薦答案

出現問題是因為s??tudio的gradle-wrapper.jar和最新的下載url的hash策略不同gradle-wrapper.jar.

The problem occurred is because the hash policy for the download url is different between studio's gradle-wrapper.jar and latest gradle-wrapper.jar.

我的 Android 應用目錄下的 gradle-wrapper.jar(我猜它是從 android-sdk-macosx/tools/templates/gradle/wrapper/gradle/wrapper/gradle-wrapper.jar)使用下面的方法計算下載url的hash.

The gradle-wrapper.jar under my Android app directory (I guess it's copied from android-sdk-macosx/tools/templates/gradle/wrapper/gradle/wrapper/gradle-wrapper.jar) use the following method to calculate hash for the download url.

// PathAssembler.java
private String getMd5Hash(String string) {
    try {
        MessageDigest e = MessageDigest.getInstance("MD5");
        byte[] bytes = string.getBytes();
        e.update(bytes);
        return (new BigInteger(1, e.digest())).toString(32);
    } catch (Exception var4) {
        throw new RuntimeException("Could not hash input string.", var4);
    }
}

但是最新的gradle-wrapper.jar使用下面的方法來做.基數從 32 變為 36.

But the latest gradle-wrapper.jar use the following method to do. The radix change from 32 to 36.

private String getHash(String string) {
    try {
        MessageDigest messageDigest = MessageDigest.getInstance("MD5");
        byte[] bytes = string.getBytes();
        messageDigest.update(bytes);
        return new BigInteger(1, messageDigest.digest()).toString(36);
    } catch (Exception e) {
        throw new RuntimeException("Could not hash input string.", e);
    }
}

我在目錄名中找到的魔法字符串是下載url的md5哈希字符串.

The magic string I found in the directory name is the md5 hash string of the download url.

對于2.10版本,有目錄名

For version 2.10, there is a directory name

.gradle/wrapper/dists/gradle-2.10-all/a4w5fzrkeut1ox71xslb49gst

并且 a4w5fzrkeut1ox71xslb49gst 是從下載 url 散列的.

And the a4w5fzrkeut1ox71xslb49gst is hashed from the download url.

try {
    MessageDigest messageDigest = MessageDigest.getInstance("MD5");
    messageDigest.update("https://services.gradle.org/distributions/gradle-2.10-all.zip".getBytes());
    System.out.println(new BigInteger(1, messageDigest.digest()).toString(36));
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
}

通過對來自 gradle/wrapper/gradle-wrapper.properties 的相同下載 url 使用相同的哈希方法(使用相同的 gradle-wrapper.jar),有同一版本的 gradle 不會被多次下載.

By using the same hash method (use the same gradle-wrapper.jar) for the same download url from gradle/wrapper/gradle-wrapper.properties, there won't be multiple downloads for the same version of gradle.

這個問題只存在于android studio項目和其他gradle項目之間.

This issue only exist between android studio project and other gradle project.

這篇關于為什么同一個版本的gradle會有多個副本的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

IncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM(更新到 Android Build Tools 25.1.6 GCM/FCM 后出現 IncompatibleClassChangeError)
How to get current flavor in gradle(如何在 gradle 中獲取當前風味)
How to fix quot;unexpected element lt;queriesgt; found in lt;manifestgt;quot; error?(如何修復“意外元素lt;查詢gt;在“清單中找到錯誤?)
Multi flavor app based on multi flavor library in Android Gradle(基于 Android Gradle 中多風味庫的多風味應用)
Android dependency has different version for the compile and runtime(Android 依賴在編譯和運行時有不同的版本)
Transitive dependencies for local aar library(本地 aar 庫的傳遞依賴)
主站蜘蛛池模板: 温控器生产厂家-提供温度开关/热保护器定制与批发-惠州市华恺威电子科技有限公司 | 工业洗衣机_工业洗涤设备_上海力净工业洗衣机厂家-洗涤设备首页 bkzzy在职研究生网 - 在职研究生招生信息咨询平台 | 不锈钢水管-不锈钢燃气管-卫生级不锈钢管件-不锈钢食品级水管-广东双兴新材料集团有限公司 | 建筑工程资质合作-工程资质加盟分公司-建筑资质加盟 | 神超官网_焊接圆锯片_高速钢锯片_硬质合金锯片_浙江神超锯业制造有限公司 | 黄石东方妇产医院_黄石妇科医院哪家好_黄石无痛人流医院 | 沧州友城管业有限公司-内外涂塑钢管-大口径螺旋钢管-涂塑螺旋管-保温钢管生产厂家 | 华中线缆有限公司-电缆厂|电缆厂家|电线电缆厂家 | 新材料分散-高速均质搅拌机-超声波分散混合-上海化烁智能设备有限公司 | 吹田功率计-长创耐压测试仪-深圳市新朗普电子科技有限公司 | 全自动固相萃取仪_高通量真空平行浓缩仪-勤业永为 | 中药超微粉碎机(中药细胞级微粉碎)-百科 | 超声波焊接机,振动摩擦焊接机,激光塑料焊接机,超声波焊接模具工装-德召尼克(常州)焊接科技有限公司 | 领先的大模型技术与应用公司-中关村科金 | 安徽免检低氮锅炉_合肥燃油锅炉_安徽蒸汽发生器_合肥燃气锅炉-合肥扬诺锅炉有限公司 | 信阳网站建设专家-信阳时代网联-【信阳网站建设百度推广优质服务提供商】信阳网站建设|信阳网络公司|信阳网络营销推广 | 「安徽双凯」自动售货机-无人售货机-成人用品-自动饮料食品零食售货机 | 金环宇|金环宇电线|金环宇电缆|金环宇电线电缆|深圳市金环宇电线电缆有限公司|金环宇电缆集团 | 预制围墙_工程预制围墙_天津市瑞通建筑材料有限公司 | Safety light curtain|Belt Sway Switches|Pull Rope Switch|ultrasonic flaw detector-Shandong Zhuoxin Machinery Co., Ltd | 安平县鑫川金属丝网制品有限公司,防风抑尘网,单峰防风抑尘,不锈钢防风抑尘网,铝板防风抑尘网,镀铝锌防风抑尘网 | 防潮防水通风密闭门源头实力厂家 - 北京酷思帝克门窗 | 圆窗水平仪|伊莉莎冈特elesa+ganter | 彩信群发_群发彩信软件_视频短信营销平台-达信通 | 骨密度仪-骨密度测定仪-超声骨密度仪-骨龄测定仪-天津开发区圣鸿医疗器械有限公司 | 东亚液氮罐-液氮生物容器-乐山市东亚机电工贸有限公司 | 空调风机,低噪声离心式通风机,不锈钢防爆风机,前倾皮带传动风机,后倾空调风机-山东捷风风机有限公司 | 肉嫩度仪-凝胶测试仪-国产质构仪-气味分析仪-上海保圣实业发展有限公司|总部 | 合金ICP光谱仪(磁性材料,工业废水)-百科 | 找果网 | 苹果手机找回方法,苹果iPhone手机丢了找回,认准找果网! | 分轨 | 上传文件,即刻分离人声和伴奏 | 12cr1mov无缝钢管切割-15crmog无缝钢管切割-40cr无缝钢管切割-42crmo无缝钢管切割-Q345B无缝钢管切割-45#无缝钢管切割 - 聊城宽达钢管有限公司 | 铝板冲孔网,不锈钢冲孔网,圆孔冲孔网板,鳄鱼嘴-鱼眼防滑板,盾构走道板-江拓数控冲孔网厂-河北江拓丝网有限公司 | LNG鹤管_内浮盘价格,上装鹤管,装车撬厂家-连云港赛威特机械 | 特种阀门-调节阀门-高温熔盐阀-镍合金截止阀-钛阀门-高温阀门-高性能蝶阀-蒙乃尔合金阀门-福建捷斯特阀门制造有限公司 | ◆大型吹塑加工|吹塑加工|吹塑代加工|吹塑加工厂|吹塑设备|滚塑加工|滚塑代加工-莱力奇塑业有限公司 | 纯化水设备-纯水设备-超纯水设备-[大鹏水处理]纯水设备一站式服务商-东莞市大鹏水处理科技有限公司 | 鼓风干燥箱_真空烘箱_高温干燥箱_恒温培养箱-上海笃特科学仪器 | 石家庄网站建设|石家庄网站制作|石家庄小程序开发|石家庄微信开发|网站建设公司|网站制作公司|微信小程序开发|手机APP开发|软件开发 | 厌氧工作站-通用型厌氧工作站-上海胜秋科学仪器有限公司 | 一体式钢筋扫描仪-楼板测厚仪-裂缝检测仪-泰仕特(北京) |