10

Cordova version: 4.3.0

java version "1.8.0_40" 64bit

OS X 10.10.2

Ant version: 1.9.4

enter image description here

Target android SDK I'm using is 19.

When I run 'ant release' in the platforms/android/CordovaLib folder I get the following output with error:

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 are all in in the PATH.

I've tried fiddling with the target sdks and tried downloading different versions but I've run out of ideas. Any help would be much appreciated.

AndroidManifest - from CordovaLib folder:

<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>

Don't understand why it refers to LOLLIPOP in the error message and then why can't it find it since it's installed.

L4zl0w
  • 1,069
  • 4
  • 15
  • 42
  • on which Os are you compling? can you specfy you ant version? – KOTIOS Mar 05 '15 at 11:52
  • hi @diva ant version is 1.9.4, operating system is OS X 10.10.2 Yosemite – L4zl0w Mar 05 '15 at 12:02
  • mac right? and java version "1.8.0_40" 64bit – KOTIOS Mar 05 '15 at 12:03
  • yes, its a Mac with latest Java – L4zl0w Mar 05 '15 at 12:06
  • could you plz post manifest also – KOTIOS Mar 05 '15 at 12:19
  • yes, I've added it to the post. thanks – L4zl0w Mar 05 '15 at 12:21
  • could try using android:minSdkVersion="17" and build the project and let me know the results? – KOTIOS Mar 05 '15 at 12:36
  • 2
    Any chance you have upgraded your cli tools without updating the project? What does `cordova platform` say the version is at? Also, I thought 3.7.1, used in cli 4.3 upped the sdk to 21 -- http://cordova.apache.org/announcements/2015/02/06/cordova-android-3.7.1.html? – laughingpine Mar 05 '15 at 15:30
  • @laughingpine thanks, CordovaLib subproject compiles with API 21! However the project as a whole fails to compile with error about plugins all over. – L4zl0w Mar 05 '15 at 16:44
  • By the way this is a brand new project built from scratch. Android platform version is 3.7.1. I'm getting similar 'cannot find symbol' error but this time from plugins. – L4zl0w Mar 05 '15 at 16:47
  • 1
    It is eventually working with target sdks 21. If you add it as an answer, I'll accept :) – L4zl0w Mar 05 '15 at 17:04

3 Answers3

15

I think it's because the Cordova 4.3.0 has referenced the android.webkit.ClientCertRequest, which is newly added in API level 21.

FYI: https://developer.android.com/reference/android/webkit/ClientCertRequest.html

Zheng Can
  • 166
  • 1
  • 4
  • I didn't see any reference here: https://cordova.apache.org/docs/en/4.0.0/guide_platforms_android_index.md.html should probably be added to the docs. but this worked for me as well – TyBourque Aug 18 '15 at 17:37
13

Install Android build tools version 21 and 22 from SDK Manager.
Once the build tools are installed, remove the platforms folder inside your app.
Go to Cordova and add the android platform again (using cordova platform add android command).
Once the platform is reinstalled, rebuild the app (using cordova build command) and it will build successfully

Raj Adepu
  • 131
  • 1
  • 2
6

Your Cordova is too high to work with Android Api 19. Meaning it's newer so it references libraries that Api 19 doesn't have and gives an error. So you need to dumb it down a little bit.

Uninstall it:

sudo npm uninstall -g cordova 

And then install an older version of cordova that works well with Api 19:

sudo npm install -g cordova@4.0.0

and now do everything again from scratch. "cordova create blabla", "cordova platform add android", "cordova run android", etc.

To get a list of cordova versions do:

npm view cordova versions

But I know that 4.0.0 will work with Api 19 since I had the same problem.

shareef
  • 9,255
  • 13
  • 58
  • 89
Shai UI
  • 50,568
  • 73
  • 204
  • 309
  • Great answer. Alternatively, you could update your target if you don't care about using 19. You can run `android list targets` to see your options, and then upgrade from `platforms/android` by running `android update project --target android-23 -p ~/< MY PROJECT DIRECTORY >/platforms/android -s` I got the same error as the asker and updating to android-23 fixed it for me. – Sarah Apr 30 '16 at 00:56