使用 Firebase 和 cordova-plugin-firebase 在 Apache Cordova Android 应用程序上构建问题
Posted
技术标签:
【中文标题】使用 Firebase 和 cordova-plugin-firebase 在 Apache Cordova Android 应用程序上构建问题【英文标题】:Build problem on Apache Cordova Android app with Firebase and ordova-plugin-firebase 【发布时间】:2019-04-04 12:23:54 【问题描述】:我需要有关 Firebase 和 Cordova 插件的帮助:cordova-plugin-firebase。 所以我使用visual studio 2017,我需要创建一个带有推送通知的android项目。所以我安装了这个插件,之后,当我尝试运行设备时,我从 Visual Studio 2017 收到这个错误。
Severity Code Description Project File Line Suppression State
Error at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:606) Mivebo 1
Error Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence. Mivebo 1
Error java.lang.IllegalStateException: buildToolsVersion is not specified. Mivebo 1
Error at com.google.common.base.Preconditions.checkState(Preconditions.java:176) Mivebo 1
Error at com.android.build.gradle.BasePlugin$10$1.call(BasePlugin.java:572) Mivebo 1
Error at com.android.build.gradle.BasePlugin$10$1.call(BasePlugin.java:569) Mivebo 1
Error at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:55) Mivebo 1
Error at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:47) Mivebo 1
Error at com.android.build.gradle.BasePlugin$10.execute(BasePlugin.java:568) Mivebo 1
Error at com.android.build.gradle.BasePlugin$10.execute(BasePlugin.java:565) Mivebo 1
Error at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:93) Mivebo 1
Error at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:82) Mivebo 1
Error at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:44) Mivebo 1
Error at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:79) Mivebo 1
Error at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:30) Mivebo 1
Error at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) Mivebo 1
Error at com.sun.proxy.$Proxy10.afterEvaluate(Unknown Source) Mivebo 1
Error at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67) Mivebo 1
Error at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61) Mivebo 1
Error at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:529) Mivebo 1
Error at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:90) Mivebo 1
Error at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42) Mivebo 1
Error at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35) Mivebo 1
Error at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:125) Mivebo 1
Error at org.gradle.internal.Factories$1.create(Factories.java:22) Mivebo 1
Error at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) Mivebo 1
Error at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52) Mivebo 1
Error at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:122) Mivebo 1
Error at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32) Mivebo 1
Error at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99) Mivebo 1
Error at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93) Mivebo 1
Error at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) Mivebo 1
Error at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62) Mivebo 1
Error at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93) Mivebo 1
Error at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82) Mivebo 1
Error at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94) Mivebo 1
Error at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28) Mivebo 1
Error at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) Mivebo 1
Error at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43) Mivebo 1
Error at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28) Mivebo 1
Error at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81) Mivebo 1
Error at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:46) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72) Mivebo 1
Error at org.gradle.util.Swapper.swap(Swapper.java:38) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50) Mivebo 1
Error at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246) Mivebo 1
Error at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) Mivebo 1
Error at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) Mivebo 1
Error at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) Mivebo 1
Error at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) Mivebo 1
Error at java.lang.Thread.run(Thread.java:748) Mivebo 1
Error FAILURE: Build failed with an exception. Mivebo 1
Error * Where: Mivebo 1
Error Build file 'C:\projects\Mivebo\Mivebo\platforms\android\build.gradle' line: 45 Mivebo 1
Error * What went wrong: Mivebo 1
Error A problem occurred evaluating root project 'android'. Mivebo 1
Error > Could not find method google() for arguments [] on repository container. Mivebo 1
Error * Try: Mivebo 1
Error Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Mivebo 1
Error Error: cmd: Command failed with exit code 1 Error output: Mivebo 1
Error Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence. Mivebo 1
Error java.lang.IllegalStateException: buildToolsVersion is not specified. Mivebo 1
Error at com.google.common.base.Preconditions.checkState(Preconditions.java:176) Mivebo 1
Error at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:606) Mivebo 1
Error at com.android.build.gradle.BasePlugin$10$1.call(BasePlugin.java:572) Mivebo 1
Error at com.android.build.gradle.BasePlugin$10$1.call(BasePlugin.java:569) Mivebo 1
Error at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:55) Mivebo 1
Error at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:47) Mivebo 1
Error at com.android.build.gradle.BasePlugin$10.execute(BasePlugin.java:568) Mivebo 1
Error at com.android.build.gradle.BasePlugin$10.execute(BasePlugin.java:565) Mivebo 1
Error at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:93) Mivebo 1
Error at org.gradle.internal.event.BroadcastDispatch$ActionInvocationHandler.dispatch(BroadcastDispatch.java:82) Mivebo 1
Error at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:44) Mivebo 1
Error at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:79) Mivebo 1
Error at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:30) Mivebo 1
Error at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) Mivebo 1
Error at com.sun.proxy.$Proxy10.afterEvaluate(Unknown Source) Mivebo 1
Error at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67) Mivebo 1
Error at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61) Mivebo 1
Error at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:529) Mivebo 1
Error at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:90) Mivebo 1
Error at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42) Mivebo 1
Error at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35) Mivebo 1
Error at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:125) Mivebo 1
Error at org.gradle.internal.Factories$1.create(Factories.java:22) Mivebo 1
Error at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) Mivebo 1
Error at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52) Mivebo 1
Error at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:122) Mivebo 1
Error at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32) Mivebo 1
Error at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99) Mivebo 1
Error at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93) Mivebo 1
Error at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) Mivebo 1
Error at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62) Mivebo 1
Error at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93) Mivebo 1
Error at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82) Mivebo 1
Error at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94) Mivebo 1
Error at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28) Mivebo 1
Error at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) Mivebo 1
Error at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43) Mivebo 1
Error at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28) Mivebo 1
Error at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81) Mivebo 1
Error at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:46) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72) Mivebo 1
Error at org.gradle.util.Swapper.swap(Swapper.java:38) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41) Mivebo 1
Error at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) Mivebo 1
Error at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50) Mivebo 1
Error at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246) Mivebo 1
Error at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) Mivebo 1
Error at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) Mivebo 1
Error at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) Mivebo 1
Error at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) Mivebo 1
Error at java.lang.Thread.run(Thread.java:748) Mivebo 1
Error FAILURE: Build failed with an exception. Mivebo 1
Error * Where: Mivebo 1
因此,在安装插件之前,该应用程序可以在设备上运行。 我已经设置了 firebase 页面并设置了 id app,但没有在设备上启动。 我还为科尔多瓦安装了谷歌播放服务插件。但还是不行。 也许我忘记了要安装的东西? 感谢帮助。 我的目标是从 Android 设备上的 firebase 发送推送通知。 感谢您的帮助。
【问题讨论】:
【参考方案1】:老实说,所有这些与 Firebase 相关的插件往往开发不佳或引入多种构建错误,因此您应该像瘟疫一样避免它们。
如果您只需要推送通知,请坚持使用phonegap-plugin-push 插件,该插件可以提供 GCM(已弃用)或 FCM(Firebase)推送通知,没有太多问题。请确保您完整阅读其文档,因为您遗漏的单个项目会导致构建失败或通知无法到达,经过多年使用,我可以证明这一点。
最后:如果你真的在使用 VS2017 for Cordova,check out this article 肯定会遇到一些问题。我一直在使用 VS2015,没有任何问题,应用程序可以部署到 WP8 和 Windows 10 Mobile。
【讨论】:
哇,对我来说很棒的解决方案。我已经测试过并且可以工作。谢谢。以上是关于使用 Firebase 和 cordova-plugin-firebase 在 Apache Cordova Android 应用程序上构建问题的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 Firebase 数据库和 Firebase 通知为聊天应用构建通知系统
使用选项配置 firebase 在 Xcode 11 和 Firebase 6.19 中崩溃
如何在项目中使用 firebase 和 firebase 功能的现有 Flutter 应用程序中更新包名称?
使用 Firebase 和 cordova-plugin-firebase 在 Apache Cordova Android 应用程序上构建问题