1. Mô tả lỗi
Khi tui thực hiện build ứng dụng sang platform android với lệnh ionic cordova build android –debug thì xuất hiện lỗi như sau:
Dependency failing: com.google.firebase:firebase-messaging:17.4.0 -> com.google.firebase:firebase-iid@[17.1.0], but fire base-iid version was 17.1.2.
Và bên dưới là thông tin chi tiết của lỗi này:
Dependency resolved to an incompatible version: Dependency(fromArtifactVersion=ArtifactVersion(groupId=com.google.firebase, artifactId=firebase-messaging, version=17.4.0), toArtifact=Artifact(groupId=com.google.firebase, artifactId=firebase-iid), toArtifactVersionString=[17.1.0]) :app:preDebugBuild FAILED FAILURE: Build failed with an exception. * What went wrong: In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[17.1. 0]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown. Dependency failing: com.google.firebase:firebase-messaging:17.4.0 -> com.google.firebase:firebase-iid@[17.1.0], but fire base-iid version was 17.1.2. The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art ifact with the issue. -- Project 'app' depends onto com.google.firebase:firebase-core@16.0.+ -- Project 'app' depends onto com.google.firebase:firebase-messaging@17.4.+ For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https:// github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b uild.gradle file. * Try: For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https:// github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b uild.gradle file. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. * Get more help at https://help.gradle.org BUILD FAILED in 56s [ERROR] An error occurred while running subprocess cordova. cordova.cmd build android --debug exited with exit code 1. Re-running this command with the --verbose flag may provide more information.
2. Cách khắc phục
Để fix lỗi này bằng cách thực hiện gỡ bỏ plugin-firebase-messaging và cài lại nó với thông số ANDROID_SUPPORT_VERSION là 26.1 như sau:
ionic cordova plugin rm cordova-plugin-firebase-messaging ionic cordova plugin add cordova-plugin-firebase-messaging --variable ANDROID_SUPPORT_VERSION=26.1
Lưu ý: Nếu trong quá trình cài đặt lại plugin này gặp phải lỗi “Plugin doesn’t support this project’s cordova-android version” thì xem cách fix lỗi này ở đây nhé.
Hy vọng hữu ích với bạn!
Nosomovo