Translate

[Cordova] cordova(phonegap) 빌드 시 'ANDROID_HOME is set to a non-existant path' 오류 문제



Cordova(PhoneGap) 설치하여 프로젝트를 create 후에 빌드를 하니 다음과 같이 오류가 발생을 했다.



C:\Users\1004lucifer\CordovaProjects\helloworld>cordova build android
Running command: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\cordova\build.bat
[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
ERROR building one of the platforms: Error: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\cordova\build.bat: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\cordova\build.bat: Command failed with exit code 2
    at ChildProcess.whenDone (C:\Users\1004lucifer\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:1008:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1080:5)

C:\Users\1004lucifer\CordovaProjects\helloworld>



ANDROID_HOME path 가 셋팅되어 있지 않다고 해서 환경변수에 Android-sdk Path 를 셋팅 해 주었다.







그 후 다음과 같은 오류가 발생을 했다.


C:\Users\1004lucifer\CordovaProjects\helloworld>cordova build android
Running command: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\cordova\build.bat
[Error: ANDROID_HOME is set to a non-existant path: "C:\Data\android-sdk-windows"]
ERROR building one of the platforms: Error: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\cordova\build.bat: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\cordova\build.bat: Command failed with exit code 2
    at ChildProcess.whenDone (C:\Users\1004lucifer\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:1008:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1080:5)

C:\Users\1004lucifer\CordovaProjects\helloworld>










stackoverflow 에 ant 가 설치 되어있어야 한다고 하는걸 봤지만 Cordova Site(Link) 와 책에서도 Ant에 대한 언급은 없어서 설마 했는데..
한참을 찾아보다가 Ant 설치 후 잘 되는걸 확인했다. ㅠㅠ


다음과 같이 셋팅을 했다.
1. ANT (http://ant.apache.org/) 다운로드 및 설치
2. {ANT_HOME}/bin 디렉토리를 환경변수의 path 에 추가
(윈도우는 환경변수 셋팅 후 cmd를 다시 띄워줘야 적용이 된다.)



C:\Users\1004lucifer\CordovaProjects\helloworld>cordova build android
Running command: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\cordova\build.bat
Buildfile: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 24.1.2
 [checkenv] Installed at C:\Data\android-sdk-windows

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

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 22.0.0
     [echo] Resolving Build Target for MainActivity...
[gettarget] Project Target:   Android 5.0.1
[gettarget] API level:        21
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build
    [mkdir] Created dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\res
    [mkdir] Created dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\rsObj
    [mkdir] Created dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\rsLibs
    [mkdir] Created dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-gen
    [mkdir] Created dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\classes
    [mkdir] Created dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\dexedLibs
     [echo] ----------
     [echo] Resolving Dependencies for MainActivity...
[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 24.1.2
 [checkenv] Installed at C:\Data\android-sdk-windows

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

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 22.0.0
     [echo] Resolving Build Target for MainActivity...
[gettarget] Project Target:   Android 5.0.1
[gettarget] API level:        21
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\res
    [mkdir] Created dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\libs
    [mkdir] Created dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\ant-build
    [mkdir] Created dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\ant-build\res
    [mkdir] Created dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\ant-build\rsObj
    [mkdir] Created dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\ant-build\rsLibs
    [mkdir] Created dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\ant-gen
    [mkdir] Created dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\ant-build\classes
    [mkdir] Created dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\ant-build\dexedLibs
     [echo] ----------
     [echo] Resolving Dependencies for MainActivity...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------

-code-gen:
[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...
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:

-compile:
    [javac] Compiling 98 source files to C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\ant-build\classes
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
     [echo] Creating library output jar file...
      [jar] Building jar: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\ant-build\classes.jar

-post-compile:

-obfuscate:

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

-crunch:
   [crunch] Crunching PNG Files in source dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\res
   [crunch] To destination dir: C:\Users\1004lucifer\CordovaProjects\helloworld\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] Creating new property file: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\ant-build\build.prop
[propertyfile] Updating property file: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\ant-build\build.prop
[propertyfile] Updating property file: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\ant-build\build.prop
[propertyfile] Updating property file: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\ant-build\build.prop

-post-build:

debug:

-code-gen:
[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...
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:
     [echo] Set jars path to: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\ant-build\classes.jar

-compile:
    [javac] Compiling 3 source files to C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\classes

-post-compile:

-obfuscate:

-dex:
      [dex] input: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\classes
      [dex] input: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\ant-build\classes.jar
      [dex] Pre-Dexing C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\ant-build\classes.jar -> classes-ab66162190587b093963c982552bef1c.jar
      [dex] Converting compiled files and external libraries into C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\classes.dex...
       [dx] Merged dex A (7 defs/2.2KiB) with dex B (223 defs/326.2KiB). Result is 230 defs/400.1KiB. Took 0.3s

-crunch:
   [crunch] Crunching PNG Files in source dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\res
   [crunch] To destination dir: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\res
   [crunch] Processing image to cache: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\res\drawable-hdpi\icon.png => C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-bui
ld\res\drawable-hdpi\icon.png
   [crunch]   (processed image to cache entry C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\res\drawable-hdpi\icon.png: 67% size of source)
   [crunch] Processing image to cache: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\res\drawable-land-hdpi\screen.png => C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\
ant-build\res\drawable-land-hdpi\screen.png
   [crunch]   (processed image to cache entry C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\res\drawable-land-hdpi\screen.png: 97% size of source)
   [crunch] Processing image to cache: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\res\drawable-land-ldpi\screen.png => C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\
ant-build\res\drawable-land-ldpi\screen.png
   [crunch]   (processed image to cache entry C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\res\drawable-land-ldpi\screen.png: 96% size of source)
   [crunch] Processing image to cache: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\res\drawable-land-mdpi\screen.png => C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\
ant-build\res\drawable-land-mdpi\screen.png
   [crunch]   (processed image to cache entry C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\res\drawable-land-mdpi\screen.png: 97% size of source)
   [crunch] Processing image to cache: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\res\drawable-land-xhdpi\screen.png => C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android
\ant-build\res\drawable-land-xhdpi\screen.png
   [crunch]   (processed image to cache entry C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\res\drawable-land-xhdpi\screen.png: 99% size of source)
   [crunch] Processing image to cache: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\res\drawable-ldpi\icon.png => C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-bui
ld\res\drawable-ldpi\icon.png
   [crunch]   (processed image to cache entry C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\res\drawable-ldpi\icon.png: 0% size of source)
   [crunch] Processing image to cache: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\res\drawable-mdpi\icon.png => C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-bui
ld\res\drawable-mdpi\icon.png
   [crunch]   (processed image to cache entry C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\res\drawable-mdpi\icon.png: 0% size of source)
   [crunch] Processing image to cache: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\res\drawable-port-hdpi\screen.png => C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\
ant-build\res\drawable-port-hdpi\screen.png
   [crunch]   (processed image to cache entry C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\res\drawable-port-hdpi\screen.png: 97% size of source)
   [crunch] Processing image to cache: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\res\drawable-port-ldpi\screen.png => C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\
ant-build\res\drawable-port-ldpi\screen.png
   [crunch]   (processed image to cache entry C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\res\drawable-port-ldpi\screen.png: 97% size of source)
   [crunch] Processing image to cache: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\res\drawable-port-mdpi\screen.png => C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\
ant-build\res\drawable-port-mdpi\screen.png
   [crunch]   (processed image to cache entry C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\res\drawable-port-mdpi\screen.png: 99% size of source)
   [crunch] Processing image to cache: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\res\drawable-port-xhdpi\screen.png => C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android
\ant-build\res\drawable-port-xhdpi\screen.png
   [crunch]   (processed image to cache entry C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\res\drawable-port-xhdpi\screen.png: 99% size of source)
   [crunch] Processing image to cache: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\res\drawable-xhdpi\icon.png => C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-bu
ild\res\drawable-xhdpi\icon.png
   [crunch]   (processed image to cache entry C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\res\drawable-xhdpi\icon.png: 53% size of source)
   [crunch] Processing image to cache: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\res\drawable\icon.png => C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\re
s\drawable\icon.png
   [crunch]   (processed image to cache entry C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\res\drawable\icon.png: 53% size of source)
   [crunch] Crunched 13 PNG files to update cache

-package-resources:
     [aapt] Creating full resource package...

-package:
[apkbuilder] Current build type is different than previous build: forced apkbuilder run.
[apkbuilder] Creating MainActivity-debug-unaligned.apk and signing it with a debug key...

-post-package:

-do-debug:
 [zipalign] Running zip align on final apk...
     [echo] Debug Package: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\MainActivity-debug.apk
[propertyfile] Creating new property file: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\build.prop
[propertyfile] Updating property file: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\build.prop
[propertyfile] Updating property file: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\build.prop
[propertyfile] Updating property file: C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\build.prop

-post-build:
     [move] Moving 1 file to C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build
     [move] Moving 1 file to C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\CordovaLib\ant-build

debug:

BUILD SUCCESSFUL
Total time: 36 seconds
Built the following apk(s):
    C:\Users\1004lucifer\CordovaProjects\helloworld\platforms\android\ant-build\MainActivity-debug.apk

C:\Users\1004lucifer\CordovaProjects\helloworld>



참조: http://stackoverflow.com/questions/20323787/cordova-platform-add-android-not-working-while-listing-android-targets

댓글