kristianhristov / cordova-cookie-master

MIT License
26 stars 113 forks source link

Build Errors with android-25 and cordova android platform@6.1.0 #15

Open jkunjoonju18 opened 7 years ago

jkunjoonju18 commented 7 years ago

Given the following targeted SDK and Platform:

cordova platform add android@6.1.0
Adding android project...
Creating Cordova project for the Android platform:
    Path: platforms/android
    Activity: MainActivity
    Android target: android-25
Subproject Path: CordovaLib

Here's the Build Errors

:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
<RootFolder>/platforms/android/src/com/cordova/plugins/cookiemaster/CookieMaster.java:91: error: package Build does not exist
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
                     ^
<RootFolder>/platforms/android/src/com/cordova/plugins/cookiemaster/CookieMaster.java:91: error: package Build does not exist
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
                                              ^
<RootFolder>/platforms/android/src/com/cordova/plugins/cookiemaster/CookieMaster.java:92: error: method removeAllCookies in class CookieManager cannot be applied to given types;
                            cookieManager.removeAllCookies();
                                         ^
  required: ValueCallback<Boolean>
  found: no arguments
  reason: actual and formal argument lists differ in length

Here's the solution that worked:

+++ fixes/CookieMaster.java 2017-01-27 08:00:55.000000000 -0800
@@ -12,6 +12,7 @@
 import java.net.HttpCookie;

 import android.webkit.CookieManager;
+import android.os.Build;

 public class CookieMaster extends CordovaPlugin {

@@ -89,8 +90,8 @@
             CookieManager cookieManager = CookieManager.getInstance();

             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
-               cookieManager.removeAllCookies();
-               cookieManager.flush();
+               cookieManager.removeAllCookies(null);
+               cookieManager.flush();
            } else
            {
                cookieManager.removeAllCookie();
ernsheong commented 6 years ago

PR it, i think the maintainer will merge even though it is no longer actively maintained

RTK commented 6 years ago

Alternatively use my implementation: https://github.com/RTK/cordova-cookie-emperor

danova123 commented 6 years ago

@RTK Your plugin works perfectly. Thanks a lot