技術

[ Ionic ] A problem occurred evaluating project ‘:app’. > Failed to apply plugin [class ‘com.google.gms.googleservices.GoogleServicesPlugin’] > For input string: “+”

投稿日:

こんにちは。たなかです。
相変わらずモバイルアプリ開発やっています。

先日、Ionicでandroid buildした際に以下のエラーにぶつかりました。

エラー内容

BUILD FAILED in 2s
Error: /Users/xxxx/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Script ‘/Users/xxxx/platforms/android/cordova-support-google-services/xxxx-build.gradle’ line: 16

* What went wrong:
A problem occurred evaluating project ‘:app’.
> Failed to apply plugin [class ‘com.google.gms.googleservices.GoogleServicesPlugin’]
> For input string: “+”

* 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 2s
at ChildProcess.whenDone (/Users/xxxx/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at ChildProcess.emit (events.js:189:13)
at maybeClose (internal/child_process.js:978:16)
at Socket.stream.socket.on (internal/child_process.js:395:11)
at Socket.emit (events.js:189:13)
at Pipe._handle.close (net.js:613:12)
[ERROR] An error occurred while running subprocess cordova.

cordova build android –verbose exited with exit code 1.

Re-running this command with the –verbose flag may provide more information.
ionic:cli-framework:utils:process onBeforeExit handler: process.exit received +0ms
ionic:cli-framework:utils:process onBeforeExit handler: running 2 functions +0ms
ionic:cli-framework:utils:process onBeforeExit handler: exiting (exit code 1) +54ms

元から入れていたcordova-support-google-servicesプラグインと、build前に新たに追加したcordova-plugin-firebaseが競合?しているっぽい…?

cordova-plugin-firebaseをremoveするとbuild自体は通るようになります。

しかし、firebaseでのプッシュ通知を実現したいという目的があったため、なんとかしてプラグインを両立させbuild成功させたいところです。

 

エラー内容を手がかりに調査を開始した田中。

 

ちょっと関係ないですが、Ionicでbuild関連エラーの調査すると十中八九「platformをremoveしてaddしなおせ」って出てきますよね。

ここまで幾度となくbuildに躓いてきているので、remove & addは得意技になってしまいました。もはや目をつぶっても出来ます。ホントだよ。

 

解決方法

config.xmlで「PLAY_SERVICES_VERSION」を指定している箇所を、
全て “+” に変更する!

 

variable name="PLAY_SERVICES_VERSION" value="15.0.1"

こういった感じの箇所を…

variable name="PLAY_SERVICES_VERSION" value="+"

こう!

 

決め打ちしているPLAY_SERVICES_VERSIONのバージョンを+で柔軟にしてやることで、build時に上手いことやってくれるようになりました!

お得意のplatform remove & addを行い、再びandroid build……

** EXPORT SUCCEEDED **

やったぜ!

(この数日後、cordova-plugin-firebaseとは違う方針で進めることとなり、水泡に帰す)

 

短いですが今回はここまで。

 

参考サイト

https://github.com/arnesson/cordova-plugin-firebase/issues/988

https://github.com/arnesson/cordova-plugin-firebase/issues/742

コメントを見ていると
「IonicキツイからPWAでやるわ…」
「あきらめないで!」

みたいなやり取りがあって熱いです。

-技術
-

執筆者:


comment

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

関連記事

no image

VivaldiのWEBパネルに登録して便利だったサイトを紹介する

こんばんは VivaldiのWEBパネルはとても便利です。 今回はWEBパネルに …

[ionic] アプリ名にハイフンやアンダーバー入ってると困る件

どうも中田です 今日もionicのお話。 スマホアプリ作るときに test-ap …

[Xcode]Provisioning Profileの中身を確認する方法

こんにちは。たなかです。 以前『[Xcode]Provisioning Prof …

no image

【ionic】$ionicHistory.clearCache()が効かぬ!

どうも中田です。   ログアウトしたら、viewの情報を初期化したい! …

rails_logo

[Rails] Controllerで表示してるページのパスを判定したい

Controllerで表示してるページのパスを判定して、条件分岐したいと思います …