简体   繁体   中英

Cordova / Phonegap Android - Java / Ant Issue on build?

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.

However with Android, I am 'now' having some issues, when I run cordova build android I get the following error,

/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.

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?

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.

Any help?

Thanks

I solve my problem. On my config.xml I missed the platform tag ir order to configure the icons and splash screen:

<platform name="ios">
</platform>
<platform name="android">
</platform>

Here is the Cordova doc

Maybe you have something misconfigured like me. Hope It helps

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 :

adb logcat

I discovered that, after the .apk upload, my android device rejected it because the signature was different than my previous build.

The solution was dead simple: uninstall the previous version on the device .

Check your device log, error may come from that side !

For me as others might have this problem

I had an old plugin inside the android.json that I hadn't removed.

So I deleted the android.json file and then did

phonegap run android

This will rebuild the plugins from what is in your config.xml

Then it worked for me.

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 --'

<?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="dev@cordova.apache.org" 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.

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.

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.

Try installing ant using:

sudo apt-get install ant

It automates the building process and might be causing this error.

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.

xCode then brought up an issue with my certs which it automatically fixed. All good now.

I hope this helps someone out there who was/is going crazy.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM