'ionic platform build android' - FAILS :(

I have spent hours trying to get this fixed and looked at all the feedback but nothing has really helped. I am on UBUNTU 14.04 can successfully add the android platform, but it fails right at the end of the build, in the post build section. I’ve included my entire console output for reference, but the failed build info is at the very bottom. Any help would be tremendous. Thank you!!

charles@charles:~/WebstormProjects/aoapp$ ionic build android
Running build task...
Building platform android
Running command: /home/charles/WebstormProjects/aoapp/platforms/android/cordova/build 
Buildfile: /home/charles/WebstormProjects/aoapp/platforms/android/build.xml
  [taskdef] Could not load definitions from resource emma_ant.properties. It could not be found.

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 23.0.0
 [checkenv] Installed at /home/charles/adt-bundle/sdk

-setup:
     [echo] Project Name: AlphaOmegaInternationalDentalFraternity
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 20.0.0
     [echo] Resolving Build Target for AlphaOmegaInternationalDentalFraternity...
[gettarget] Project Target:   Android 4.4.2
[gettarget] API level:        19
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: /home/charles/WebstormProjects/aoapp/platforms/android/ant-build/rsObj
    [mkdir] Created dir: /home/charles/WebstormProjects/aoapp/platforms/android/ant-build/rsLibs
     [echo] ----------
     [echo] Resolving Dependencies for AlphaOmegaInternationalDentalFraternity...
[dependency] Library dependencies:
[dependency] 
[dependency] ------------------
[dependency] Ordered libraries:
[dependency] 
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...
  [taskdef] Could not load definitions from resource emma_ant.properties. It could not be found.

nodeps:

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 23.0.0
 [checkenv] Installed at /home/charles/adt-bundle/sdk

-setup:
     [echo] Project Name: CordovaLib
  [gettype] Project Type: Android Library

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 20.0.0
     [echo] Resolving Build Target for CordovaLib...
[gettarget] Project Target:   Android 4.4.2
[gettarget] API level:        19
     [echo] ----------
     [echo] Creating output directories if needed...
     [echo] ----------
     [echo] Resolving Dependencies for CordovaLib...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency] 
[dependency] ------------------

-code-gen:
[mergemanifest] No changes in the AndroidManifest files.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] No changed resources. R.java and Manifest.java untouched.
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] No need to generate new BuildConfig.

-pre-compile:

-compile:
     [echo] Creating library output jar file...

-post-compile:

-obfuscate:

-dex:
     [echo] Library project: do not convert bytecode...

-crunch:
   [crunch] Crunching PNG Files in source dir: /home/charles/WebstormProjects/aoapp/platforms/android/CordovaLib/res
   [crunch] To destination dir: /home/charles/WebstormProjects/aoapp/platforms/android/CordovaLib/ant-build/res
   [crunch] Crunched 0 PNG files to update cache

-package-resources:
     [echo] Library project: do not package resources...

-package:
     [echo] Library project: do not package apk...

-post-package:

-do-debug:
     [echo] Library project: do not create apk...
[propertyfile] Updating property file: /home/charles/WebstormProjects/aoapp/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: /home/charles/WebstormProjects/aoapp/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: /home/charles/WebstormProjects/aoapp/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: /home/charles/WebstormProjects/aoapp/platforms/android/CordovaLib/ant-build/build.prop

-post-build:

debug:

-code-gen:
[mergemanifest] Found modified input file
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [aapt] /home/charles/WebstormProjects/aoapp/platforms/android/res/xml/config.xml:33: error: Error parsing XML: unbound prefix

BUILD FAILED
/home/charles/adt-bundle/sdk/tools/ant/build.xml:653: The following error occurred while executing this line:
/home/charles/adt-bundle/sdk/tools/ant/build.xml:698: null returned: 1

Total time: 2 seconds
Error code 1 for command: ant with args: debug,-f,/home/charles/WebstormProjects/aoapp/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: /home/charles/WebstormProjects/aoapp/platforms/android/cordova/build: Command failed with exit code 2
    at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:755:16)
    at Process.ChildProcess._handle.onexit (child_process.js:822:5)
ERROR: Unable to build app on platform android. Please see console for more info.
Exiting.

Did a quick look up and found this.

Try running ant clean in your project folder.

That didn’t work. I tried so many things and finally found the combination that works for me. What I ended up doing is loading $ npm install -g phonegap and then $ phonegap create myApp. It adds files to the project tree that IONIC doesn’t. I then copied over my IONIC directory files. Then I did a $ phonegap build android and then $ ant release from the /platforms/android directory and I ended up with an unsigned APK file. Afterwards I ran

 $ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore my_application.apk alias_name

to sign my file and then $ zipalign -v 4 your_project_name-unaligned.apk your_project_name.apk - uploaded and successful… This reply isn’t much of a tutorial, but maybe it’ll help someone else fill in the gaps of their builds.

Thank you.

The file emma_ant.properties is not found. That might be because you started your project before installing ant, or maybe on another computer.

I did start the project before installing ANT…ha! Now we might be onto something :slight_smile: I will report back to see if this resolved the issue for everyone else’s benefit. Thanks Bonda

