NullPointerException in Android SDK

30 views
Skip to first unread message

dereulenspiegel

unread,
Mar 15, 2010, 8:21:12 AM3/15/10
to AdWhirl Users
Hello,

after my last Problem disappeared after I added the quattro sdk my
classpath, I have now another problem. Sometimes when create the
AdWhirlLayout object I get the following exception:

java.lang.NullPointerException at
com.qwapi.adclient.android.service.AdRequestThread
$1.handleMessage(Unknown Source) at
android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:123) at
com.qwapi.adclient.android.service.AdRequestThread.run(Unknown
Source)

This exception is rather rare but I experienced it myself although I
can't reproduced it. Can anybody help me?

Justin Pincar

unread,
Mar 17, 2010, 3:57:26 PM3/17/10
to adwhir...@googlegroups.com
From that stacktrace snippet it looks like this might be an issue with
Quattro's SDK and not the AdWhirl SDK. You should reach out to Quattro
about this.
`Justin

dm1973

unread,
Mar 19, 2010, 12:56:33 AM3/19/10
to AdWhirl Users
I am seeing the same issue occasionally. I have not seen this bug in
my apps that don't use AdWhirl (but use Quattro)so I am a bit
concerned that there is some interaction between Adwhirl and quattro
where the quattro view is getting removed when it can not be done
safelye (i.e something alone the lines of if there is an ad request in
progress, deleting the view causes the crash. ). I have dropped
Quattro a line and will let you know if I hear anything back.


I am also seeing another crashes
java.lang.OutOfMemoryError: thread creation failed
at java.lang.VMThread.create(Native Method)
at java.lang.Thread.start(Thread.java:1327)
at com.adwhirl.AdWhirlLayout.rotateThreadedDelayed(AdWhirlLayout.java:
183)
at com.adwhirl.adapters.GenericAdapter.handle(GenericAdapter.java:43)
at com.adwhirl.AdWhirlLayout.handleAd(AdWhirlLayout.java:156)
at com.adwhirl.AdWhirlLayout.access$0(AdWhirlLayout.java:143)
at com.adwhirl.AdWhirlLayout$1.run(AdWhirlLayout.java:87)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4338)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)

java.lang.OutOfMemoryError
at
org.apache.http.impl.io.AbstractSessionInputBuffer.init(AbstractSessionInputBuffer.java:
79)
at
org.apache.http.impl.io.SocketInputBuffer.<init>(SocketInputBuffer.java:
93)
at
org.apache.http.impl.SocketHttpClientConnection.createSessionInputBuffer(SocketHttpClientConnection.java:
83)
at
org.apache.http.impl.conn.DefaultClientConnection.createSessionInputBuffer(DefaultClientConnection.java:
170)
at
org.apache.http.impl.SocketHttpClientConnection.bind(SocketHttpClientConnection.java:
106)
at
org.apache.http.impl.conn.DefaultClientConnection.openCompleted(DefaultClientConnection.java:
129)
at
org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:
136)
at
org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:
164)
at
org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:
119)
at
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:
348)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:
555)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:
487)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:
465)
at com.adwhirl.AdWhirlLayout$7.run(AdWhirlLayout.java:222)


Obviously the out of memory could just be a bug in my program(but it
was not happening before the adwhirl integration) but it is also
possible that occasionally adwhirl isn't cleaning things up properly.
It is really easy to keep references around when they shouldn't be
with things like inner classes and Contexts (my apps do support
rotation so the same activity can get launched a lot of times).
Something to keep your eye on.

I will you guys know if I hear or discover anything else

jj

unread,
May 3, 2010, 3:02:53 PM5/3/10
to AdWhirl Users
Sorry to bring up an old thread, but curious if anyone has heard from
Quattro on this issue. I recently have started to see it as well and
the report I get is:

java.lang.NullPointerException
at com.qwapi.adclient.android.service.AdRequestThread
$1.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at com.qwapi.adclient.android.service.AdRequestThread.run(Unknown
Source)

This looks purely to be a Quattro issue. I emailed them about this
last week and they keep pushing me off...

David Matiskella

unread,
May 4, 2010, 9:35:05 AM5/4/10
to adwhir...@googlegroups.com
I never heard back from Quattro. I am pretty sure the problem is deleting the view when an Ad request is in progress but without source code it is hard to be 100% sure. My workout around was to not delete the Quattro view but to recycle it.

Justin Pincar

unread,
May 4, 2010, 1:28:27 PM5/4/10
to adwhir...@googlegroups.com
Just took a closer look - this is what I think is happening:
- Quattro QWAdView is created with refresh rate 0, so it shouldn't
ever refresh ads
- QWAdView starts AdRequestThread
- AdRequestThread tells the QWAdView (gotten from a WeakReference) to
get ads, etc.
- (The logic for refreshing and everything else isn't in
AdRequestThread itself though)
- At some point along the line, AdWhirl deletes the QWAdView
- The AdRequestThread is still looping, either because QWAdView
doesn't stop it immediately or it's in the middle of a loop
- In AdRequestThread the QWAdView WeakReference is now null and
there's no check, so it throws the NPE

`Justin

