首页 > 解决方案 > 离子插件错误:运行使用本机地理围栏 API 的应用程序时 plugin_not_installed

问题描述

我正在创建一个使用地理围栏本机 api 的应用程序。当我尝试使用 ionicDevApp 测试设备时,出现以下错误。

plugin_not_installed我的控制台将记录以下警告:

[15:04:03]  console.warn: Native: tried calling Geofence.addOrUpdate, but the Geofence plugin is not installed.
[15:04:03]  console.warn: Install the Geofence plugin: 'ionic cordova plugin add cordova-plugin-geofence'
[15:04:03]  console.log: Geofence failed to add plugin_not_installed

但是我已经cordova-plugin-geofence 使用以下命令安装了ionic cordova plugin add cordova-plugin-geofence

我也在npm install --save @ionic-native/geofence安装插件后运行,但我仍然遇到同样的错误。

这是我的package.json文件片段,显示了项目中依赖项的版本。

{
  "name": "geolocation",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@agm/core": "^1.0.0-beta.3",
    "@angular/animations": "5.2.11",
    "@angular/common": "5.2.11",
    "@angular/compiler": "5.2.11",
    "@angular/compiler-cli": "5.2.11",
    "@angular/core": "5.2.11",
    "@angular/forms": "5.2.11",
    "@angular/http": "5.2.11",
    "@angular/platform-browser": "5.2.11",
    "@angular/platform-browser-dynamic": "5.2.11",
    "@ionic-native/core": "4.7.0",
    "@ionic-native/geofence": "^4.7.0",
    "@ionic-native/geolocation": "^4.7.0",
    "@ionic-native/splash-screen": "4.7.0",
    "@ionic-native/status-bar": "4.7.0",
    "@ionic/storage": "2.1.3",
    "@types/pusher-js": "^4.2.0",
    "body-parser": "^1.18.3",
    "cordova-android": "7.0.0",
    "cordova-ios": "4.5.4",
    "cordova-plugin-add-swift-support": "^1.6.0",
    "cordova-plugin-compat": "^1.2.0",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-geofence": "^0.7.0",
    "cordova-plugin-geolocation": "^4.0.1",
    "cordova-plugin-ionic-keyboard": "^2.1.2",
    "cordova-plugin-ionic-webview": "^1.2.1",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "dotenv": "^6.0.0",
    "es6-promise-plugin": "^4.2.2",
    "express": "^4.16.3",
    "ionic-angular": "3.9.2",
    "ionicons": "3.0.0",
    "pusher": "^2.0.0",
    "pusher-js": "^4.2.2",
    "rxjs": "5.5.11",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.1.10",
    "typescript": "~2.6.2"
  },
  "description": "An Ionic project",
  "cordova": {
     "plugins": {
      "cordova-plugin-geolocation": {
        "GEOLOCATION_USAGE_DESCRIPTION": "To locate you"
      },
      "cordova-plugin-geofence": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-ionic-keyboard": {},
      "cordova-plugin-add-swift-support": {}
    },
    "platforms": [
      "android",
      "ios"
    ]
  }
}

标签: angularcordovaionic-frameworkionic3android-geofence

解决方案


它看起来不像 cordova-plugin-geofence 是 IonicDevApp 当前支持的插件列表的一部分:

https://ionicframework.com/docs/pro/devapp/

您需要将应用程序打包成适当的二进制文件,然后将其安装在您的 Android 上,或者如果您是 iOS 用户,则使用 TestFlight 来测试地理围栏插件。


推荐阅读