Failed to excute "ionic build android"


#1

I’m on a mac with 10.9
And I added platform android.
Then I excute “ionic build android”,but it’s failed.
I get following error

NACIKI-INUI:myApp NACIKI$ ionic build android
Building platform android
Running command: /Users/NACIKI/myApp/platforms/android/cordova/build 
Buildfile: /Users/NACIKI/myApp/platforms/android/build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 23.0.2
 [checkenv] Installed at /Users/NACIKI/android/adt-mac/sdk

-setup:
     [echo] Project Name: android
  [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 android...
[gettarget] Project Target:   Android 4.4.2
[gettarget] API level:        19
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: /Users/NACIKI/myApp/platforms/android/ant-build/rsObj
    [mkdir] Created dir: /Users/NACIKI/myApp/platforms/android/ant-build/rsLibs
     [echo] ----------
     [echo] Resolving Dependencies for android...
[dependency] Library dependencies:
[dependency] 
[dependency] ------------------
[dependency] Ordered libraries:
[dependency] 
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...

nodeps:

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 23.0.2
 [checkenv] Installed at /Users/NACIKI/android/adt-mac/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: /Users/NACIKI/myApp/platforms/android/CordovaLib/res
   [crunch] To destination dir: /Users/NACIKI/myApp/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: /Users/NACIKI/myApp/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: /Users/NACIKI/myApp/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: /Users/NACIKI/myApp/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: /Users/NACIKI/myApp/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] Found modified input file
     [aapt] Generating resource IDs...
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:
     [echo] Set jars path to: /Users/NACIKI/myApp/platforms/android/CordovaLib/ant-build/classes.jar

-compile:
    [javac] Compiling 3 source files to /Users/NACIKI/myApp/platforms/android/ant-build/classes
    [javac] /Users/NACIKI/myApp/platforms/android/src/com/ionicframework/starter/.java:25: <identifier> expected
    [javac] public class  extends CordovaActivity 
    [javac]             ^
    [javac] 1 error

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

Total time: 4 seconds
Error code 1 for command: ant with args: debug,-f,/Users/NACIKI/myApp/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
Error: /Users/NACIKI/myApp/platforms/android/cordova/build: Command failed with exit code 2
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135: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)
Unable to build app on platform android. Please see console for more info.

Very thankful for help.


#2

Fixed it!
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; PS: File name of images only contain the “[0-9][a-z][A-Z]” and “_”,I take the “-”,it built error;

Hope it can help others!