TiTouchGallery icon indicating copy to clipboard operation
TiTouchGallery copied to clipboard

Image cannot be loaded in Andorid L 5.0

Open uniware opened this issue 10 years ago • 6 comments

The module works fine on Android 4.4.4 and before. But it does not work properly on Android L 5.0. The images are loaded for the first time but if you close the image page and open it again (with the same http request), it will give the following error. This happens even after we close the app and reopen it.

[WARN] : W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.startsWith(java.lang.String)' on a null object reference [WARN] : W/System.err: at com.android.okhttp.internal.http.StatusLine.(StatusLine.java:24) [WARN] : W/System.err: at com.android.okhttp.Response$Builder.statusLine(Response.java:419) [WARN] : W/System.err: at com.android.okhttp.internal.http.JavaApiConverter.createOkResponse(JavaApiConverter.java:116) [WARN] : W/System.err: at com.android.okhttp.internal.http.ResponseCacheAdapter.get(ResponseCacheAdapter.java:53) [WARN] : W/System.err: at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:190) [WARN] : W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:373) [WARN] : W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:106) [WARN] : W/System.err: at src.ru.truba.touchgallery.TouchView.UrlTouchImageView$ImageLoadTask.doInBackground(UrlTouchImageView.java:226) [WARN] : W/System.err: at src.ru.truba.touchgallery.TouchView.UrlTouchImageView$ImageLoadTask.doInBackground(UrlTouchImageView.java:176) [WARN] : W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:288) [WARN] : W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237) [WARN] : W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) [WARN] : W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) [WARN] : W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) [WARN] : W/System.err: at java.lang.Thread.run(Thread.java:818)

any fixes or hints?

Thanks a lot

uniware avatar Jan 12 '15 21:01 uniware

It seems this issue was caused by caching. A temporary fix would be disable the caching in UrlTouchImageView.java:

URL aURL = new URL(url); URLConnection conn = aURL.openConnection(); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP )
conn.setUseCaches(false);

azmetro avatar Jan 26 '15 14:01 azmetro

This is caused by a bug in the implementation of TiCacheResponse. See: https://code.google.com/p/android/issues/detail?id=160522

grebulon avatar Mar 22 '15 11:03 grebulon

Hi,can anyone temporary disable the cache then compile to module zip fike and send it to me? my ant build compile error

koolll avatar Apr 01 '15 17:04 koolll

Dirty workaround: I have added a '?_=' + Mat.random() to every URL and it works for me. i know, it is very dirty, but it works. I suppose a new propetty 'nocache'

The issue is here: http://stackoverflow.com/questions/29072951/httpurlconnection-failes-with-nullpointerexception-on-lollipop

Here is a compiled version: https://github.com/AppWerft/DLRmediathek/blob/master/com.gbaldera.titouchgallery.zip?raw=true Currently I don't know how I can pullrequest. In my version 1.2 I have supressed caching.

AppWerft avatar Apr 11 '15 12:04 AppWerft

If you build titanium yourself, you can get my fix to TiResponseCache from here: https://www.dropbox.com/s/z814rg68p8qz7ew/TiResponseCache.java?dl=0

grebulon avatar Apr 13 '15 13:04 grebulon

This should be fixed now with the latest Ti SDK 4.1.0+

fahad86 avatar Aug 26 '15 02:08 fahad86