Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cookie manager causing fatal signal 11

My app silently crashes (no force close popup) when i try to set a cookie on the cookiemanager.

mHttpClient.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
HttpGet http_get = new HttpGet(url); 
HttpResponse response = mHttpClient.execute(http_get);

for(Cookie cookie : mHttpClient.getCookieStore().getCookies()) {

    Log.d(AppPreferences.TESTTAG,"cookie =  " + cookie.getName());
    if(cookie.getName().equals("SACSID") || cookie.getName().equals("ACSID"))
    {
        response.getEntity().consumeContent();
        String cookieString = cookie.getName() + "=" + cookie.getValue() + "; domain=" + cookie.getDomain();  
        CookieManager.getInstance().setCookie(cookie.getDomain(), cookieString); //**crashes here**
        return true;
    }                   
}

Here's all i'm getting from logcat

04-19 22:51:35.277: W/dalvikvm(16704): Invalid indirect reference 0x414bb040 in decodeIndirectRef
04-19 22:51:35.277: E/dalvikvm(16704): VM aborting
04-19 22:51:35.281: A/libc(16704): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 16754 (AsyncTask #1)

Here's the tombstone log generated: http://textuploader.com/?p=6&id=gPpJ

It fails right on the CookieManager setCookie() line (i.e. I log a message before and after that line it prints the before message but not the one after)

Anyone run in to this problem?

like image 962
user2128112 Avatar asked Apr 19 '13 15:04

user2128112


2 Answers

Add CookieSyncManager.createInstance(context); before calling CookieManager.

like image 161
Phil Avatar answered Sep 22 '22 05:09

Phil


Try to create WebView in onCreate() method and destroy it. WebView create some "bridge" between ContentManager and WebKit. Some thing like this:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_layout);
    WebView web = new WebView(this);
    web.destroy();
}
like image 23
Dmitry Velychko Avatar answered Sep 18 '22 05:09

Dmitry Velychko