Flutter项目报错:无法解析com.stripe:stripe-android:20.12.+依赖求助
构建失败问题求助
项目此前运行一切正常,今日突然出现如下构建错误。
说明:自身应用未使用jCenter,但支付SDK flutter_stripe依赖jCenter。
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:checkDebugAarMetadata'. > Could not resolve all files for configuration ':app:debugRuntimeClasspath'. > Could not resolve com.stripe:stripe-android:20.12.+. Required by: project :app > project :stripe_android > Failed to list versions for com.stripe:stripe-android. > Unable to load Maven meta-data from https://jcenter.bintray.com/com/stripe/stripe-android/maven-metadata.xml. > Could not HEAD 'https://jcenter.bintray.com/com/stripe/stripe-android/maven-metadata.xml'. > Read timed out * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 1m 47s Exception: Gradle task assembleDebug failed with exit code 1
解决方法
- 升级flutter_stripe到最新版本:新版本的
stripe_android已迁移至Maven Central,不再依赖jCenter。修改pubspec.yaml中flutter_stripe的版本号后执行flutter pub get。 - 强制指定依赖仓库:若暂时无法升级SDK,可在
android/build.gradle中配置依赖解析规则,强制com.stripe组的依赖从Maven Central拉取:dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() exclusiveContent { forRepository { maven { url "https://repo1.maven.org/maven2/" } } filter { includeGroup "com.stripe" } } } } - 清理Gradle缓存:执行以下命令清除本地缓存并重新拉取依赖:
- Linux/macOS:
./gradlew clean build --refresh-dependencies - Windows:
gradlew clean build --refresh-dependencies
- Linux/macOS:
内容的提问来源于stack exchange,提问作者Harish Sharma
相关产品推荐
相关产品推荐

