问题:
安装完这个插件后,运行 cordova run android 报错。
报错信息:(注意粗体斜线的版本,我的报错是24)
BUILD FAILED in 30s3 actionable tasks: 1 executed, 2 up-to-date/Users/X/Documents/cordovaProject/App/platforms/android/gradlew: Command failed with exit code 1 Error output:FAILURE: Build failed with an exception.* What went wrong:Could not resolve all files for configuration ':app:debugCompileClasspath'.> Could not resolve com.android.support:support-v4:24.1.1+. Required by: project :app > Failed to list versions for com.android.support:support-v4. > Unable to load Maven meta-data from https://jcenter.bintray.com/com/android/support/support-v4/maven-metadata.xml. > Could not get resource 'https://jcenter.bintray.com/com/android/support/support-v4/maven-metadata.xml'. > Could not GET 'https://jcenter.bintray.com/com/android/support/support-v4/maven-metadata.xml'. > Connect to jcenter.bintray.com:443 [jcenter.bintray.com/34.95.74.180] failed: connect 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.orgBUILD FAILED in 30s
版本:
"cordova":"^9.0.0"
"cordova-android": "^8.1.0",
"cordova-plugin-x-socialsharing": "^5.6.8",
解决方法:
看了报错信息,大致感觉是版本的不统一问题。
1.打开build.gradle全都改成24版本的如下。改完后运行 cordova run android
![](https://img.haomeiwen.com/i5609919/3c647f315888cd9b.png)
2.发现报了另一个错,没关系,再把24版本改回原来的版本,再次运行cordova run android
BUILD FAILED in 13s
23 actionable tasks: 3 executed, 20 up-to-date
/Users/X/Documents/cordovaProject/App/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Android resource linking failed /Users/X/Documents/cordovaProject/App/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:344: error: resource android:attr/fontStyle not found. /Users/X/Documents/cordovaProject/App/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:344: error: resource android:attr/font not found. /Users/X/Documents/cordovaProject/App/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:344: error: resource android:attr/fontWeight not found.
error: failed linking references.
* 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 13s
3.成功
![](https://img.haomeiwen.com/i5609919/6776959160e7bef6.png)
网友评论