{"id":57408,"date":"2025-08-15T12:20:25","date_gmt":"2025-08-15T04:20:25","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/57408.html"},"modified":"2025-08-15T12:20:25","modified_gmt":"2025-08-15T04:20:25","slug":"gradle-%e9%85%8d%e7%bd%ae%e5%9b%bd%e5%86%85%e9%95%9c%e5%83%8f%ef%bc%9a%e8%af%a6%e7%bb%86%e6%8c%87%e5%8d%97%ef%bc%8c%e5%8a%a0%e9%80%9f%e6%9e%84%e5%bb%ba%ef%bc%8c%e6%8f%90%e5%8d%87%e5%bc%80%e5%8f%91","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/57408.html","title":{"rendered":"#Gradle \u914d\u7f6e\u56fd\u5185\u955c\u50cf\uff1a\u8be6\u7ec6\u6307\u5357\uff0c\u52a0\u901f\u6784\u5efa\uff0c\u63d0\u5347\u5f00\u53d1\u6548\u7387"},"content":{"rendered":"<h3>\u524d\u8a00<\/h3>\n<p>\u5728\u4f7f\u7528 Gradle \u8fdb\u884c Java\u3001Android \u6216\u5176\u4ed6 JVM \u9879\u76ee\u5f00\u53d1\u65f6&#xff0c;\u6700\u4ee4\u4eba\u5934\u75bc\u7684\u95ee\u9898\u4e4b\u4e00\u5c31\u662f\u4f9d\u8d56\u4e0b\u8f7d\u901f\u5ea6\u6162\u3002\u7531\u4e8e Gradle \u9ed8\u8ba4\u7684\u4e2d\u592e\u4ed3\u5e93&#xff08;\u5982 Maven Central\u3001JCenter \u7b49&#xff09;\u4f4d\u4e8e\u56fd\u5916&#xff0c;\u7f51\u7edc\u8fde\u63a5\u4e0d\u7a33\u5b9a\u6216\u5ef6\u8fdf\u9ad8&#xff0c;\u5e38\u5e38\u5bfc\u81f4\u6784\u5efa\u8fc7\u7a0b\u8017\u65f6\u8fc7\u957f&#xff0c;\u751a\u81f3\u5931\u8d25\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6848&#xff1a;\u914d\u7f6e\u56fd\u5185\u955c\u50cf\u6e90&#xff0c;\u5c06\u4f9d\u8d56\u4e0b\u8f7d\u8bf7\u6c42\u91cd\u5b9a\u5411\u5230\u56fd\u5185\u7684\u955c\u50cf\u670d\u52a1\u5668&#xff0c;\u663e\u8457\u63d0\u5347\u4e0b\u8f7d\u901f\u5ea6&#xff0c;\u7f29\u77ed\u6784\u5efa\u65f6\u95f4\u3002<\/p>\n<p>\u672c\u6587\u5c06\u4e3a\u4f60\u63d0\u4f9b\u6700\u8be6\u7ec6\u3001\u6700\u5168\u9762\u7684 Gradle \u914d\u7f6e\u56fd\u5185\u955c\u50cf\u7684\u6307\u5357&#xff0c;\u6db5\u76d6\u591a\u79cd\u914d\u7f6e\u65b9\u5f0f\u3001\u4e0d\u540c\u573a\u666f\u3001\u5e38\u89c1\u95ee\u9898\u53ca\u6700\u4f73\u5b9e\u8df5&#xff0c;\u52a9\u4f60\u5f7b\u5e95\u89e3\u51b3\u4f9d\u8d56\u4e0b\u8f7d\u6162\u7684\u75db\u70b9\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u4e3a\u4ec0\u4e48\u9700\u8981\u914d\u7f6e\u56fd\u5185\u955c\u50cf&#xff1f;<\/h3>\n<li>\u5730\u7406\u4f4d\u7f6e\u4f18\u52bf&#xff1a;\u56fd\u5185\u955c\u50cf\u670d\u52a1\u5668&#xff08;\u5982\u963f\u91cc\u4e91\u3001\u534e\u4e3a\u4e91\u3001\u817e\u8baf\u4e91\u7b49&#xff09;\u4f4d\u4e8e\u4e2d\u56fd\u5883\u5185&#xff0c;\u7f51\u7edc\u5ef6\u8fdf\u4f4e&#xff0c;\u8bbf\u95ee\u901f\u5ea6\u5feb\u3002<\/li>\n<li>\u7f51\u7edc\u7a33\u5b9a\u6027&#xff1a;\u907f\u514d\u4e86\u8de8\u56fd\u7f51\u7edc\u6ce2\u52a8\u3001\u4e22\u5305\u7b49\u95ee\u9898&#xff0c;\u4e0b\u8f7d\u8fc7\u7a0b\u66f4\u7a33\u5b9a\u3002<\/li>\n<li>\u63d0\u5347\u5f00\u53d1\u6548\u7387&#xff1a;\u51cf\u5c11\u7b49\u5f85\u65f6\u95f4&#xff0c;\u52a0\u5feb\u9879\u76ee\u6784\u5efa\u3001\u7f16\u8bd1\u548c\u6d4b\u8bd5\u901f\u5ea6\u3002<\/li>\n<li>\u907f\u514d\u6784\u5efa\u5931\u8d25&#xff1a;\u7f51\u7edc\u8d85\u65f6\u6216\u8fde\u63a5\u4e2d\u65ad\u5bfc\u81f4\u7684\u4f9d\u8d56\u4e0b\u8f7d\u5931\u8d25\u95ee\u9898\u5927\u5927\u51cf\u5c11\u3002<\/li>\n<hr \/>\n<h3>\u4e8c\u3001\u4e3b\u6d41\u7684 Gradle \u56fd\u5185\u955c\u50cf\u6e90<\/h3>\n<p>\u4ee5\u4e0b\u662f\u56fd\u5185\u5e7f\u6cdb\u4f7f\u7528\u4e14\u7a33\u5b9a\u7684\u955c\u50cf\u6e90&#xff1a;<\/p>\n<table>\n<tr>\u955c\u50cf\u6e90\u5730\u5740\u5907\u6ce8<\/tr>\n<tbody>\n<tr>\n<td align=\"left\">\u963f\u91cc\u4e91 (Aliyun)<\/td>\n<td align=\"left\">https:\/\/maven.aliyun.com\/repository\/public<\/td>\n<td align=\"left\">\u8986\u76d6 Maven Central\u3001JCenter \u7b49&#xff0c;\u901f\u5ea6\u5feb&#xff0c;\u63a8\u8350\u9996\u9009<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u534e\u4e3a\u4e91 (Huawei Cloud)<\/td>\n<td align=\"left\">https:\/\/repo.huaweicloud.com\/repository\/maven\/<\/td>\n<td align=\"left\">\u534e\u4e3a\u5b98\u65b9\u955c\u50cf&#xff0c;\u7a33\u5b9a\u53ef\u9760<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u817e\u8baf\u4e91 (Tencent Cloud)<\/td>\n<td align=\"left\">https:\/\/mirrors.cloud.tencent.com\/nexus\/repository\/maven-public\/<\/td>\n<td align=\"left\">\u817e\u8baf\u4e91\u63d0\u4f9b\u7684\u955c\u50cf\u670d\u52a1<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u7f51\u6613 (163)<\/td>\n<td align=\"left\">http:\/\/mirrors.163.com\/maven\/repository\/maven-public\/<\/td>\n<td align=\"left\">\u7f51\u6613\u5f00\u6e90\u955c\u50cf\u7ad9<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u4e2d\u79d1\u5927 (USTC)<\/td>\n<td align=\"left\">https:\/\/mirrors.ustc.edu.cn\/maven-central\/<\/td>\n<td align=\"left\">\u4e2d\u56fd\u79d1\u5b66\u6280\u672f\u5927\u5b66\u5f00\u6e90\u955c\u50cf<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u63a8\u8350&#xff1a;\u963f\u91cc\u4e91\u955c\u50cf&#xff0c;\u56e0\u5176\u901f\u5ea6\u5feb\u3001\u8986\u76d6\u5168\u3001\u7a33\u5b9a\u6027\u9ad8&#xff0c;\u662f\u76ee\u524d\u6700\u53d7\u6b22\u8fce\u7684\u9009\u62e9\u3002<\/p>\n<hr \/>\n<h3>\u4e09\u3001\u914d\u7f6e Gradle \u56fd\u5185\u955c\u50cf\u7684\u56db\u79cd\u65b9\u6cd5<\/h3>\n<p>Gradle \u63d0\u4f9b\u4e86\u591a\u79cd\u914d\u7f6e\u955c\u50cf\u6e90\u7684\u65b9\u5f0f&#xff0c;\u4f60\u53ef\u4ee5\u6839\u636e\u9879\u76ee\u9700\u6c42\u548c\u56e2\u961f\u89c4\u8303\u9009\u62e9\u6700\u9002\u5408\u7684\u4e00\u79cd\u3002<\/p>\n<h4>\u65b9\u6cd5\u4e00&#xff1a;\u5168\u5c40\u914d\u7f6e&#xff08;\u63a8\u8350\u7528\u4e8e\u4e2a\u4eba\u5f00\u53d1&#xff09;<\/h4>\n<p>\u9002\u7528\u4e8e\u6240\u6709 Gradle \u9879\u76ee&#xff0c;\u53ea\u9700\u914d\u7f6e\u4e00\u6b21&#xff0c;\u6c38\u4e45\u751f\u6548\u3002<\/p>\n<h5>\u6b65\u9aa4&#xff1a;<\/h5>\n<li>\n<p>\u627e\u5230\u6216\u521b\u5efa Gradle \u7684\u7528\u6237\u4e3b\u76ee\u5f55\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<ul>\n<li>Windows: C:\\\\Users\\\\&lt;\u4f60\u7684\u7528\u6237\u540d&gt;\\\\.gradle\\\\init.gradle<\/li>\n<li>macOS\/Linux: ~\/.gradle\/init.gradle<\/li>\n<li>\u5982\u679c.gradle\u76ee\u5f55\u6216init.gradle\u6587\u4ef6\u4e0d\u5b58\u5728&#xff0c;\u8bf7\u624b\u52a8\u521b\u5efa\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5728init.gradle\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9&#xff1a;<\/p>\n<\/li>\n<p><span class=\"token comment\">\/\/ init.gradle &#8211; \u5168\u5c40\u914d\u7f6e\u955c\u50cf\u6e90<\/span><br \/>\ninitscript <span class=\"token punctuation\">{<\/span><br \/>\n    repositories <span class=\"token punctuation\">{<\/span><br \/>\n        maven <span class=\"token punctuation\">{<\/span> url <span class=\"token string\">&#039;https:\/\/maven.aliyun.com\/repository\/public&#039;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token function\">mavenCentral<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u4e3a\u6240\u6709\u9879\u76ee\u914d\u7f6e\u4ed3\u5e93<\/span><br \/>\nallprojects <span class=\"token punctuation\">{<\/span><br \/>\n    repositories <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u79fb\u9664\u9ed8\u8ba4\u7684jcenter()\u548cmavenCentral()<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u6dfb\u52a0\u963f\u91cc\u4e91\u955c\u50cf<\/span><br \/>\n        maven <span class=\"token punctuation\">{<\/span> url <span class=\"token string\">&#039;https:\/\/maven.aliyun.com\/repository\/public&#039;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u4e5f\u53ef\u4ee5\u6dfb\u52a0\u5176\u4ed6\u56fd\u5185\u955c\u50cf\u4f5c\u4e3a\u5907\u9009<\/span><br \/>\n        <span class=\"token comment\">\/\/ maven { url &#039;https:\/\/repo.huaweicloud.com\/repository\/maven\/&#039; }<\/span><br \/>\n        <span class=\"token comment\">\/\/ maven { url &#039;https:\/\/mirrors.cloud.tencent.com\/nexus\/repository\/maven-public\/&#039; }<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u5982\u679c\u9879\u76ee\u9700\u8981&#xff0c;\u53ef\u4ee5\u4fdd\u7559\u5bf9Google\u7b49\u7279\u5b9a\u4ed3\u5e93\u7684\u5f15\u7528<\/span><br \/>\n        <span class=\"token comment\">\/\/ google()<\/span><br \/>\n        <span class=\"token comment\">\/\/ gradlePluginPortal()<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token comment\">\/\/ \u914d\u7f6e\u4f9d\u8d56\u89e3\u6790\u89c4\u5219&#xff08;\u53ef\u9009&#xff0c;\u7528\u4e8e\u91cd\u5b9a\u5411&#xff09;<\/span><br \/>\n    configurations<span class=\"token punctuation\">.<\/span>all <span class=\"token punctuation\">{<\/span><br \/>\n        resolutionStrategy <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token comment\">\/\/ \u5f3a\u5236\u4f7f\u7528\u955c\u50cf\u6e90&#xff08;\u53ef\u9009&#xff0c;\u66f4\u5f7b\u5e95&#xff09;<\/span><br \/>\n            dependencySubstitution <span class=\"token punctuation\">{<\/span><br \/>\n                <span class=\"token comment\">\/\/ \u4f8b\u5982&#xff1a;\u5c06jcenter\u7684\u8bf7\u6c42\u91cd\u5b9a\u5411\u5230\u963f\u91cc\u4e91<\/span><br \/>\n                <span class=\"token comment\">\/\/ substitute module(&#039;jcenter&#039;) using module(&#039;maven:https:\/\/maven.aliyun.com\/repository\/public&#039;)<\/span><br \/>\n            <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h5>\u4f18\u70b9&#xff1a;<\/h5>\n<ul>\n<li>\u4e00\u52b3\u6c38\u9038&#xff0c;\u6240\u6709\u9879\u76ee\u81ea\u52a8\u751f\u6548\u3002<\/li>\n<li>\u65e0\u9700\u4fee\u6539\u6bcf\u4e2a\u9879\u76ee\u7684build.gradle\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<h5>\u7f3a\u70b9&#xff1a;<\/h5>\n<ul>\n<li>\u5982\u679c\u56e2\u961f\u534f\u4f5c&#xff0c;\u5176\u4ed6\u6210\u5458\u4e5f\u9700\u8981\u5355\u72ec\u914d\u7f6e\u3002<\/li>\n<li>\u53ef\u80fd\u5f71\u54cd\u67d0\u4e9b\u9700\u8981\u8bbf\u95ee\u539f\u59cb\u4ed3\u5e93\u7684\u7279\u6b8a\u9879\u76ee\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>\u65b9\u6cd5\u4e8c&#xff1a;\u9879\u76ee\u7ea7\u914d\u7f6e&#xff08;\u63a8\u8350\u7528\u4e8e\u56e2\u961f\u534f\u4f5c&#xff09;<\/h4>\n<p>\u9002\u7528\u4e8e\u5355\u4e2a\u9879\u76ee&#xff0c;\u914d\u7f6e\u5199\u5728\u9879\u76ee\u6587\u4ef6\u4e2d&#xff0c;\u56e2\u961f\u6210\u5458\u514b\u9686\u9879\u76ee\u540e\u81ea\u52a8\u751f\u6548\u3002<\/p>\n<h5>\u6b65\u9aa4&#xff1a;<\/h5>\n<li>\n<p>\u6253\u5f00\u9879\u76ee\u7684build.gradle\u6587\u4ef6&#xff08;\u901a\u5e38\u662f\u6839\u9879\u76ee\u7684build.gradle&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u627e\u5230repositories\u5757&#xff0c;\u6ce8\u91ca\u6216\u5220\u9664\u539f\u6709\u7684jcenter()\u548cmavenCentral()\u3002<\/p>\n<\/li>\n<li>\n<p>\u6dfb\u52a0\u56fd\u5185\u955c\u50cf\u6e90\u3002<\/p>\n<\/li>\n<p><span class=\"token comment\">\/\/ build.gradle (Project Level)<\/span><br \/>\nbuildscript <span class=\"token punctuation\">{<\/span><br \/>\n    repositories <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u539f\u6709\u914d\u7f6e&#xff08;\u53ef\u9009&#xff09;<\/span><br \/>\n        <span class=\"token comment\">\/\/ jcenter()<\/span><br \/>\n        <span class=\"token comment\">\/\/ mavenCentral()<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u4f7f\u7528\u963f\u91cc\u4e91\u955c\u50cf<\/span><br \/>\n        maven <span class=\"token punctuation\">{<\/span> url <span class=\"token string\">&#039;https:\/\/maven.aliyun.com\/repository\/public&#039;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u6216\u4f7f\u7528\u534e\u4e3a\u4e91<\/span><br \/>\n        <span class=\"token comment\">\/\/ maven { url &#039;https:\/\/repo.huaweicloud.com\/repository\/maven\/&#039; }<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    dependencies <span class=\"token punctuation\">{<\/span><br \/>\n        classpath <span class=\"token string\">&#039;com.android.tools.build:gradle:7.0.2&#039;<\/span> <span class=\"token comment\">\/\/ \u793a\u4f8b<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u5176\u4ed6classpath\u4f9d\u8d56<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>allprojects <span class=\"token punctuation\">{<\/span><br \/>\n    repositories <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u539f\u6709\u914d\u7f6e&#xff08;\u53ef\u9009&#xff09;<\/span><br \/>\n        <span class=\"token comment\">\/\/ jcenter()<\/span><br \/>\n        <span class=\"token comment\">\/\/ mavenCentral()<\/span><br \/>\n        <span class=\"token comment\">\/\/ google()<\/span><br \/>\n        <span class=\"token comment\">\/\/ gradlePluginPortal()<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u4f18\u5148\u4f7f\u7528\u56fd\u5185\u955c\u50cf<\/span><br \/>\n        maven <span class=\"token punctuation\">{<\/span> url <span class=\"token string\">&#039;https:\/\/maven.aliyun.com\/repository\/public&#039;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u53ef\u4ee5\u6dfb\u52a0\u591a\u4e2a\u955c\u50cf\u6e90&#xff0c;Gradle\u4f1a\u6309\u987a\u5e8f\u5c1d\u8bd5<\/span><br \/>\n        maven <span class=\"token punctuation\">{<\/span> url <span class=\"token string\">&#039;https:\/\/repo.huaweicloud.com\/repository\/maven\/&#039;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n        maven <span class=\"token punctuation\">{<\/span> url <span class=\"token string\">&#039;https:\/\/mirrors.cloud.tencent.com\/nexus\/repository\/maven-public\/&#039;<\/span> <span class=\"token punctuation\">}<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u4fdd\u7559\u5fc5\u8981\u7684\u5b98\u65b9\u4ed3\u5e93<\/span><br \/>\n        <span class=\"token function\">google<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token comment\">\/\/ Android\u9879\u76ee\u9700\u8981<\/span><br \/>\n        <span class=\"token function\">gradlePluginPortal<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token comment\">\/\/ Gradle\u63d2\u4ef6\u9700\u8981<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u6e05\u7406\u672a\u4f7f\u7528\u7684\u4ed3\u5e93&#xff08;\u53ef\u9009&#xff09;<\/span><br \/>\ntask <span class=\"token function\">clean<\/span><span class=\"token punctuation\">(<\/span>type<span class=\"token punctuation\">:<\/span> Delete<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    delete rootProject<span class=\"token punctuation\">.<\/span>buildDir<br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h5>\u4f18\u70b9&#xff1a;<\/h5>\n<ul>\n<li>\u914d\u7f6e\u968f\u9879\u76ee\u7248\u672c\u63a7\u5236&#xff0c;\u56e2\u961f\u6210\u5458\u5171\u4eab\u3002<\/li>\n<li>\u4e0d\u5f71\u54cd\u5176\u4ed6\u9879\u76ee\u7684\u6784\u5efa\u73af\u5883\u3002<\/li>\n<\/ul>\n<h5>\u7f3a\u70b9&#xff1a;<\/h5>\n<ul>\n<li>\u6bcf\u4e2a\u9879\u76ee\u90fd\u9700\u8981\u5355\u72ec\u914d\u7f6e\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>\u65b9\u6cd5\u4e09&#xff1a;\u901a\u8fc7settings.gradle\u914d\u7f6e&#xff08;Gradle 5.0&#043; \u63a8\u8350&#xff09;<\/h4>\n<p>Gradle 5.0 \u5f15\u5165\u4e86settings.gradle\u4e2d\u7684dependencyResolutionManagement&#xff0c;\u662f\u5b98\u65b9\u63a8\u8350\u7684\u96c6\u4e2d\u7ba1\u7406\u4f9d\u8d56\u548c\u4ed3\u5e93\u7684\u65b9\u5f0f\u3002<\/p>\n<h5>\u6b65\u9aa4&#xff1a;<\/h5>\n<li>\u5728\u9879\u76ee\u6839\u76ee\u5f55\u7684settings.gradle\u6587\u4ef6\u4e2d\u6dfb\u52a0&#xff1a;<\/li>\n<p><span class=\"token comment\">\/\/ settings.gradle<\/span><br \/>\nrootProject<span class=\"token punctuation\">.<\/span>name <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;YourProjectName&#039;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u914d\u7f6e\u4f9d\u8d56\u89e3\u6790\u7ba1\u7406&#xff08;Gradle 5.0&#043;&#xff09;<\/span><br \/>\ndependencyResolutionManagement <span class=\"token punctuation\">{<\/span><br \/>\n    repositoriesMode<span class=\"token punctuation\">.<\/span><span class=\"token function\">set<\/span><span class=\"token punctuation\">(<\/span>RepositoriesMode<span class=\"token punctuation\">.<\/span>FAIL_ON_PROJECT_REPOS<span class=\"token punctuation\">)<\/span><br \/>\n    repositories <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token comment\">\/\/ \u6e05\u9664\u9ed8\u8ba4\u4ed3\u5e93<\/span><br \/>\n        <span class=\"token comment\">\/\/ mavenCentral()<\/span><br \/>\n        <span class=\"token comment\">\/\/ jcenter()<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u6dfb\u52a0\u56fd\u5185\u955c\u50cf<\/span><br \/>\n        maven <span class=\"token punctuation\">{<\/span><br \/>\n            name <span class=\"token operator\">&#061;<\/span> <span class=\"token interpolation-string\"><span class=\"token string\">&#034;Aliyun Maven&#034;<\/span><\/span><br \/>\n            url <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">uri<\/span><span class=\"token punctuation\">(<\/span><span class=\"token interpolation-string\"><span class=\"token string\">&#034;https:\/\/maven.aliyun.com\/repository\/public&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><br \/>\n            <span class=\"token comment\">\/\/ \u53ef\u9009&#xff1a;\u914d\u7f6e\u8ba4\u8bc1&#xff08;\u5982\u679c\u955c\u50cf\u9700\u8981&#xff09;<\/span><br \/>\n            <span class=\"token comment\">\/\/ credentials {<\/span><br \/>\n            <span class=\"token comment\">\/\/     username &#061; &#039;your-username&#039;<\/span><br \/>\n            <span class=\"token comment\">\/\/     password &#061; &#039;your-password&#039;<\/span><br \/>\n            <span class=\"token comment\">\/\/ }<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><\/p>\n<p>        maven <span class=\"token punctuation\">{<\/span><br \/>\n            name <span class=\"token operator\">&#061;<\/span> <span class=\"token interpolation-string\"><span class=\"token string\">&#034;Huawei Maven&#034;<\/span><\/span><br \/>\n            url <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">uri<\/span><span class=\"token punctuation\">(<\/span><span class=\"token interpolation-string\"><span class=\"token string\">&#034;https:\/\/repo.huaweicloud.com\/repository\/maven\/&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><\/p>\n<p>        <span class=\"token comment\">\/\/ \u4fdd\u7559\u5fc5\u8981\u7684\u5b98\u65b9\u4ed3\u5e93<\/span><br \/>\n        <span class=\"token function\">google<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token function\">mavenCentral<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token comment\">\/\/ \u5982\u679c\u955c\u50cf\u4e0d\u5b8c\u6574&#xff0c;\u53ef\u4f5c\u4e3a\u5907\u9009<\/span><br \/>\n        <span class=\"token function\">gradlePluginPortal<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u5305\u542b\u5b50\u9879\u76ee&#xff08;\u5982\u679c\u6709&#xff09;<\/span><br \/>\ninclude <span class=\"token string\">&#039;app&#039;<\/span><br \/>\n<span class=\"token comment\">\/\/ include &#039;library&#039;<\/span><\/p>\n<li>\u5728build.gradle\u4e2d\u4e0d\u518d\u9700\u8981\u91cd\u590d\u5b9a\u4e49repositories&#xff0c;\u9664\u975e\u6709\u7279\u6b8a\u9700\u6c42\u3002<\/li>\n<h5>\u4f18\u70b9&#xff1a;<\/h5>\n<ul>\n<li>\u5b98\u65b9\u63a8\u8350&#xff0c;\u7ed3\u6784\u6e05\u6670&#xff0c;\u6613\u4e8e\u7ef4\u62a4\u3002<\/li>\n<li>\u96c6\u4e2d\u7ba1\u7406\u6240\u6709\u6a21\u5757\u7684\u4ed3\u5e93\u914d\u7f6e\u3002<\/li>\n<li>\u652f\u6301\u66f4\u590d\u6742\u7684\u4f9d\u8d56\u89e3\u6790\u7b56\u7565\u3002<\/li>\n<\/ul>\n<h5>\u7f3a\u70b9&#xff1a;<\/h5>\n<ul>\n<li>\u4ec5\u9002\u7528\u4e8e Gradle 5.0 \u53ca\u4ee5\u4e0a\u7248\u672c\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>\u65b9\u6cd5\u56db&#xff1a;\u901a\u8fc7gradle.properties\u914d\u7f6e\u4ee3\u7406&#xff08;\u5907\u9009\u65b9\u6848&#xff09;<\/h4>\n<p>\u5982\u679c\u955c\u50cf\u914d\u7f6e\u65e0\u6548&#xff0c;\u6216\u9700\u8981\u66f4\u5e95\u5c42\u7684\u7f51\u7edc\u63a7\u5236&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e HTTP \u4ee3\u7406\u3002<\/p>\n<h5>\u6b65\u9aa4&#xff1a;<\/h5>\n<li>\u5728gradle.properties\u6587\u4ef6\u4e2d&#xff08;\u9879\u76ee\u7ea7\u6216\u7528\u6237\u7ea7&#xff09;\u6dfb\u52a0&#xff1a;<\/li>\n<p># gradle.properties<br \/>\n# \u8bbe\u7f6eHTTP\u4ee3\u7406&#xff08;\u5982\u679c\u516c\u53f8\u6216\u7f51\u7edc\u9700\u8981&#xff09;<br \/>\n# org.gradle.jvmargs&#061;-Dhttp.proxyHost&#061;proxy.company.com -Dhttp.proxyPort&#061;8080 -Dhttps.proxyHost&#061;proxy.company.com -Dhttps.proxyPort&#061;8080<\/p>\n<p># \u6216\u8005\u76f4\u63a5\u8bbe\u7f6e\u4ed3\u5e93URL&#xff08;\u4e0d\u63a8\u8350&#xff0c;\u4e0d\u5982\u65b9\u6cd5\u4e09\u7075\u6d3b&#xff09;<br \/>\n# systemProp.maven.repo.remote&#061;https:\/\/maven.aliyun.com\/repository\/public<\/p>\n<p>\u6ce8\u610f&#xff1a;\u6b64\u65b9\u6cd5\u4e3b\u8981\u7528\u4e8e\u4ee3\u7406&#xff0c;\u76f4\u63a5\u8bbe\u7f6e\u4ed3\u5e93 URL \u7684\u6548\u679c\u6709\u9650&#xff0c;\u5efa\u8bae\u4f18\u5148\u4f7f\u7528\u524d\u4e09\u79cd\u65b9\u6cd5\u3002<\/p>\n<hr \/>\n<h3>\u56db\u3001\u9a8c\u8bc1\u914d\u7f6e\u662f\u5426\u751f\u6548<\/h3>\n<p>\u914d\u7f6e\u5b8c\u6210\u540e&#xff0c;\u5982\u4f55\u786e\u8ba4\u955c\u50cf\u6e90\u5df2\u6210\u529f\u4f7f\u7528&#xff1f;<\/p>\n<h4>\u65b9\u6cd5 1&#xff1a;\u67e5\u770b\u6784\u5efa\u65e5\u5fd7<\/h4>\n<p>\u8fd0\u884c.\/gradlew build &#8211;info&#xff0c;\u5728\u8f93\u51fa\u65e5\u5fd7\u4e2d\u641c\u7d22Downloading\u6216Download&#xff0c;\u89c2\u5bdf\u4f9d\u8d56\u7684\u4e0b\u8f7d URL \u662f\u5426\u6307\u5411\u4f60\u914d\u7f6e\u7684\u56fd\u5185\u955c\u50cf\u5730\u5740\u3002<\/p>\n<h4>\u65b9\u6cd5 2&#xff1a;\u68c0\u67e5\u7f51\u7edc\u8bf7\u6c42<\/h4>\n<p>\u4f7f\u7528\u7f51\u7edc\u76d1\u63a7\u5de5\u5177&#xff08;\u5982 Wireshark\u3001Fiddler&#xff09;\u6216\u6d4f\u89c8\u5668\u5f00\u53d1\u8005\u5de5\u5177&#xff0c;\u89c2\u5bdf Gradle \u6784\u5efa\u65f6\u7684 HTTP \u8bf7\u6c42\u76ee\u6807\u5730\u5740\u3002<\/p>\n<h4>\u65b9\u6cd5 3&#xff1a;\u5bf9\u6bd4\u6784\u5efa\u65f6\u95f4<\/h4>\n<p>\u914d\u7f6e\u524d\u540e\u6267\u884c.\/gradlew clean build&#xff0c;\u6bd4\u8f83\u6784\u5efa\u8017\u65f6&#xff0c;\u56fd\u5185\u955c\u50cf\u901a\u5e38\u80fd\u5c06\u65f6\u95f4\u4ece\u51e0\u5206\u949f\u7f29\u77ed\u5230\u51e0\u79d2\u6216\u51e0\u5341\u79d2\u3002<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u5e38\u89c1\u95ee\u9898\u4e0e\u89e3\u51b3\u65b9\u6848<\/h3>\n<h4>\u95ee\u9898 1&#xff1a;\u914d\u7f6e\u540e\u4ecd\u7136\u4ece\u56fd\u5916\u4ed3\u5e93\u4e0b\u8f7d&#xff1f;<\/h4>\n<ul>\n<li>\u68c0\u67e5repositories\u987a\u5e8f&#xff1a;Gradle \u6309repositories\u5217\u8868\u7684\u987a\u5e8f\u67e5\u627e\u4f9d\u8d56&#xff0c;\u786e\u4fdd\u56fd\u5185\u955c\u50cf\u6392\u5728mavenCentral()\u6216jcenter()\u4e4b\u524d\u3002<\/li>\n<li>\u68c0\u67e5settings.gradle&#xff1a;\u5982\u679c\u4f7f\u7528\u4e86dependencyResolutionManagement&#xff0c;\u786e\u4fddrepositoriesMode\u8bbe\u7f6e\u6b63\u786e&#xff0c;\u4e14\u672a\u5728\u5b50\u9879\u76ee\u4e2d\u8986\u76d6\u3002<\/li>\n<li>\u6e05\u9664 Gradle \u7f13\u5b58&#xff1a;\u8fd0\u884c.\/gradlew &#8211;stop\u505c\u6b62\u5b88\u62a4\u8fdb\u7a0b&#xff0c;\u7136\u540e\u5220\u9664~\/.gradle\/caches\/\u76ee\u5f55&#xff08;\u8c28\u614e\u64cd\u4f5c&#xff09;&#xff0c;\u91cd\u65b0\u6784\u5efa\u3002<\/li>\n<\/ul>\n<h4>\u95ee\u9898 2&#xff1a;\u67d0\u4e9b\u4f9d\u8d56\u5728\u955c\u50cf\u4e2d\u627e\u4e0d\u5230&#xff1f;<\/h4>\n<ul>\n<li>\u955c\u50cf\u540c\u6b65\u5ef6\u8fdf&#xff1a;\u56fd\u5185\u955c\u50cf\u53ef\u80fd\u6709\u540c\u6b65\u5ef6\u8fdf&#xff0c;\u7a0d\u7b49\u4e00\u6bb5\u65f6\u95f4\u518d\u8bd5\u3002<\/li>\n<li>\u4f9d\u8d56\u6e90\u7279\u6b8a&#xff1a;\u67d0\u4e9b\u79c1\u6709\u5e93\u6216\u975e\u4e3b\u6d41\u4ed3\u5e93\u4e0d\u5728\u955c\u50cf\u8303\u56f4\u5185\u3002\u89e3\u51b3\u65b9\u6848&#xff1a;\n<ul>\n<li>\u5728repositories\u4e2d\u540c\u65f6\u4fdd\u7559\u56fd\u5185\u955c\u50cf\u548c\u539f\u59cb\u4ed3\u5e93&#xff08;\u5982mavenCentral()&#xff09;\u3002<\/li>\n<li>\u5c06\u56fd\u5185\u955c\u50cf\u653e\u5728\u524d\u9762&#xff0c;Gradle \u4f1a\u4f18\u5148\u4ece\u955c\u50cf\u4e0b\u8f7d&#xff0c;\u627e\u4e0d\u5230\u65f6\u518d\u5c1d\u8bd5\u539f\u59cb\u4ed3\u5e93\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>\u95ee\u9898 3&#xff1a;Android \u9879\u76ee\u63d0\u793a\u201cFailed to resolve: androidx.xxx\u201d&#xff1f;<\/h4>\n<ul>\n<li>\u786e\u4fdd\u5728repositories\u4e2d\u4fdd\u7559\u4e86google()\u4ed3\u5e93&#xff0c;AndroidX \u4f9d\u8d56\u5fc5\u987b\u4ece Google \u4ed3\u5e93\u4e0b\u8f7d\u3002<\/li>\n<li>\u914d\u7f6e\u793a\u4f8b&#xff1a;allprojects <span class=\"token punctuation\">{<\/span><br \/>\n    repositories <span class=\"token punctuation\">{<\/span><br \/>\n        maven <span class=\"token punctuation\">{<\/span> url <span class=\"token string\">&#039;https:\/\/maven.aliyun.com\/repository\/public&#039;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token function\">google<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token comment\">\/\/ \u5fc5\u987b\u4fdd\u7559<\/span><br \/>\n        <span class=\"token function\">mavenCentral<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<\/li>\n<\/ul>\n<h4>\u95ee\u9898 4&#xff1a;Gradle \u7248\u672c\u8fc7\u4f4e&#xff0c;\u4e0d\u652f\u6301settings.gradle\u914d\u7f6e&#xff1f;<\/h4>\n<ul>\n<li>\u5347\u7ea7 Gradle \u7248\u672c&#xff1a;\u4fee\u6539gradle\/wrapper\/gradle-wrapper.properties\u4e2d\u7684distributionUrl\u3002distributionUrl&#061;https\\\\:\/\/services.gradle.org\/distributions\/gradle-7.4.2-bin.zip\n<\/li>\n<li>\u4f7f\u7528build.gradle\u9879\u76ee\u7ea7\u914d\u7f6e\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3>\u516d\u3001\u6700\u4f73\u5b9e\u8df5\u4e0e\u5efa\u8bae<\/h3>\n<li>\u4f18\u5148\u4f7f\u7528settings.gradle\u914d\u7f6e&#xff1a;\u5bf9\u4e8e Gradle 5.0&#043;\u9879\u76ee&#xff0c;\u8fd9\u662f\u6700\u73b0\u4ee3\u548c\u63a8\u8350\u7684\u65b9\u5f0f\u3002<\/li>\n<li>\u4e2a\u4eba\u5f00\u53d1\u7528\u5168\u5c40\u914d\u7f6e&#xff1a;\u7701\u65f6\u7701\u529b&#xff0c;\u4e00\u6b21\u914d\u7f6e&#xff0c;\u7ec8\u8eab\u53d7\u76ca\u3002<\/li>\n<li>\u56e2\u961f\u9879\u76ee\u7528\u9879\u76ee\u7ea7\u914d\u7f6e&#xff1a;\u786e\u4fdd\u73af\u5883\u4e00\u81f4\u6027&#xff0c;\u907f\u514d\u201c\u5728\u6211\u673a\u5668\u4e0a\u80fd\u8dd1\u201d\u7684\u95ee\u9898\u3002<\/li>\n<li>\u7ec4\u5408\u4f7f\u7528\u591a\u4e2a\u955c\u50cf&#xff1a;\u914d\u7f6e\u963f\u91cc\u4e91\u4e3a\u4e3b&#xff0c;\u534e\u4e3a\u4e91\u6216\u817e\u8baf\u4e91\u4e3a\u5907&#xff0c;\u63d0\u9ad8\u53ef\u7528\u6027\u3002<\/li>\n<li>\u4fdd\u7559\u5fc5\u8981\u7684\u5b98\u65b9\u4ed3\u5e93&#xff1a;\u5982google()\u3001gradlePluginPortal()&#xff0c;\u907f\u514d\u529f\u80fd\u7f3a\u5931\u3002<\/li>\n<li>\u5b9a\u671f\u68c0\u67e5\u955c\u50cf\u72b6\u6001&#xff1a;\u5173\u6ce8\u955c\u50cf\u6e90\u7684\u5b98\u65b9\u516c\u544a&#xff0c;\u4e86\u89e3\u540c\u6b65\u72b6\u6001\u548c\u7ef4\u62a4\u8ba1\u5212\u3002<\/li>\n<li>\u6587\u6863\u5316\u914d\u7f6e&#xff1a;\u5728\u9879\u76ee README \u4e2d\u8bf4\u660e\u4ed3\u5e93\u914d\u7f6e&#xff0c;\u65b9\u4fbf\u65b0\u6210\u5458\u52a0\u5165\u3002<\/li>\n<hr \/>\n<h3>\u4e03\u3001\u603b\u7ed3<\/h3>\n<p>\u914d\u7f6e Gradle \u56fd\u5185\u955c\u50cf\u662f\u63d0\u5347 JVM \u9879\u76ee\u5f00\u53d1\u6548\u7387\u7684\u5fc5\u5907\u6280\u80fd\u3002\u901a\u8fc7\u672c\u6587\u4ecb\u7ecd\u7684\u56db\u79cd\u65b9\u6cd5&#xff0c;\u4f60\u53ef\u4ee5\u7075\u6d3b\u9009\u62e9\u6700\u9002\u5408\u4f60\u573a\u666f\u7684\u65b9\u6848\u3002<\/p>\n<p>\u6838\u5fc3\u8981\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u963f\u91cc\u4e91\u955c\u50cf\u662f\u9996\u9009\u3002<\/li>\n<li>settings.gradle \u662f\u672a\u6765\u8d8b\u52bf\u3002<\/li>\n<li>\u9879\u76ee\u7ea7\u914d\u7f6e\u5229\u4e8e\u56e2\u961f\u534f\u4f5c\u3002<\/li>\n<li>\u5168\u5c40\u914d\u7f6e\u9002\u5408\u4e2a\u4eba\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<p>\u7acb\u5373\u52a8\u624b\u914d\u7f6e&#xff0c;\u544a\u522b\u7f13\u6162\u7684\u4f9d\u8d56\u4e0b\u8f7d&#xff0c;\u4eab\u53d7\u4e1d\u6ed1\u7684\u6784\u5efa\u4f53\u9a8c\u5427&#xff01;<\/p>\n<p>\u63d0\u793a&#xff1a;\u914d\u7f6e\u5b8c\u6210\u540e&#xff0c;\u522b\u5fd8\u4e86\u8fd0\u884c.\/gradlew build\u9a8c\u8bc1\u6548\u679c&#xff0c;\u5e76\u5206\u4eab\u7ed9\u4f60\u7684\u56e2\u961f\u6210\u5458&#xff01;<\/p>\n<hr \/>\n<p>\u53c2\u8003\u8d44\u6599&#xff1a;<\/p>\n<ul>\n<li>Gradle \u5b98\u65b9\u6587\u6863&#xff1a;https:\/\/docs.gradle.org\/<\/li>\n<li>\u963f\u91cc\u4e91 Maven \u955c\u50cf&#xff1a;https:\/\/maven.aliyun.com\/<\/li>\n<li>\u534e\u4e3a\u4e91 Maven \u4ed3\u5e93&#xff1a;https:\/\/repo.huaweicloud.com\/<\/li>\n<\/ul>\n<p>\u5e0c\u671b\u8fd9\u7bc7\u8be6\u7ec6\u7684\u6307\u5357\u80fd\u5f7b\u5e95\u89e3\u51b3\u4f60\u7684 Gradle \u6784\u5efa\u96be\u9898&#xff01;\u5982\u6709\u7591\u95ee&#xff0c;\u6b22\u8fce\u5728\u8bc4\u8bba\u533a\u4ea4\u6d41\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb293\u6b21\u3002Gradle\u914d\u7f6e\u56fd\u5185\u955c\u50cf\u6e90\u6307\u5357\uff1a\u89e3\u51b3\u4f9d\u8d56\u4e0b\u8f7d\u6162\u95ee\u9898 \u6458\u8981\uff1a\u672c\u6587\u63d0\u4f9b\u4e86Gradle\u914d\u7f6e\u56fd\u5185\u955c\u50cf\u6e90\u7684\u8be6\u7ec6\u89e3\u51b3\u65b9\u6848\uff0c\u65e8\u5728\u89e3\u51b3\u56e0\u9ed8\u8ba4\u56fd\u5916\u4ed3\u5e93\u5bfc\u81f4\u7684\u4f9d\u8d56\u4e0b\u8f7d\u6162\u3001\u6784\u5efa\u5931\u8d25\u7b49\u95ee\u9898\u3002\u6587\u7ae0\u63a8\u8350\u963f\u91cc\u4e91\u3001\u534e\u4e3a\u4e91\u7b49\u4e3b\u6d41\u56fd\u5185\u955c\u50cf\u6e90\uff0c\u5e76\u8be6\u7ec6\u4ecb\u7ecd\u56db\u79cd\u914d\u7f6e\u65b9\u6cd5\uff1a\u5168\u5c40\u914d\u7f6e\uff08\u901a\u8fc7init.gradle\uff09\u3001\u9879\u76ee\u7ea7\u914d\u7f6e\uff08\u4fee\u6539build.gradle\uff09\u3001settings.gradle\u914d\u7f6e\uff08Gradle 5.0+\uff09\u4ee5\u53ca\u547d\u4ee4\u884c\u4e34\u65f6\u914d\u7f6e\u3002\u91cd\u70b9\u63a8\u8350\u963f\u91cc\u4e91\u955c\u50cf\u6e90\uff0c\u5176\u901f\u5ea6\u5feb\u3001\u8986\u76d6\u5168\uff0c\u540c\u65f6\u63d0\u4f9b\u591a\u79cd\u914d\u7f6e\u65b9\u5f0f\u7684\u4f18\u7f3a\u70b9\u6bd4\u8f83\u548c\u4f7f\u7528\u573a\u666f\u5efa\u8bae\u3002\u901a\u8fc7\u5408\u7406\u914d\u7f6e\u56fd\u5185\u955c\u50cf\u6e90\uff0c\u53ef\u663e\u8457<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[2801],"topic":[],"class_list":["post-57408","post","type-post","status-publish","format-standard","hentry","category-server","tag-gradle"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>#Gradle \u914d\u7f6e\u56fd\u5185\u955c\u50cf\uff1a\u8be6\u7ec6\u6307\u5357\uff0c\u52a0\u901f\u6784\u5efa\uff0c\u63d0\u5347\u5f00\u53d1\u6548\u7387 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/57408.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"#Gradle \u914d\u7f6e\u56fd\u5185\u955c\u50cf\uff1a\u8be6\u7ec6\u6307\u5357\uff0c\u52a0\u901f\u6784\u5efa\uff0c\u63d0\u5347\u5f00\u53d1\u6548\u7387 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb293\u6b21\u3002Gradle\u914d\u7f6e\u56fd\u5185\u955c\u50cf\u6e90\u6307\u5357\uff1a\u89e3\u51b3\u4f9d\u8d56\u4e0b\u8f7d\u6162\u95ee\u9898 \u6458\u8981\uff1a\u672c\u6587\u63d0\u4f9b\u4e86Gradle\u914d\u7f6e\u56fd\u5185\u955c\u50cf\u6e90\u7684\u8be6\u7ec6\u89e3\u51b3\u65b9\u6848\uff0c\u65e8\u5728\u89e3\u51b3\u56e0\u9ed8\u8ba4\u56fd\u5916\u4ed3\u5e93\u5bfc\u81f4\u7684\u4f9d\u8d56\u4e0b\u8f7d\u6162\u3001\u6784\u5efa\u5931\u8d25\u7b49\u95ee\u9898\u3002\u6587\u7ae0\u63a8\u8350\u963f\u91cc\u4e91\u3001\u534e\u4e3a\u4e91\u7b49\u4e3b\u6d41\u56fd\u5185\u955c\u50cf\u6e90\uff0c\u5e76\u8be6\u7ec6\u4ecb\u7ecd\u56db\u79cd\u914d\u7f6e\u65b9\u6cd5\uff1a\u5168\u5c40\u914d\u7f6e\uff08\u901a\u8fc7init.gradle\uff09\u3001\u9879\u76ee\u7ea7\u914d\u7f6e\uff08\u4fee\u6539build.gradle\uff09\u3001settings.gradle\u914d\u7f6e\uff08Gradle 5.0+\uff09\u4ee5\u53ca\u547d\u4ee4\u884c\u4e34\u65f6\u914d\u7f6e\u3002\u91cd\u70b9\u63a8\u8350\u963f\u91cc\u4e91\u955c\u50cf\u6e90\uff0c\u5176\u901f\u5ea6\u5feb\u3001\u8986\u76d6\u5168\uff0c\u540c\u65f6\u63d0\u4f9b\u591a\u79cd\u914d\u7f6e\u65b9\u5f0f\u7684\u4f18\u7f3a\u70b9\u6bd4\u8f83\u548c\u4f7f\u7528\u573a\u666f\u5efa\u8bae\u3002\u901a\u8fc7\u5408\u7406\u914d\u7f6e\u56fd\u5185\u955c\u50cf\u6e90\uff0c\u53ef\u663e\u8457\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/57408.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-15T04:20:25+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/57408.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/57408.html\",\"name\":\"#Gradle \u914d\u7f6e\u56fd\u5185\u955c\u50cf\uff1a\u8be6\u7ec6\u6307\u5357\uff0c\u52a0\u901f\u6784\u5efa\uff0c\u63d0\u5347\u5f00\u53d1\u6548\u7387 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-15T04:20:25+00:00\",\"dateModified\":\"2025-08-15T04:20:25+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/57408.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/57408.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/57408.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"#Gradle \u914d\u7f6e\u56fd\u5185\u955c\u50cf\uff1a\u8be6\u7ec6\u6307\u5357\uff0c\u52a0\u901f\u6784\u5efa\uff0c\u63d0\u5347\u5f00\u53d1\u6548\u7387\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"#Gradle \u914d\u7f6e\u56fd\u5185\u955c\u50cf\uff1a\u8be6\u7ec6\u6307\u5357\uff0c\u52a0\u901f\u6784\u5efa\uff0c\u63d0\u5347\u5f00\u53d1\u6548\u7387 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/57408.html","og_locale":"zh_CN","og_type":"article","og_title":"#Gradle \u914d\u7f6e\u56fd\u5185\u955c\u50cf\uff1a\u8be6\u7ec6\u6307\u5357\uff0c\u52a0\u901f\u6784\u5efa\uff0c\u63d0\u5347\u5f00\u53d1\u6548\u7387 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb293\u6b21\u3002Gradle\u914d\u7f6e\u56fd\u5185\u955c\u50cf\u6e90\u6307\u5357\uff1a\u89e3\u51b3\u4f9d\u8d56\u4e0b\u8f7d\u6162\u95ee\u9898 \u6458\u8981\uff1a\u672c\u6587\u63d0\u4f9b\u4e86Gradle\u914d\u7f6e\u56fd\u5185\u955c\u50cf\u6e90\u7684\u8be6\u7ec6\u89e3\u51b3\u65b9\u6848\uff0c\u65e8\u5728\u89e3\u51b3\u56e0\u9ed8\u8ba4\u56fd\u5916\u4ed3\u5e93\u5bfc\u81f4\u7684\u4f9d\u8d56\u4e0b\u8f7d\u6162\u3001\u6784\u5efa\u5931\u8d25\u7b49\u95ee\u9898\u3002\u6587\u7ae0\u63a8\u8350\u963f\u91cc\u4e91\u3001\u534e\u4e3a\u4e91\u7b49\u4e3b\u6d41\u56fd\u5185\u955c\u50cf\u6e90\uff0c\u5e76\u8be6\u7ec6\u4ecb\u7ecd\u56db\u79cd\u914d\u7f6e\u65b9\u6cd5\uff1a\u5168\u5c40\u914d\u7f6e\uff08\u901a\u8fc7init.gradle\uff09\u3001\u9879\u76ee\u7ea7\u914d\u7f6e\uff08\u4fee\u6539build.gradle\uff09\u3001settings.gradle\u914d\u7f6e\uff08Gradle 5.0+\uff09\u4ee5\u53ca\u547d\u4ee4\u884c\u4e34\u65f6\u914d\u7f6e\u3002\u91cd\u70b9\u63a8\u8350\u963f\u91cc\u4e91\u955c\u50cf\u6e90\uff0c\u5176\u901f\u5ea6\u5feb\u3001\u8986\u76d6\u5168\uff0c\u540c\u65f6\u63d0\u4f9b\u591a\u79cd\u914d\u7f6e\u65b9\u5f0f\u7684\u4f18\u7f3a\u70b9\u6bd4\u8f83\u548c\u4f7f\u7528\u573a\u666f\u5efa\u8bae\u3002\u901a\u8fc7\u5408\u7406\u914d\u7f6e\u56fd\u5185\u955c\u50cf\u6e90\uff0c\u53ef\u663e\u8457","og_url":"https:\/\/www.wsisp.com\/helps\/57408.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-15T04:20:25+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/57408.html","url":"https:\/\/www.wsisp.com\/helps\/57408.html","name":"#Gradle \u914d\u7f6e\u56fd\u5185\u955c\u50cf\uff1a\u8be6\u7ec6\u6307\u5357\uff0c\u52a0\u901f\u6784\u5efa\uff0c\u63d0\u5347\u5f00\u53d1\u6548\u7387 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-15T04:20:25+00:00","dateModified":"2025-08-15T04:20:25+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/57408.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/57408.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/57408.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"#Gradle \u914d\u7f6e\u56fd\u5185\u955c\u50cf\uff1a\u8be6\u7ec6\u6307\u5357\uff0c\u52a0\u901f\u6784\u5efa\uff0c\u63d0\u5347\u5f00\u53d1\u6548\u7387"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/57408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=57408"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/57408\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=57408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=57408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=57408"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=57408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}