无法在离子v2中安装非原生cordova插件

时间:2017-06-20 01:04:31

标签: android cordova ionic-framework ionic2 cordova-plugins

我正在构建一个Ionic 2移动应用程序。我想获得网络的IP地址。

所以我想安装插件cordova-plugin-networkinterface

https://github.com/salbahra/cordova-plugin-networkinterface

以下是我的ionic info

global packages:

    @ionic/cli-utils : 1.4.0
    Cordova CLI      : 7.0.1 
    Ionic CLI        : 3.4.0

local packages:

    @ionic/app-scripts              : 1.1.3
    @ionic/cli-plugin-cordova       : 1.1.2
    @ionic/cli-plugin-ionic-angular : 1.1.2
    Ionic Framework                 : ionic-angular 2.1.0

System:

    Node       : v6.10.2
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.1 Build version 8E1000a 
    ios-deploy : 1.9.1 
    ios-sim    : 5.0.13 
    npm        : 4.5.0 

但是,当我尝试使用命令

安装插件时
ionic cordova plugin add cordova-plugin-networkinterface

我收到以下错误:

Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova plugin add cordova-plugin-networkinterface --save (exit code 1):

        Installing "cordova-plugin-networkinterface" for android
        ANDROID_HOME=/Users/ankarthik/Library/Android/sdk
        JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
        Subproject Path: CordovaLib
        Failed to install 'cordova-plugin-networkinterface': Error: spawn EACCES
        at exports._errnoException (util.js:1018:11)
        at ChildProcess.spawn (internal/child_process.js:319:11)
        at Object.exports.spawn (child_process.js:378:9)
        at exports.spawn
        (/Users/ankarthik/Documents/projects/Juventus/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:134:31)
        at /Users/ankarthik/Documents/projects/Juventus/platforms/android/cordova/lib/builders/GradleBuilder.js:261:16
        at _fulfilled
        (/Users/ankarthik/Documents/projects/Juventus/platforms/android/cordova/node_modules/q/q.js:854:54)
        at self.promiseDispatch.done
        (/Users/ankarthik/Documents/projects/Juventus/platforms/android/cordova/node_modules/q/q.js:883:30)
        at Promise.promise.promiseDispatch
        (/Users/ankarthik/Documents/projects/Juventus/platforms/android/cordova/node_modules/q/q.js:816:13)
        at /Users/ankarthik/Documents/projects/Juventus/platforms/android/cordova/node_modules/q/q.js:877:14
        at runSingle (/Users/ankarthik/Documents/projects/Juventus/platforms/android/cordova/node_modules/q/q.js:137:13)
        Error: spawn EACCES

已尝试解决以下链接中建议的权限问题:

getting Error: spawn EACCES while ionic build android in ubuntu 14.04

还尝试将我的Ionic CLI降级到2.1.0但仍然发生同样的错误。我错过了什么吗?

1 个答案:

答案 0 :(得分:2)

删除android平台文件夹并重新添加。如果不检查文件夹权限,它应该解决您的问题。