为Android构建手机缺口应用程序失败

时间:2015-05-01 10:58:57

标签: java android cordova gradle

尝试使用

为Android构建手机间隙应用时
sudo phonegap build android

它因此错误而失败:

:compileDebugJava
/Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/src/org/apache/cordova/inappbrowser/InAppBrowser.java:120: error: cannot find symbol

                                || Config.isUrlWhiteListed(url)) {
                                         ^

  symbol:   method isUrlWhiteListed(String)

  location: class Config

Note: Some input files use or override a deprecated API.

Note: Recompile with -Xlint:deprecation for details.

1 error


FAILED



FAILURE: 
Build failed with an exception.



* What went wrong:

Execution failed for task ':compileDebugJava'.

> 
Compilation failed; see the compiler error output for details.



* Try:

Run with 
--stacktrace option to get the stack trace. Run with 
--info or 
--debug
 option to get more log output.



BUILD FAILED


Total time: 5.607 secs


/Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^

Error code 1 for command: /Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/build.gradle,-Dorg.gradle.daemon=true

ERROR building one of the platforms: Error: /Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project

Error: /Users/youssefsami/Library/Mobile Documents/com~apple~CloudDocs/Developer/Mobile Apps/UzuConvert/platforms/android/cordova/build: Command failed with exit code 1
    at ChildProcess.whenDone (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1015:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1087:5)

我尝试将java_home设置为lib exec中的java别名,但仍然没有。关于可能导致问题的任何想法?

3 个答案:

答案 0 :(得分:24)

这是因为你的InAppBrowser插件已经过时,可能与新版本的Cordova Android平台不同,而不是你第一次安装插件时。我在使用cordova-android@4.0.0和InAppBrowser的0.5.3时遇到了同样的问题。

修复是先删除插件

cordova plugin rm org.apache.cordova.inappbrowser

然后再次添加它(它应该重新安装最新版本的cordova CLI在我的情况下它抓住了0.6)。您可以在plugins / org.apache.cordova.inappbrowser /文件夹中查看RELEASENOTES.md中的版本。

cordova plugin add org.apache.cordova.inappbrowser

您需要删除Android平台并在重新构建之前重新添加它,以便它不会保留旧版本的插件。

cordova platform rm android

cordova platform add android

现在再次构建,错误应该已经消失。

编辑:我刚刚在你的问题的顶部注意到你正在使用phonegap。既然你用cordova标记了(这就是我使用的那些)我用cordova命令回答了,但我猜测几乎相同的过程适用于Phonegap。

答案 1 :(得分:4)

与cordova-android@4.0.0相同的问题 感谢JDawgg你的解决方案比我的好,但是如果有人仍然有这个bug,你可以像这样使用cordova-android@3.6.4:

cordova platform remove android

然后

cordova platform add android@3.6.4

你必须安装android 4.2.2 sdk

最后

sudo phonegap build android

答案 2 :(得分:1)

如果有人使用Meteor并遇到同样的问题,martijnwalraven建议删除旧版cordova-plugin-inappbrowser并添加最新版本:

$ meteor remove cordova:cordova-plugin-inappbrowser
$ meteor add cordova:cordova-plugin-inappbrowser@1.0.1

这对我有用了!