Ionic构建Android失败:无法连接jcenter.bintray.com超时
Hey there, let's work through this build failure you're stuck on. From the error details you shared, the core issue is that your build can't fetch required dependencies because of network timeouts connecting to jcenter.bintray.com—even without a proxy, this is a common problem with unstable networks, temporary jcenter outages, or outdated Gradle configs.
First, let's recap your environment setup for clarity:
Environment Information
Ionic/Cordova CLI:
@ionic/cli-utils : 1.19.2 ionic (Ionic CLI) : 3.20.0 cordova (Cordova CLI) : 8.0.0
Local Project Packages:
@ionic/app-scripts : 3.1.8 Cordova Platforms : android 7.0.0 Ionic Framework : ionic-angular 3.9.2
System & Environment Variables:
Android SDK Tools : 26.1.1 Node : v8.11.1 npm : 5.6.0 OS : Windows 10 ANDROID_HOME : C:\Users\admin\AppData\Local\Android\sdk backend : pro
Build Failure Error Log
When running ionic cordova build --debug android, you get:
FAILURE: Build failed with an exception.
- 出错原因:配置根项目'android'时出现问题。
无法解析配置':classpath'的所有文件。
无法解析org.jetbrains.kotlin:kotlin-stdlib:1.1.3-2,该依赖由多个Gradle模块所需;无法获取资源http://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.1.3-2/kotlin-stdlib-1.1.3-2.pom,连接jcenter.bintray.com:80超时。
同时无法解析org.ow2.asm:asm:5.1、org.ow2.asm:asm-analysis:5.1等依赖,均因连接jcenter.bintray.com超时导致。
Solutions to Try
Let's go through fixes step by step, starting with the simplest:
1. Verify Network Access to jcenter
First, open your browser and try visiting http://jcenter.bintray.com. If it doesn't load, your network might be blocking it (some corporate networks do this) or jcenter is down temporarily. Try switching to a different network (like a mobile hotspot) and re-run the build to test.
2. Update Gradle Repositories
Jcenter has been sunset, so replacing or supplementing it with Maven Central (which hosts most of the same dependencies) can resolve this. Here's how:
- Navigate to your project's
androidfolder, open the rootbuild.gradlefile. - Look for the
repositoriesblocks in bothbuildscriptandallprojectssections. AddmavenCentral()before or alongsidejcenter():buildscript { repositories { mavenCentral() jcenter() // You can keep this, but mavenCentral is more reliable now } // ... rest of your buildscript code } allprojects { repositories { mavenCentral() jcenter() // ... other repos like maven { url 'https://maven.google.com' } } }
3. Clear Gradle Cache
Corrupted cache files can sometimes cause dependency fetch issues. Delete the Gradle cache folder on your Windows machine:
- Go to
C:\Users\admin\.gradle\cachesand delete all contents inside. - After deleting, re-run your build command:
ionic cordova build --debug android
4. Increase Gradle Timeout Settings
If your network is slow, increasing the timeout for dependency downloads can help.
- In the
androidfolder, create or edit thegradle.propertiesfile and add these lines:org.gradle.jvmargs=-Dhttp.connectionTimeout=120000 -Dhttp.socketTimeout=120000 org.gradle.parallel=true - You can also add resolution strategy settings in the root
build.gradleto force fresh checks for dependencies:buildscript { configurations.all { resolutionStrategy { cacheChangingModulesFor 0, 'seconds' } } // ... rest of your buildscript code }
5. Update Gradle Version
Your project is using an older Cordova Android version (7.0.0), which might rely on an outdated Gradle version. Try updating the Gradle wrapper:
- Open
android/gradle/wrapper/gradle-wrapper.properties - Update the
distributionUrlto a newer stable version, like:distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
Give these steps a try—start with checking your network first, as that's the most likely culprit. If none of these work, we can dig deeper!
内容的提问来源于stack exchange,提问作者Kirubel

