Question

I'm using Android Studio.

AQ version : compile group: 'com.googlecode.android-query', name: 'android-query', version: '0.25.9'

I used the same technique in an eclipse project few months ago and it worked:(.

In fragment's onActivityCreated:

     aq = new AQuery(getActivity(), this.getView());
    String url = "http://farm4.static.flickr.com/3531/3769416703_b76406f9de.jpg";
    aq.id(R.id.image_webview).progress(R.id.progress).webImage(url);

I've tried to put the code into onCreateView with the same result.

Edited:

2-05 21:42:20.181  32489-32489/cz.bioport.interspar.androidd.debug W/AQuery﹕ java.lang.NullPointerException: Attempt to invoke virtual method 'int java.io.InputStream.read(byte[])' on a null object reference
        at com.androidquery.util.AQUtility.copy(AQUtility.java:401)
        at com.androidquery.util.AQUtility.copy(AQUtility.java:389)
        at com.androidquery.util.AQUtility.toBytes(AQUtility.java:421)
        at com.androidquery.util.WebImage.getSource(WebImage.java:48)
        at com.androidquery.util.WebImage.setup(WebImage.java:146)
        at com.androidquery.util.WebImage.access$100(WebImage.java:32)
        at com.androidquery.util.WebImage$1.onNewPicture(WebImage.java:131)
        at com.android.webview.chromium.WebViewContentsClientAdapter.onNewPicture(WebViewContentsClientAdapter.java:351)
        at com.android.org.chromium.android_webview.AwContentsClientCallbackHelper$1.handleMessage(AwContentsClientCallbackHelper.java:127)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4998)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
java.lang.NullPointerException:Attempt to invoke virtual method 'java.lang.String java.lang.String.replace(java.lang.CharSequence, java.lang.CharSequence)' on a null object reference
        at com.androidquery.util.WebImage.setup(WebImage.java:147)
        at com.androidquery.util.WebImage.access$100(WebImage.java:32)
        at com.androidquery.util.WebImage$1.onNewPicture(WebImage.java:131)
        at com.android.webview.chromium.WebViewContentsClientAdapter.onNewPicture(WebViewContentsClientAdapter.java:351)
        at com.android.org.chromium.android_webview.AwContentsClientCallbackHelper$1.handleMessage(AwContentsClientCallbackHelper.java:127)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4998)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)

AQ source code

private static String getSource(Context context){
    if(template == null){
        try{
            InputStream is = context.getClassLoader().getResourceAsStream("com/androidquery/util/web_image.html");          
            template = new String(AQUtility.toBytes(is));
        }catch(Exception e){
            AQUtility.debug(e);
        }
    }
    return template;
}
 private void setup(){
    String source = getSource(wv.getContext());
LINE 147:       String html = source.replace("@src", url).replace("@color", Integer.toHexString(color));
    .....
}

It looks like that AS is having troubles with loading web_image.html.

Thank you for all replies!!!

Was it helpful?

Solution

The problem is actually in the maven source ( compile group: 'com.googlecode.android-query', name: 'android-query', version: '0.25.9'). The library is missing one of the html files. Solution is to download jar file from https://code.google.com/p/android-query/downloads/list .

OTHER TIPS

If your app is targeting >= SDK 18 and running on Android 4.4 then the WebView's onNewPicture callback will provide a null Picture; i.e. the API is intended to inform you when content has changed but doesn't give you the Picture. I'm not familiar with aQuery but it sounds like they need to update their libraries to handle this case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top