NPE - AdWhirlLayout.rotateThreadedDelayed(AdWhirlLayout.java:237)

21 views
Skip to first unread message

Stephan Roorda

unread,
May 12, 2011, 12:43:31 AM5/12/11
to adwhir...@googlegroups.com
Updated to the latest AdWhirl SDK in my most recent release and now I have several of these reported in the market.  I had 1 or 2 in a previous version, but I have 5-6 since the latest release with 3.0.

I have looked at the AdWhirl source quickly, but I am at a loss as to where this is happening in my app and why.

java.lang.NullPointerException
at com.adwhirl.AdWhirlLayout.rotateThreadedDelayed(AdWhirlLayout.java:237)
at com.adwhirl.AdWhirlLayout.handleAd(AdWhirlLayout.java:210)
at com.adwhirl.AdWhirlLayout.access$3(AdWhirlLayout.java:205)
at com.adwhirl.AdWhirlLayout$HandleAdRunnable.run(AdWhirlLayout.java:390)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:4937)
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:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)

Stephan

Stephan Roorda

unread,
May 15, 2011, 12:17:44 AM5/15/11
to adwhir...@googlegroups.com
The fix seems to be fairly straightforward after downloading and going through the source.  The offending source code is:
  // Rotate in extra.cycleTime seconds
  public void rotateThreadedDelayed() {
    Log.d(AdWhirlUtil.ADWHIRL, "Will call rotateAd() in " + extra.cycleTime
        + " seconds");
    scheduler.schedule(new RotateAdRunnable(this), extra.cycleTime,
        TimeUnit.SECONDS);
  }

Line 237 is the Log.d() method call.  'extra' appears to be null (I cannot recreate the problem locally to verify 100%).  More digging in the code and it looks to me like 'extra' is set when the configuration is read from AdWhirl and the only way it could be null is if there is an error reading the config.  If that were the case I suppose it could result in an NPE here.  A simple fix would be:
  public void rotateThreadedDelayed() {
    int cycleTime = 30;
    if( extra != null ) {
      cycleTime = extra.cycleTime;
    }
    Log.d(AdWhirlUtil.ADWHIRL, "Will call rotateAd() in " + cycleTime
        + " seconds");
    scheduler.schedule(new RotateAdRunnable(this), cycleTime,
        TimeUnit.SECONDS);
  }

For now, since I do not really trust myself to build the code properly and do not want to endure the extra test cycle of testing with my own jar I am going to revert to the 2.5.4 AdWhirl jar (even though it has the same code in rotateThreadDelayed()) I never saw the error.  Only the latest versions of my app with the 3.0.0 jar are reporting.

Stephan

Stephan Roorda

unread,
Aug 7, 2011, 8:01:13 PM8/7/11
to adwhir...@googlegroups.com
This continues to be a major problem for us.  Any comments from AdWhirl developers?  This is preventing us from moving up to 3.0.0 which in turn is preventing us from moving up to later versions of some of the ad network jars which all results in use losing $$.  We may have to either switch from AdWhirl or build the code ourselves.  It would be great to at least get some feedback on this.
Reply all
Reply to author
Forward
0 new messages