Yahma

unread,
Jun 23, 2010, 11:33:12 AM6/23/10
to AdWhirl Users
Sorry to bring up an old thread, but can you give us details on how
you were able to recycle the Quattro view? Were you able to do it w/o
modifications to the AdWhirl source?

quankiquanki

unread,
Jun 25, 2010, 5:16:15 PM6/25/10
to AdWhirl Users
Hey guys,

Quattro worked fine for me in the past month but lately I am getting
this error too. I also would really like to know how you did your
workaround in solving it because I have already emailed Quattro about
it and I do not think they are going to help us fix it. Would I need
to change some code in the Adwhirl source code for this to work? Or
maybe can it be incorporated in the next SDK version release, I do not
know if this is too much trouble for you guys.
> > >>>> Thisexceptionis rather rare but I experienced it myself although I

Michael Bollmann

unread,
Jul 7, 2010, 9:57:36 AM7/7/10
to AdWhirl Users
Recently i'm getting loads of those errors too :(

Justin Pincar

unread,
Jul 7, 2010, 12:38:33 PM7/7/10
to adwhir...@googlegroups.com
Try using the latest version of the AdWhirl SDK; it should be able to
catch exceptions thrown by the ad networks.
`Justin

Joe

unread,
Jul 9, 2010, 11:56:17 AM7/9/10
to AdWhirl Users
Would that actually be able to catch the exception if it's being
thrown from within a QW thread?

If my understanding is correct, once the thread starts running, your
try/catch is no longer relevant, because the code will return and exit
from the try/catch while the spawned thread is still running in
another thread.

That means the only way to catch the error is via a thread's exception
handler, and since you don't have access to the thread object, the
only way to achieve that is by registering a DefaultExceptionHandler
with Thread, and inspect every exception you receive to see if it came
from qwsdk.

On Jul 7, 12:38 pm, Justin Pincar <jpin...@google.com> wrote:
> Try using the latest version of the AdWhirl SDK; it should be able to
> catch exceptions thrown by the ad networks.
> `Justin
>
> On Wed, Jul 7, 2010 at 6:57 AM, Michael Bollmann
>

Justin Pincar

unread,
Jul 9, 2010, 12:27:32 PM7/9/10
to adwhir...@googlegroups.com
At first I thought that we wouldn't be able to catch it either, but I
looked into the issue some more and we can get at least some of the
exceptions. With some added reflection and refactoring the code to
wrap the adapters in a better way, we'll know if they throw something
and can roll over. I've tested some cases with success, though I think
that if the adapter throws an exception in a post to a handler in the
UI thread that it still might cause issues, but haven't confirmed
this.

You can take a look at the changesets to see the difference:
http://code.google.com/p/adwhirl/source/detail?r=25246ccee171344ab8b1d85f42a14e829b59d592&repo=sdk
http://code.google.com/p/adwhirl/source/detail?r=6a34f8ccafc3f226b7470c5925f438f6daec5bb2&repo=sdk

`Justin

Yahma

unread,
Jul 10, 2010, 2:49:22 PM7/10/10
to AdWhirl Users
Hi Justin,

I just started a new thread, and then realized this thread exists.
The following NullPointerException still brings down the latest 2.1.3
version of Adwhirl and the entire application:

java.lang.NullPointerException:
at com.qwapi.adclient.android.service.AdRequestThread
$1.handleMessage([unknown source]:-1)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at com.qwapi.adclient.android.service.AdRequestThread.run([unknown
source]:-1)

It is being thrown by the Quattro API. Is it possible to catch this
NullPointerException?

Thanks

On Jul 9, 9:27 am, Justin Pincar <jpin...@google.com> wrote:
> At first I thought that we wouldn't be able to catch it either, but I
> looked into the issue some more and we can get at least some of the
> exceptions. With some added reflection and refactoring the code to
> wrap the adapters in a better way, we'll know if they throw something
> and can roll over. I've tested some cases with success, though I think
> that if the adapter throws an exception in a post to a handler in the
> UI thread that it still might cause issues, but haven't confirmed
> this.
>
> You can take a look at the changesets to see the difference:http://code.google.com/p/adwhirl/source/detail?r=25246ccee171344ab8b1...http://code.google.com/p/adwhirl/source/detail?r=6a34f8ccafc3f226b747...
>
> `Justin

Justin Pincar

unread,
Jul 12, 2010, 12:58:04 PM7/12/10
to adwhir...@googlegroups.com
Well, I think that the changes I made for the latest version are the
extent of what we can do to catch ad network exceptions. I don't think
that specifying an UncaughtExceptionHandler is the right solution,
especially at the AdWhirl level, though if you really want to try that
approach you should be able to do that in your app outside of the
AdWhirl codebase. Also feel free to play around with the AdWhirl code
to see if you can find an alternate solution, and if you do we'd love
to hear about it. It probably also wouldn't hurt to ping Quattro every
now and then to see if they fixed this.
`Justin
Reply all
Reply to author
Forward
0 new messages