Ok, even with my many steps earlier today, the app will not emulate, gives an error in the emulator “Unfortunately, Alpha Omega has stopped”, so since your post Bonda, I fired up a brand new project $ ionic start ionic-build-test - then I ran $ ionic platform add android and $ ionic build android - both with no errors…I am happy at this point…until, I ran $ ionic emulate android…emulator opens and “Unfortunately, HelloCordova has stopped” - damn, so close…

Maybe this errors are caused by the emulator? Do you have any real device to use for testing?
Also, you can consider using other emulators, for example, for myself I use http://www.genymotion.com/ which provides android emulators for almost any android version and works pretty well and much faster than the eclipse emulator. And its free for personal use

Bonda - In a hurry this afternoon, I pushed the new build to Google (an internal app, not for public use) and didn’t realize it was a bad build until I downloaded and installed on my phone, which of course, failed to launch, so I don’t think its the emulator itself, but maybe the settings. But, if the build was good and only the emulator was bad, then it should have been fine on Google Play, so I have to believe it has something to do with the build itself.

Also, I don’t use Eclipse, I use IntelliJ. What is your opinion between the two?

Sorry to hear that!
At this point i dont know if i can be useful to you. But at least I can give you two suggestions and let’s see what happens.

First, try to emulate your app without any of your javascript or HTML code. Just a plain index.html hello world file. If it works, we know that the issues are on javascript. And then you can delete parts of your app until it works again.

If it still fails, just create a new project without any plugins (you can see the plugins of your code in CLI typing: cordova plugins ls and remove them by typing cordova plugins rm plugin-name

If it still fails this way, we migh be fucked, but there are one last shot worth the try.
Instead of using ionic platform add, ionic build android and ionic emulate, follow the exact same steps that you’ve done in your previous post but using cordova.

(re)install cordova by typing sudo npm install -g cordova (sudo required because you are on ubuntu), create a new project cordova create hello com.example.hello HelloWorld, and put there all your code.

cordova platform add android, cordova build android and cordova emulate android in that order.
Ionic is build on top of cordova, but we never know, right?

Ps: never used eclipse or intelliJ. I use Sublime Text for all my projects. But i’ve heard that both of them are great. I just assumed that you used eclipse because when you download the android sdk bundle, it comes with eclipse

Tried everything, but still cant an emulation without it crashing, well it never launches. The only thing left for me to figure out is the error [taskdef] Could not load definitions from resource emma_ant.properties - It happens at the first part fo the build and is the only issue unaccounted for.

FIXED!!

I found the problem. I am running Ubuntu 14.04 64-bit and apparently Debian still needs i386 architecture. Here are the two links, in order that solved the problem. Now, build with no errors and successful emulation !!!

Link explaining exact same issue…

Link to solution!!

2 Likes

Nice to hear.
Good luck with your app!

Hi! I’m develop on Mac OS 10.9 and I fail in this error too.

Hey @GeorgeYang, lets start a new post for yours. As your platform is for mac and not ubuntu

But I fixed it by taking the idea of @rooster 's
And my step:
1st: “Cordova create newApp”;
2nd: Copy the folder “www” from myApp project;
3rd: Replace the folder “www” of newApp project;
4th: “Cordova build newApp”------Successfully;

Try to run “ionic resources”.

I just started with ionic and facing issues with building ionic.

command: ionic build android (from project dir)
OS: win7
java version: 1.6
Error:
D:\tanwar\ionic\testing1>ionic build android
Updated the hooks directory to have execute permissions
Running command: D:\Installed\nodejs\node.exe D:\tanwar\ionic\testing1\hooks\after_prepare\010_add_platform_class.js D:\tanwar\ionic\testing1
add to body class: platform-android
Running command: D:\tanwar\ionic\testing1\platforms\android\cordova\build.bat
ANDROID_HOME=D:\Installed\Android\android-sdk
JAVA_HOME=D:\Installed\Java\jdk1.6.0_45
Running: D:\tanwar\ionic\testing1\platforms\android\gradlew cdvBuildDebug -b D:\tanwar\ionic\testing1\platforms\android\build.gradle -Dorg.gradle.daemon=true
events.js:85
throw er; // Unhandled ‘error’ event
^
Error: spawn cmd ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20
at process._tickCallback (node.js:355:11)
ERROR building one of the platforms: Error: D:\tanwar\ionic\testing1\platforms\android\cordova\build.bat: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: D:\tanwar\ionic\testing1\platforms\android\cordova\build.bat: Command failed with exit code 1
at ChildProcess.whenDone (C:\Users\Tanwar\AppData\Roaming\npm\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)

I am stuck with this problem for over 3 days and could solve this.

nodejs version 0.12.x(latest available for download)

steps:

  1. installed nodejs
  2. npm install -g cordova ionic gulp
  3. ionic start testing1 tabs
  4. ionic platform add android
    5 ionic build android(this i failing with above message)

Please help understand what I am doing wrong here.

Re-installed my OS and followed same steps as in guide. Worked for me now.

Checked for android.

Build in android sucessfull but ionic serve not created.how to process next further steps