在 Play 计费示例应用中部署后端服务器步骤

Deploy Back end server step in Play billing sample app

我已经按照here中的所有步骤得到了"Classy Taxi: Google Play Billing Subscriptions Android App Java Sample"运行ning,但是在最后一步我很困惑,不清楚我应该如何部署后端,步骤如下:

这些是构建位于 here

的后端服务器代码的步骤
  1. 确保您已安装 Node.js、npm 和 Firebase CLI。
  2. 运行 npm install 安装依赖项。
  3. 使用您的 Android 应用和订阅产品为 Firebase 配置 Cloud Functions:
firebase use --add {your_firebase_project_id}
firebase functions:config:set app.package_name="your_android_application_id"
firebase functions:config:set app.basic_plan_sku="your_basic_subscription_product_sku_id"
firebase functions:config:set app.premium_plan_sku="your_premium_subscription_product_sku_id"
  1. 运行 firebase deploy 将后端部署到 Cloud Functions for Firebase。

关于如何部署服务器的步骤并不清楚,它只提到了应用程序 ID 和产品 SKU,但没有提到服务器的代码,所以我需要帮助澄清,谢谢。我想一步一步看如何部署服务器。

这就是我目前正在做的事情: 1. 转到服务器的根文件夹 2.从该文件夹打开cmd 3. 运行 文档中列出的命令。 4.然后我得到这个错误:

=== Deploying to 'billing-project-c9f03'...

i  deploying functions, hosting
Running command: npm --prefix "$RESOURCE_DIR" run lint
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\frank\Desktop\Billing app\ClassyTaxiServer\server\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\frank\Desktop\Billing app\ClassyTaxiServer\server\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\frank\AppData\Roaming\npm-cache\_logs20-04-13T01_21_30_198Z-debug.log

Error: functions predeploy error: Command terminated with non-zero exit code429496323

但是我在根文件夹中看到 package.json 文件。

查看 Firebase CLI reference. This should be the project's root directory ClassyTaxiServer; assuming that you've ran all previous steps successfully, before attempting to firebase deploy. firebase.json knows what to do... however, that file is the actual problem; see PR #289

firebase.json 更新到此版本,它应该会成功:

{
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ],
    "source": "."
  },
  "hosting": {
    "public": "webapp",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [ ]
  }
}