Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova fails to build for Android after customising configuration

I followed this instructions to set up Facebook SDK for my Cordova/Ionic project: http://ngcordova.com/docs/plugins/facebook/

For iOS everything worked well, but for Android, the last step of

cordova build android

fails with weird errors:

    -compile:
    [javac] Compiling 97 source files to /Users/glfx/Projects/Sportcial/platforms/android/CordovaLib/ant-build/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] /Users/glfx/Projects/Sportcial/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] /Users/glfx/Projects/Sportcial/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] /Users/glfx/Projects/Sportcial/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] /Users/glfx/Projects/Sportcial/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] /Users/glfx/Projects/Sportcial/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] /Users/glfx/Projects/Sportcial/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] /Users/glfx/Projects/Sportcial/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] /Users/glfx/Projects/Sportcial/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] /Users/glfx/Projects/Sportcial/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] /Users/glfx/Projects/Sportcial/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] /Users/glfx/Projects/Sportcial/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] /Users/glfx/Projects/Sportcial/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/glfx/Library/Android/sdk/tools/ant/build.xml:601: The following error occurred while executing this line:
/Users/glfx/Library/Android/sdk/tools/ant/build.xml:720: The following error occurred while executing this line:
/Users/glfx/Library/Android/sdk/tools/ant/build.xml:734: Compile failed; see the compiler error output for details.

Total time: 2 seconds

/Users/glfx/Projects/Sportcial/platforms/android/cordova/node_modules/q/q.js:126
                throw e;
                      ^
Error code 1 for command: ant with args: debug,-f,/Users/glfx/Projects/Sportcial/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen
ERROR building one of the platforms: Error: /Users/glfx/Projects/Sportcial/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /Users/glfx/Projects/Sportcial/platforms/android/cordova/build: Command failed with exit code 1
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1008:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1080:5)

My manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.facebook.android">
    <application/>
    <uses-sdk android:minSdkVersion='14' android:targetSdkVersion='21' />
</manifest>

I've tried updating Java version, changing target SDK version, Googling.. No luck.

Some details:

java version "1.8.0_40"

Cordova:

Installed platforms: android 3.7.1, ios 3.8.0

Mac OSX latest.

Please assist.

like image 462
deb0rian Avatar asked Mar 26 '15 18:03

deb0rian


People also ask

Does Cordova support Android 12?

We have integrated the Android 12 SplashScreen API including the compatibility library into the core of the Cordova-Android platform to provide support for Android API 22+.

Does Cordova need Android studio?

Cordova-Android projects can be opened in Android Studio. This can be useful if you wish to use Android Studio's built in Android debugging and profiling tools or if you are developing Android plugins. Note: When opening your project in Android Studio, it is recommended to NOT edit the code within the IDE.


1 Answers

Today I faced same problem, using AdvancedWebView and found cordova related problem. for Ant Users, just check project.properties file. Change the

target=android-21
like image 112
Nafis Ahmad Avatar answered Oct 22 '22 14:10

Nafis Ahmad