Cordova Android项目无法编译

时间:2015-03-05 11:43:47

标签: android cordova ant

Cordova版本:4.3.0

java版" 1.8.0_40" 64位

OS X 10.10.2

Ant版本:1.9.4

enter image description here

目标android SDK我使用的是19。

当我跑步'蚂蚁释放'在platforms / android / CordovaLib文件夹中,我得到以下输出错误:

Buildfile: .../platforms/android/CordovaLib/build.xml

-set-mode-check:

-set-release-mode:

-release-obfuscation-check:
     [echo] proguard.config is ${proguard.config}

-pre-build:

-check-env:
 [checkenv] Android SDK Tools Revision 24.1.2
 [checkenv] Installed at /Users/.../Library/Android/sdk

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

-build-setup:
[getbuildtools] Using latest Build Tools: 21.1.2
     [echo] Resolving Build Target for MainActivity...
[gettarget] Project Target:   Android 4.4.2
[gettarget] API level:        19
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: .../platforms/android/CordovaLib/bin/rsObj
    [mkdir] Created dir: .../platforms/android/CordovaLib/bin/rsLibs
     [echo] ----------
     [echo] Resolving Dependencies for MainActivity...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency] 
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'release'...
   [subant] No sub-builds to iterate on

-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] Generating BuildConfig class.

-pre-compile:

-compile:
    [javac] Compiling 98 source files to .../platforms/android/CordovaLib/bin/classes
    [javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release
    [javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release
    [javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
    [javac] .../platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebViewClient.java:35: error: cannot find symbol
    [javac] import android.webkit.ClientCertRequest;
    [javac]                      ^
    [javac]   symbol:   class ClientCertRequest
    [javac]   location: package android.webkit
    [javac] .../platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebViewClient.java:145: error: cannot find symbol
    [javac]     public void onReceivedClientCertRequest (WebView view, ClientCertRequest request)
    [javac]                                                            ^
    [javac]   symbol:   class ClientCertRequest
    [javac]   location: class CordovaWebViewClient
    [javac] .../platforms/android/CordovaLib/src/org/apache/cordova/CordovaChromeClient.java:342: error: cannot find symbol
    [javac]     public boolean onShowFileChooser(WebView webView, final ValueCallback<Uri[]> filePathsCallback, final WebChromeClient.FileChooserParams fileChooserParams) {
    [javac]                                                                                                                          ^
    [javac]   symbol:   class FileChooserParams
    [javac]   location: class WebChromeClient
    [javac] .../platforms/android/CordovaLib/src/org/apache/cordova/CordovaClientCertRequest.java:25: error: cannot find symbol
    [javac] import android.webkit.ClientCertRequest;
    [javac]                      ^
    [javac]   symbol:   class ClientCertRequest
    [javac]   location: package android.webkit
    [javac] .../platforms/android/CordovaLib/src/org/apache/cordova/CordovaClientCertRequest.java:32: error: cannot find symbol
    [javac]     private final ClientCertRequest request;
    [javac]                   ^
    [javac]   symbol:   class ClientCertRequest
    [javac]   location: class CordovaClientCertRequest
    [javac] .../platforms/android/CordovaLib/src/org/apache/cordova/CordovaClientCertRequest.java:34: error: cannot find symbol
    [javac]     public CordovaClientCertRequest(ClientCertRequest request) {
    [javac]                                     ^
    [javac]   symbol:   class ClientCertRequest
    [javac]   location: class CordovaClientCertRequest
    [javac] .../platforms/android/CordovaLib/src/org/apache/cordova/CordovaChromeClient.java:340: error: cannot find symbol
    [javac]     @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    [javac]                                   ^
    [javac]   symbol:   variable LOLLIPOP
    [javac]   location: class VERSION_CODES
    [javac] .../platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java:197: error: cannot find symbol
    [javac]         if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
    [javac]                                                        ^
    [javac]   symbol:   variable LOLLIPOP
    [javac]   location: class VERSION_CODES
    [javac] .../platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java:200: error: cannot find symbol
    [javac]             cookieManager.setAcceptThirdPartyCookies(this, true);
    [javac]                          ^
    [javac]   symbol:   method setAcceptThirdPartyCookies(CordovaWebView,boolean)
    [javac]   location: variable cookieManager of type CookieManager
    [javac] .../platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebViewClient.java:143: error: method does not override or implement a method from a supertype
    [javac]     @Override
    [javac]     ^
    [javac] .../platforms/android/CordovaLib/src/org/apache/cordova/CordovaChromeClient.java:341: error: method does not override or implement a method from a supertype
    [javac]     @Override
    [javac]     ^
    [javac] .../platforms/android/CordovaLib/src/org/apache/cordova/CordovaChromeClient.java:348: error: cannot find symbol
    [javac]                     Uri[] result = WebChromeClient.FileChooserParams.parseResult(resultCode, intent);
    [javac]                                                   ^
    [javac]   symbol:   variable FileChooserParams
    [javac]   location: class WebChromeClient
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] 12 errors
    [javac] 3 warnings

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

Total time: 3 seconds

android,ant,java都在PATH中。

我试图摆弄目标sdks并尝试下载不同的版本,但我已经没有想法了。任何帮助将不胜感激。

AndroidManifest - 来自CordovaLib文件夹:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="org.apache.cordova" android:versionName="1.0" android:versionCode="1">
    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
</manifest>

不要理解为什么它会在错误消息中引用LOLLIPOP,然后为什么它会在安装后找到它。

3 个答案:

答案 0 :(得分:15)

我认为这是因为Cordova 4.3.0引用了android.webkit.ClientCertRequest,它是在API级别21中新添加的。

仅供参考:https://developer.android.com/reference/android/webkit/ClientCertRequest.html

答案 1 :(得分:13)

从SDK Manager安装Android构建工具版本21和22 安装构建工具后,删除应用程序中的平台文件夹 转到Cordova并再次添加android平台(使用 cordova platform add android 命令) 重新安装平台后,重建应用程序(使用 cordova build 命令),它将成功构建

答案 2 :(得分:5)

您的Cordova太高而无法使用Android Api 19.这意味着它更新,因此它引用了Api 19没有的库并给出了错误。所以你需要把它愚蠢一点。

卸载它:

sudo npm uninstall -g cordova 

然后安装一个适用于Api 19的旧版cordova:

sudo npm install -g cordova@4.0.0

现在从头再做一切。 “科尔多瓦创造了blabla”,“科尔多瓦  平台添加android“,”cordova运行android“,等等。

要获取cordova版本列表,请执行以下操作:

npm view cordova versions

但是我知道4.0.0将与Api 19一起工作,因为我遇到了同样的问题。