java - 使用 Grade/ant 进行 Cordova 5 构建会抛出 java 编译错误

标签 java android cordova ant gradle

安装了 Android SDK Manager 中列出的所有工具。

JAVA_HOME指向jdk7

GRADLE_HOME、ANT_HOME、ANDROID_HOME 是其他正确配置的环境变量。

已经尝试删除并再次添加平台 android 到 cordova 项目。

C:\Users\Pratik\Documents\routeplannerfront\platforms\android\CordovaLib\src\org
\apache\cordova\CordovaClientCertRequest.java:25: error: cannot find symbol
import android.webkit.ClientCertRequest;
                     ^
  symbol:   class ClientCertRequest
  location: package android.webkit
C:\Users\Pratik\Documents\routeplannerfront\platforms\android\CordovaLib\src\org
\apache\cordova\CordovaClientCertRequest.java:32: error: cannot find symbol
    private final ClientCertRequest request;
                  ^
  symbol:   class ClientCertRequest
  location: class CordovaClientCertRequest
C:\Users\Pratik\Documents\routeplannerfront\platforms\android\CordovaLib\src\org
\apache\cordova\CordovaClientCertRequest.java:34: error: cannot find symbol
    public CordovaClientCertRequest(ClientCertRequest request) {
                                    ^
  symbol:   class ClientCertRequest
  location: class CordovaClientCertRequest
C:\Users\Pratik\Documents\routeplannerfront\platforms\android\CordovaLib\src\org
\apache\cordova\engine\SystemWebChromeClient.java:251: error: cannot find symbol

    public boolean onShowFileChooser(WebView webView, final ValueCallback<Uri[]>
 filePathsCallback, final WebChromeClient.FileChooserParams fileChooserParams) {


                                         ^
  symbol:   class FileChooserParams
  location: class WebChromeClient
C:\Users\Pratik\Documents\routeplannerfront\platforms\android\CordovaLib\src\org
\apache\cordova\engine\SystemWebViewClient.java:29: error: cannot find symbol
import android.webkit.ClientCertRequest;
                     ^
  symbol:   class ClientCertRequest
  location: package android.webkit
C:\Users\Pratik\Documents\routeplannerfront\platforms\android\CordovaLib\src\org
\apache\cordova\engine\SystemWebViewClient.java:116: error: cannot find symbol
    public void onReceivedClientCertRequest (WebView view, ClientCertRequest req
uest)
                                                           ^
  symbol:   class ClientCertRequest
  location: class SystemWebViewClient
C:\Users\Pratik\Documents\routeplannerfront\platforms\android\CordovaLib\src\org
\apache\cordova\engine\SystemWebChromeClient.java:249: error: cannot find symbol

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
                                  ^
  symbol:   variable LOLLIPOP
  location: class VERSION_CODES
C:\Users\Pratik\Documents\routeplannerfront\platforms\android\CordovaLib\src\org
\apache\cordova\engine\SystemCookieManager.java:37: error: cannot find symbol
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                                                        ^
  symbol:   variable LOLLIPOP
  location: class VERSION_CODES
C:\Users\Pratik\Documents\routeplannerfront\platforms\android\CordovaLib\src\org
\apache\cordova\engine\SystemCookieManager.java:38: error: cannot find symbol
            cookieManager.setAcceptThirdPartyCookies(webView, true);
                         ^
  symbol:   method setAcceptThirdPartyCookies(WebView,boolean)
  location: variable cookieManager of type CookieManager
C:\Users\Pratik\Documents\routeplannerfront\platforms\android\CordovaLib\src\org
\apache\cordova\engine\SystemCookieManager.java:59: error: cannot find symbol
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                                                        ^
  symbol:   variable LOLLIPOP
  location: class VERSION_CODES
C:\Users\Pratik\Documents\routeplannerfront\platforms\android\CordovaLib\src\org
\apache\cordova\engine\SystemCookieManager.java:60: error: cannot find symbol
            cookieManager.flush();
                         ^
  symbol:   method flush()
  location: variable cookieManager of type CookieManager
C:\Users\Pratik\Documents\routeplannerfront\platforms\android\CordovaLib\src\org
\apache\cordova\engine\SystemWebChromeClient.java:257: error: cannot find symbol

                    Uri[] result = WebChromeClient.FileChooserParams.parseResult
(resultCode, intent);
                                                  ^
  symbol:   variable FileChooserParams
  location: class WebChromeClient
C:\Users\Pratik\Documents\routeplannerfront\platforms\android\CordovaLib\src\org
\apache\cordova\engine\SystemWebChromeClient.java:250: error: method does not ov
erride or implement a method from a supertype
    @Override
    ^
C:\Users\Pratik\Documents\routeplannerfront\platforms\android\CordovaLib\src\org
\apache\cordova\engine\SystemWebViewClient.java:114: error: method does not over
ride or implement a method from a supertype
    @Override
    ^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
14 errors
:CordovaLib:compileDebugJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':CordovaLib:compileDebugJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Total time: 6.446 secs

最佳答案

我使用的是cordova 5.0.0

升级到5.1.1后npm update -g cordova然后使用从项目中删除android

cordova 平台删除 android

然后再次添加android

cordova平台添加android

工作得很好。与此同时,我还安装了 API22,因此其中之一或两者都造成了该问题。

关于java - 使用 Grade/ant 进行 Cordova 5 构建会抛出 java 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30818731/

相关文章:

java - 如何调试AndroidManifest.xml中的应用程序类问题?

android - 漏洞? Fragment 中未显示以编程方式添加的内容

android - 房间多表同对象(多语言数据库)

ios - Cordova InAppBrowser - 单击链接后如何返回 iOS 设备上的应用程序

android - 我无法在 phonegap 构建中加载我的 Polymer 项目

android - sencha Touch 2 + PhoneGap 的正确路径

java - 如何在Android编程中使用Volley并保持代码整洁? (回调问题)

java - AWS S3 Java : doesObjectExist results in 403: FORBIDDEN

java - 字符串数组 - 唯一值的实例

java - 如何从对话框内的edittext获取文本