Visual studio code 打开安卓工程,查看代码无法正常跳转
#### Visual studio code 打开安卓工程,查看代码无法正常跳转
2025-06-04 周三
gradle报错如下:
```
[{
"resource": "/F:/code/testApp/apps/testApp/build.gradle",
"owner": "_generated_diagnostic_collection_name_#4",
"code": "0",
"severity": 8,
"message": "The supplied phased action failed with an exception.\r\nA problem occurred configuring root project 'testApp'.\r\nBuild file 'F:\\code\\testApp\\apps\\testApp\\build.gradle' line: 3\r\nPlugin [id: 'com.android.application', version: '7.3.0', apply: false] was not found in any of the following sources:\r\n- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)\r\n- Plugin Repositories (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:7.3.0')\r\n Searched in the following repositories:\n Gradle Central Plugin Repository\n Google\n MavenRepo\r\nPlugin [id: 'com.android.application', version: '7.3.0', apply: false] was not found in any of the following sources:\r\n- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)\r\n- Plugin Repositories (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:7.3.0')\r\n Searched in the following repositories:\n Gradle Central Plugin Repository\n Google\n MavenRepo",
"source": "Java",
"startLineNumber": 3,
"startColumn": 1,
"endLineNumber": 3,
"endColumn": 1
}]
```
**原因分析:**
网络问题
- Gradle 无法从 `Gradle Central Plugin Repository`、`Google` 或 `MavenRepo` 中解析到该插件。可能是网络连接问题,或者这些仓库中确实没有该版本的插件。
检查网络连接
- 确保你的网络可以访问 `Gradle Central Plugin Repository`、`Google` 和 `MavenRepo`。
- 如果网络有问题,可以尝试切换到其他网络,或者使用代理。
**解决方法:**
C:\Users\<username>\.gradle\gradle.properties里有设置代理的地方,将代理放开:
```
systemProp.https.proxyPassword=123456
systemProp.http.proxyHost=x.x.x.x
systemProp.https.proxyUser=username
systemProp.https.proxyHost=x.x.x.x
systemProp.https.proxyPort=8080
systemProp.http.proxyPort=8080
systemProp.http.proxyPassword=
systemProp.http.proxyUser=username
```
并且打开系统设置里的代理,设置代理IP地址和端口。

浙公网安备 33010602011771号