我在我的cordova应用中使用FCM plugin。在命令提示符中执行cordova build android
后,出现以下错误。
Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugApkCopy'.
> Could not find any version that matches com.google.firebase:firebase-iid:[16.0.0].
Versions that do not match:
11.0.4
11.0.2
11.0.1
11.0.0
10.2.6
+ 14 more
Searched in the following locations:
file:/D:/android-sdk_r24.4.1-windows/android-sdk-windows/extras/google/m2repository/com/google/firebase/firebase-iid/maven-metadata.xml
file:/D:/ZenHelp/ZenHelp2017/platforms/android/sdk-manager/com/google/firebase/firebase-iid/maven-metadata.xml
file:/D:/ZenHelp/ZenHelp2017/platforms/android/sdk-manager/com/google/firebase/firebase-iid/
file:/D:/android-sdk_r24.4.1-windows/android-sdk-windows/extras/android/m2repository/com/google/firebase/firebase-iid/maven-metadata.xml
file:/D:/android-sdk_r24.4.1-windows/android-sdk-windows/extras/android/m2repository/com/google/firebase/firebase-iid/
file:/D:/ZenHelp/ZenHelp2017/platforms/android/sdk-manager/com/google/firebase/firebase-iid/maven-metadata.xml
file:/D:/ZenHelp/ZenHelp2017/platforms/android/sdk-manager/com/google/firebase/firebase-iid/
Required by:
project : > com.google.firebase:firebase-messaging:17.0.0
> Could not find any version that matches com.google.android.gms:play-services-basement:[15.0.1].
Versions that do not match:
11.0.4
11.0.2
11.0.1
11.0.0
10.2.6
+ 17 more
Searched in the following locations:
file:/D:/android-sdk_r24.4.1-windows/android-sdk-windows/extras/google/m2repository/com/google/android/gms/play-services-basement/maven-metadata.xml
file:/D:/ZenHelp/ZenHelp2017/platforms/android/sdk-manager/com/google/android/gms/play-services-basement/maven-metadata.xml
file:/D:/ZenHelp/ZenHelp2017/platforms/android/sdk-manager/com/google/android/gms/play-services-basement/
file:/D:/android-sdk_r24.4.1-windows/android-sdk-windows/extras/android/m2repository/com/google/android/gms/play-services-basement/maven-metadata.xml
file:/D:/android-sdk_r24.4.1-windows/android-sdk-windows/extras/android/m2repository/com/google/android/gms/play-services-basement/
file:/D:/ZenHelp/ZenHelp2017/platforms/android/sdk-manager/com/google/android/gms/play-services-basement/maven-metadata.xml
file:/D:/ZenHelp/ZenHelp2017/platforms/android/sdk-manager/com/google/android/gms/play-services-basement/
Required by:
project : > com.google.firebase:firebase-messaging:17.0.0 > com.google.android.gms:play-services-tasks:15.0.1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
(node:2404) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
我检查了ANDROID_HOME
路径及其正确。我还更新了我的android sdk工具,我的Google Play Services
已更新为版本49
,Google repository
更新为版本58
。我也试过了cordova clean android
。
答案 0 :(得分:12)
打开位于build.gradle
platforms/android
并找到
allprojects {
repositories {
mavenCentral();
jcenter()
}
}
然后用
替换它allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
这对我有用
答案 1 :(得分:0)
我按照以下步骤操作:
在FCMPlugin.gradle
我评论了以下一行:
apply plugin: 'com.google.gms.google-services'
然后修改ProjectName/plugins/cordova-plugin-fcm/plugin.xml
:
<framework src="com.google.firebase:firebase-core:11.8.0" />
<framework src="com.google.firebase:firebase-messaging:11.8.0" />
这适合我。
信用:Ionic forum上的ghosteye(他做了ionic cordova platform remove android
然后ionic cordova platform add android@~6.4.0
,但我没有必要这样做。
希望它有所帮助。