我对phonegap非常陌生,并尝试通过输入phonegap安装网页上所述的命令来创建一个简单的测试应用。
我使用Windows 7 64位。
不幸的是,我在命令行中收到以下错误:
-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)
答案 0 :(得分:4)
我的快速猜测是,您安装的Android SDK工具版本对于您正在使用的cordova版本来说太旧了。
消息说找不到Build.VERSION_CODES.KITKAT并且表明它只是未知的KITKAT部分而不是Build.VERSION_CODES,所以我扣除了
要解决您的问题,请在终端中运行android
命令,然后将 Android sdk工具和 Android SDK平台升级到版本19(KitKat)或大。
答案 1 :(得分:0)
在Cordova中构建Android需要三个部分:
为此,您需要安装ANDROID SDK。 download page is here。
安装SDK后,you need to add it to your PATH。
您提供的PATH值将是您安装它的位置。
完成后,运行:
android update sdk --no-ui
从命令行确保您拥有最新的SDK。然后再次尝试构建。