ionic 4 build release error with admob free and firebase

在 ionic 4 的環境,如果混用Firebase及admob,在編譯release的版本時可能會發生以下的問題:
The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[16.3.0,16.3.0], [16.4.0,16.4.0]], but resolves to 16.4.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

找了許多討論,可以瞭解問題核心在於不同plugin引用不同版本的問題:

  1. https://github.com/arnesson/cordova-plugin-firebase/issues/856
最後按討論安裝了:
  1. https://github.com/dpa99c/cordova-android-play-services-gradle-release
  2. https://github.com/dpa99c/cordova-android-firebase-gradle-release
並指定版本為『15.+』,不過反而產生其它問題。

最後找資料:
  1. https://stackoverflow.com/questions/50569501/gradle-sync-fails-play-services-measurement-base
在『project/platforms/android/app/build.gradle』的最後一行補上『com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

但如果前面兩個動作拿掉,還是一樣不行,也就是三個動作都要做。

留言

熱門文章