Cordova Android构建失败:尝试引用暂未可用的API 28
Hey there! Sorry to hear your Cordova Android build started failing unexpectedly because of that API 28 dependency issue—this is a common gotcha when using version wildcards in your Gradle configs, so let’s get this sorted out quickly.
What’s causing the problem?
The root issue here is using the + wildcard in your support library dependency (like com.android.support:design:+). This tells Gradle to automatically pull the latest available version of the library, but if the latest version tied to API 28 is temporarily unavailable or broken, your build will fail.
Step-by-step fix
- Locate the
build.gradlefile in your Cordova project—this is usually found atplatforms/android/app/build.gradle(or check other relevant Gradle config files if you’ve customized your setup). - Find the
dependenciesblock where the problematic line is:dependencies { implementation 'com.android.support:design:+' // Other dependencies... } - Replace the
+with a specific, stable version of the support library. For API 28, the reliable stable version is28.0.0:dependencies { implementation 'com.android.support:design:28.0.0' // Other dependencies... } - Pro tip: While you’re at it, check for other support library dependencies in the same block that use
+(likecom.android.support:appcompat-v7:+orcom.android.support:recyclerview-v7:+) and replace those wildcards with the same28.0.0version. This prevents similar build failures from popping up in the future. - Save the file, then clean your build cache and re-run the build:
cordova clean android cordova build android
If you still run into issues
If the build still fails after this, double-check that your Cordova Android platform version is compatible with API 28. If you’re using a newer Cordova Android version (like 9.0.0+), it might have migrated to AndroidX instead of the old support libraries. In that case, you’ll need to switch to the AndroidX equivalent dependency:
implementation 'com.google.android.material:material:1.0.0'
Hope this gets your build back up and running smoothly!
内容的提问来源于stack exchange,提问作者emmer

