0

I'm very new to phonegap and tried to create a simple test app by entering the commands like described on the phonegap install webpage.

I use Windows 7 64-bit.

Unfortunately, I get the following error in the command-line:

  -pre-compile:   

   -compile:    
   [javac] Compiling 93 source files to D:\phonegap_project\test5\platforms\and
roid\CordovaLib\ant-build\classes

[javac] D:\phonegap_project\test5\platforms\android\CordovaLib\src\org\apach

e\cordova\CordovaWebView.java:266: error: cannot find symbol
    [javac]     @TargetApi(Build.VERSION_CODES.KITKAT)
    [javac]                                   ^
    [javac]   symbol:   variable KITKAT
    [javac]   location: class VERSION_CODES

    [javac] D:\phonegap_project\test5\platforms\android\CordovaLib\src\com\squar
eup\okhttp\internal\http\HttpsURLConnectionImpl.java:347: error: method does not
 override or implement a method from a supertype

    [javac]   @Override public void setFixedLengthStreamingMode(long contentLeng
th) {
    [javac]   ^


    [javac] D:\phonegap_project\test5\platforms\android\CordovaLib\src\org\apach
e\cordova\CordovaWebView.java:230: error: cannot find symbol


    [javac]             android.os.Build.VERSION.SDK_INT >= android.os.Build.VER
SION_CODES.KITKAT) {


    [javac]       ^
    [javac]   symbol:   variable KITKAT
    [javac]   location: class VERSION_CODES
    [javac] D:\phonegap_project\test5\platforms\android\CordovaLib\src\org\apach
e\cordova\CordovaWebView.java:269: error: cannot find symbol

    [javac]             WebView.setWebContentsDebuggingEnabled(true);

    [javac]                    ^


    [javac]   symbol:   method setWebContentsDebuggingEnabled(boolean)
    [javac]   location: class WebView

    [javac] D:\phonegap_project\test5\platforms\android\CordovaLib\src\org\apach
e\cordova\IceCreamCordovaWebViewClient.java:85: error: cannot find symbol
    [javac]         return android.os.Build.VERSION.SDK_INT >= android.os.Build.
VERSION_CODES.KITKAT && "content".equals(uri.getScheme());
    [javac]
             ^
    [javac]   symbol:   variable KITKAT
    [javac]   location: class VERSION_CODES

    [javac] Note: Some input files use or override a deprecated API.

    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] 5 errors


BUILD FAILED
D:\Android\adt-bundle-windows-x86-20130522\sdk\tools\ant\build.xml:601: The foll
owing error occurred while executing this line:
D:\Android\adt-bundle-windows-x86-20130522\sdk\tools\ant\build.xml:720: The foll
owing error occurred while executing this line:
D:\Android\adt-bundle-windows-x86-20130522\sdk\tools\ant\build.xml:734: Compile
failed; see the compiler error output for details.

Total time: 2 seconds


D:\phonegap_project\test5\platforms\android\cordova\node_modules\q\q.js:126
                    throw e;
                          ^
Error code 1 for command: cmd with args: /s,/c,ant,debug,-f,D:\phonegap_project\
test5\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen


Error: D:\phonegap_project\test5\platforms\android\cordova\build.bat: Command fa
iled with exit code 8
    at ChildProcess.whenDone (C:\Users\user\AppData\Roaming\npm\node_modules\pho
negap\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:13
5:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:756:16)
    at Process.ChildProcess._handle.onexit (child_process.js:823:5)
Dawson Loudon
  • 6,029
  • 2
  • 27
  • 31
Ashok Kumar
  • 43
  • 1
  • 8

2 Answers2

4

My quick guess is that you installed a version of Android SDK tools that is too old for the version of cordova you're using.

The message says Build.VERSION_CODES.KITKAT is not found and indicates that it's just the KITKAT part that is unknown not Build.VERSION_CODES, so I deduct that

  • you correctly insalled android sdk and added to the path
  • you installed a version of Cordova that requires minimum Android SDK 19
  • but you have an older version of the sdk platform insalled.

To correct your problem, run the android command in a terminal and then upgrade Android sdk tools and Android SDK Platform to version 19 (KitKat) or greater.

QuickFix
  • 11,661
  • 2
  • 38
  • 50
0

There are three parts needed to be able to build Android in Cordova:

  1. Android SDK must be installed (at the very least the stand alone SDK tools).
  2. Android.exe / SDK must be added to your PATH.
  3. Update the Android SDK after installation to be sure you have the latest.

Installing Android SDK

For this to work, you need the ANDROID SDK installed. The download page is here.

Add Android SDK directory to PATH

Once you've installed the SDK, you need to add it to your PATH.

The PATH value you give will be wherever you installed it.

Updating Android SDK via Command Line

Once you do that, run:

android update sdk --no-ui

from the command line to ensure you have the latest SDK. And then try your build again.

Community
  • 1
  • 1
George Stocker
  • 57,289
  • 29
  • 176
  • 237