Trying to build an android project (Macosx)


#1

Hi

I’m trying to build one of the default ionic projects, in particular the “tabs” one. (I’m on a mac with 10.9)

I do the following:

  1. Downloaded adt-bundle-mac-x86_64-20140321.zip

  2. Added the sdk/tools directory to my path variable

  3. Java is installed (version 1.6.0_65)

  4. npm install -g cordova ionic

    cordova version (3.4.1-0.1.0)

  5. ionic start Test tabs

  6. cd Test

  7. ionic platform add android

  8. ionic build android

I then get the following error

-compile:
    [javac] Compiling 5 source files to /Users/leonv/Documents/cordova/Test/platforms/android/ant-build/classes
    [javac] /Users/leonv/Documents/cordova/Test/platforms/android/src/org/apache/cordova/statusbar/StatusBar.java:70: cannot find symbol
    [javac] symbol  : class PluginResult
    [javac] location: class org.apache.cordova.statusbar.StatusBar
    [javac]             callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible));
    [javac]                                                  ^
    [javac] /Users/leonv/Documents/cordova/Test/platforms/android/src/org/apache/cordova/statusbar/StatusBar.java:70: package PluginResult does not exist
    [javac]             callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible));
    [javac]                                                                           ^
    [javac] 2 errors

BUILD FAILED
/Users/leonv/development/adt-bundle-mac-x86_64-20140321/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/Users/leonv/development/adt-bundle-mac-x86_64-20140321/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.

Total time: 3 seconds
Error code 1 for command: ant with args: debug,-f,/Users/leonv/Documents/cordova/Test/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: /Users/leonv/Documents/cordova/Test/platforms/android/cordova/build: Command failed with exit code 2
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/src/superspawn.js:126:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Process.ChildProcess._handle.onexit (child_process.js:810:5)
ERROR: Unable to build app on platform android. Please see console for more info. 

Int my Test/platforms/android/CordovaLib/src/org/apache/cordova directory I do see a PluginResult.java file
In my Test/platforms/android/CordovaLib/ant-build/classes/org/apache/cordova directory I do see a PluginResult.class file

Many thanks for the help


#2

I am experiencing the same issue.


#3

Same error in ubuntu 14.04
solution:
1.open /myApp/platforms/android/src/org/apache/cordova/statusbar/StatusBar.java
2. change:
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaArgs;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;

TO

import org.apache.cordova.*;

save and build again.
SUCCESSFUL!
Try this, I think it’s helpful.


#4

@ginozhao you biscuit, it works for me.


#6

Any luck with this??? I was able to build the sample Tabs application just a few seconds ago and now boom…it fails the compilation throwing the above two errors


#7

Also i had face the same thing yesterday i was able to build without any modification on code, today I have test a new project and doesn’t work anymore , you need to remove those lines :
Open /myApp/platforms/android/src/org/apache/cordova/statusbar/StatusBar.java
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaArgs;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;
And replace them with
import org.apache.cordova.*;
then build your app


#8

Thanks

Should this be done on other plugins too?


#9

I realised where I was going wrong. Each time I created a project I closed the CMD prompt and restarted the procedure. And each time the Statusbar.java was getting overridden. Then I realised just once I need to add your solution and keep building in the same prompt.


#10

But I am still getting blank page for my index.html. IT works well in chrome. I referred to Christopher’s Sociogram app and it works so well. I am not able to figure out whats wrong with mine.
Following are my index.html and app.js links
index.html - http://pastebin.com/gADtRQ0p

app.js - http://pastebin.com/KZhRJVkd