Cordova / Phonegap Android - Java / Ant 构建问题?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27968929/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cordova / Phonegap Android - Java / Ant Issue on build?
提问by user4458505
I have been all over this site, so please forgive me if someone else as posted this but I could not find anything that could fix my issue.
我一直在这个网站上,所以如果其他人发布了这个,请原谅我,但我找不到任何可以解决我的问题的东西。
I am working on a Mac. With my IOS build, I have no problems at all.
我在 Mac 上工作。使用我的 IOS 版本,我完全没有问题。
However with Android, I am 'now' having some issues, when I run cordova build android
I get the following error,
但是,对于 Android,我“现在”遇到了一些问题,运行时cordova build android
出现以下错误,
/Users/x/Library/Android/sdk/tools/ant/build.xml:601: The following error occurred while executing this line:
/Users/x/Library/Android/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/Users/x/Library/Android/sdk/tools/ant/build.xml:734: Class not found: javac1.8
/Users/x/Desktop/One/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: ant with args: debug,-f,/Users/x/Desktop/test/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
ERROR building one of the platforms: Error: /Users/x/Desktop/test/platforms/android/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
I use the word 'now' because this error I thought I had fixed and it was working but I have changed nothing with the PATHS
Any where in my terminal, I can run javac - version
which gives me javac 1.8.0_25
. So it can different see java.
我使用“现在”这个词是因为我认为我已经修复了这个错误并且它正在工作,但是我没有对PATHS
终端中的Any where 进行任何更改,我可以运行javac - version
它给了我javac 1.8.0_25
. 所以它可以不同地看到java。
So I thought Apache Ant might have gone wrong, but when I run ant -version
I get Apache Ant(TM) version 1.9.4 compiled on April 29 2014
- So yes I am running Ant version 1.9.4, which as far as I am aware should work with my java version?
所以我认为 Apache Ant 可能出错了,但是当我运行时,ant -version
我得到Apache Ant(TM) version 1.9.4 compiled on April 29 2014
- 所以是的,我正在运行 Ant 1.9.4 版,据我所知,它应该适用于我的 Java 版本吗?
So my system can access but java & ant without any issue but I can not build my new Android app. I am now running this in a clean, new (without any plugins or my code) build and still it will not work.
所以我的系统可以访问但 java & ant 没有任何问题,但我无法构建我的新 Android 应用程序。我现在在一个干净的、新的(没有任何插件或我的代码)构建中运行它,但它仍然无法工作。
Any help?
有什么帮助吗?
Thanks
谢谢
采纳答案by user4458505
Sorry about posting late, I forgot all about this post. I sorted out my issues. I am not sure why I was having issues, but I re-built my Mac, I installed homebrew to manage ant, that solved all my issues.
抱歉,发布晚了,我忘记了这篇文章。我整理了我的问题。我不确定为什么我会遇到问题,但我重新构建了我的 Mac,我安装了自制软件来管理 ant,这解决了我所有的问题。
回答by Daniel Aron Goldenberg
I solve my problem. On my config.xml I missed the platform tag ir order to configure the icons and splash screen:
我解决了我的问题。在我的 config.xml 中,为了配置图标和启动画面,我错过了平台标签:
<platform name="ios">
</platform>
<platform name="android">
</platform>
Here is the Cordova doc
这是科尔多瓦文档
Maybe you have something misconfigured like me. Hope It helps
也许你有像我一样配置错误的东西。希望能帮助到你
回答by Paul Leclerc
It's my first cordova test in Ubuntu. I have the same error, and thanks to your post I checked my config.xml. It doesn't have the android tag too, that's why I added it but I always have the mistake. Then I would like some explanation about how did you add it ? Certainly very simple but I'm stuck in the cordova install since 3 days --'
这是我在 Ubuntu 中的第一次cordova 测试。我有同样的错误,多亏了你的帖子,我检查了我的 config.xml。它也没有 android 标签,这就是我添加它的原因,但我总是有错误。然后我想解释一下你是如何添加它的?当然非常简单,但我从 3 天起就被困在科尔多瓦安装中 --'
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.clickarmy.testant2" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>testant2</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="[email protected]" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<platform name="android">
</platform>
</widget>
The doc says : "< icon src="res/android/ldpi.png" density="ldpi" / >" But that's not this structure in my android generated dir.
该文档说:“< icon src="res/android/ldpi.png" density="ldpi" />” 但这不是我的 android 生成目录中的这种结构。
Thanks to : "cordova -d platform add android" I'm able to read : "This app does not have launcher icons defined" Even if "Project successfully created" then it's quite sure that my problem is well about icons.
感谢:“cordova -d platform add android”,我能够读到:“此应用程序没有定义启动器图标”即使“项目已成功创建”,也很确定我的问题与图标有关。
I'm on Ubuntu, I have installed and build cordova on my W8 yestarday without this problem ( a lot of others but not this one ;) ). Sry this certainly a stupid question.
我在 Ubuntu 上,我昨天在我的 W8 上安装并构建了cordova,没有这个问题(很多其他的,但不是这个;))。Sry 这当然是一个愚蠢的问题。
回答by U7786
Try installing ant using:
尝试使用以下方法安装 ant:
sudo apt-get install ant
It automates the building process and might be causing this error.
它使构建过程自动化,并且可能导致此错误。
回答by Jamie Hutber
For me as others might have this problem
对我来说,因为其他人可能有这个问题
I had an old plugin inside the android.json
that I hadn't removed.
我有一个旧插件android.json
,我没有删除。
So I deleted the android.json
file and then did
所以我删除了android.json
文件然后做了
phonegap run android
This will rebuild the plugins from what is in your config.xml
这将从你的插件中重建插件 config.xml
Then it worked for me.
然后它对我有用。
回答by AndrewJM
I had a similar issue after my iOS Dev Membership expired (then I renewed it). I tried a ton of stuff, but the solution was to open xCode and try to run the built Cordova app on my device.
在我的 iOS Dev Membership 过期后,我遇到了类似的问题(然后我更新了它)。我尝试了很多东西,但解决方案是打开 xCode 并尝试在我的设备上运行构建的 Cordova 应用程序。
xCode then brought up an issue with my certs which it automatically fixed. All good now.
xCode 然后提出了我的证书问题,它自动修复了。现在一切都很好。
I hope this helps someone out there who was/is going crazy.
我希望这可以帮助那些曾经/正在发疯的人。
回答by Tophe
Tried my android app on two different Linux machines, the first at work, the second at home. Had the same error at home while it had worked at the office. When I started :
在两台不同的 Linux 机器上尝试了我的 android 应用程序,第一台在工作中,第二台在家里。在办公室工作时,在家里也出现了同样的错误。当我开始时:
adb logcat
I discovered that, after the .apk upload, my android device rejected it because the signature was different than my previous build.
我发现,在 .apk 上传后,我的 android 设备拒绝了它,因为签名与我之前的版本不同。
The solution was dead simple: uninstall the previous version on the device.
解决方案非常简单:卸载设备上的先前版本。
Check your device log, error may come from that side !
检查您的设备日志,错误可能来自那一侧!