Ionic Run Android错误 - 在Ubuntu 16

时间:2016-08-17 14:54:02

标签: android node.js cordova ubuntu ionic-framework

我正在运行Ubuntu 16。

这是我的系统信息:

Your system information:

Cordova CLI: 6.3.1
Gulp version:  CLI version 1.2.2
Gulp local:   Local version 3.9.1
Ionic Framework Version: 1.2.4-nightly-1917
Ionic CLI Version: 2.0.0
Ionic App Lib Version: 2.0.0-beta.20
OS: Distributor ID: Ubuntu Description: Ubuntu 16.04.1 LTS 
Node Version: v4.4.7

当我尝试从我的项目目录中执行 sudo ionic run android sudo ionic build android 时,我得到了这个输出:

Running command: /home/simon/flash-trader/hooks/after_prepare/010_add_platform_class.js /home/simon/flash-trader


add to body class: platform-android


Caught exception:
 TypeError: Can't call method on  undefined
    at TypeError (native)
    at module.exports (/home/simon/flash-trader/node_modules/karma/node_modules/core-js/modules/_defined.js:3:28)
    at createHTML (/home/simon/flash-trader/node_modules/karma/node_modules/core-js/modules/_string-html.js:7:19)
    at bold (/home/simon/flash-trader/node_modules/karma/node_modules/core-js/modules/es6.string.bold.js:5:12)
    at cb (/usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/lib/winston/logger.js:206:7)
    at done (/usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/node_modules/async/lib/async.js:167:19)
    at /usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/node_modules/async/lib/async.js:40:16
    at /usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/lib/winston/logger.js:193:9
    at Console.log (/usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/lib/winston/transports/console.js:127:3)
    at emit (/usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/lib/winston/logger.js:186:17)
    at /usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/node_modules/async/lib/async.js:157:13
    at _each (/usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/node_modules/async/lib/async.js:57:9)
    at Object.async.each (/usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/node_modules/async/lib/async.js:156:9)
    at Logger.log (/usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/lib/winston/logger.js:214:9)
    at target.(anonymous function) [as error] (/usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/lib/winston/common.js:54:18)
    at Socket.<anonymous> (/usr/lib/node_modules/ionic/lib/utils/cordova.js:83:11)

Mind letting us know? https://github.com/driftyco/ionic-cli/issues


Caught exception:
 TypeError: Can't call method on  undefined
    at TypeError (native)
    at module.exports (/home/simon/flash-trader/node_modules/karma/node_modules/core-js/modules/_defined.js:3:28)
    at createHTML (/home/simon/flash-trader/node_modules/karma/node_modules/core-js/modules/_string-html.js:7:19)
    at bold (/home/simon/flash-trader/node_modules/karma/node_modules/core-js/modules/es6.string.bold.js:5:12)
    at cb (/usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/lib/winston/logger.js:206:7)
    at done (/usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/node_modules/async/lib/async.js:167:19)
    at /usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/node_modules/async/lib/async.js:40:16
    at /usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/lib/winston/logger.js:193:9
    at Console.log (/usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/lib/winston/transports/console.js:127:3)
    at emit (/usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/lib/winston/logger.js:186:17)
    at /usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/node_modules/async/lib/async.js:157:13
    at _each (/usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/node_modules/async/lib/async.js:57:9)
    at Object.async.each (/usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/node_modules/async/lib/async.js:156:9)
    at Logger.log (/usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/lib/winston/logger.js:214:9)
    at target.(anonymous function) [as error] (/usr/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/winston/lib/winston/common.js:54:18)
    at Socket.<anonymous> (/usr/lib/node_modules/ionic/lib/utils/cordova.js:83:11) 

是的,完全相同的错误两次。我已经按照developer.android.com上的规定在Ubuntu上设置了我的手机。调试模式已启用。设置了所有环境变量(我相信。)我通过Android Studio安装了Android SDK。

这个错误很秘密。有没有人见过它?

但是,离子服务可以完美地构建和运行项目。

Google搜索会出现一些相关问题,但似乎没有任何与我的确切情况相符的问题。谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

最后,我所做的是一堆事物。

我必须执行chown -R $USER ~/[project name],以便我们不必**sudo** ionic。 Sudo明显地将不同的环境变量用于shell的其余部分,因此无法访问ANDROID_HOME等。

我还必须更改我的JAVA_HOME,因为它设置为[jdk-path] / bin,应该只是[jdk-path] /

我卸载从Google Play商店下载的应用程序版本(因为我尝试构建的应用程序已经发布)也可能有所不同。

我还在cordova.js中更改了一行,在liveReload函数中将log("foo").green.bold更改为log(foo).green

如果你遇到同样的问题,祝你好运。