AdWhirl SDK IOException in fetchConfig() - returning null json
<p>I'm trying to get AdWhirl library to work. The log shows various exceptions but even then, the app actually works. It just doesn't show any ads. Here's the code I'm using right now:</p>

<pre><code>private void adStuff() {
    LinearLayout mAdLayout = (LinearLayout) findViewById(R.id.AdLayout);
    AdWhirlManager.setConfigExpireTimeout(1000 * 60 * 5);
    RelativeLayout.LayoutParams adWhirlLayoutParams = new RelativeLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    int mAdWidth = 320;
    int mAdHeight = 75;
    AdWhirlTargeting.setAge(23);
    AdWhirlTargeting.setGender(AdWhirlTargeting.Gender.MALE);
    AdWhirlTargeting.setKeywords("android");
    AdWhirlTargeting.setPostalCode("47007");
    AdWhirlTargeting.setTestMode(false);
    DisplayMetrics mDisplayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(mDisplayMetrics);
    mAdHeight = mDisplayMetrics.heightPixels;
    float mDensity = mDisplayMetrics.density;
    mAdWidth = mDisplayMetrics.widthPixels;
    mAdHeight = (int) (mAdHeight * mDensity);
    AdWhirlLayout adWhirlLayout = new AdWhirlLayout(this,
            getResources().getString(R.string.adwhirlid));
    adWhirlLayout.setAdWhirlInterface(this);
    adWhirlLayout.setMaxWidth(mAdWidth);
    adWhirlLayout.setMaxHeight(mAdHeight);
    adWhirlLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    mAdLayout.setGravity(Gravity.CENTER_HORIZONTAL);
    mAdLayout.addView(adWhirlLayout, adWhirlLayoutParams);
    mAdLayout.invalidate();
}
</code></pre>

<p>I call this method at the end of onCreate().</p>

<p>Here is my main Layout:</p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp" &gt;

&lt;EditText
    android:id="@+id/editText1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:inputType="number" &gt;

    &lt;requestFocus /&gt;
&lt;/EditText&gt;

&lt;LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" &gt;

    &lt;Button
        android:id="@+id/buttonSearch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/buscar" 
        android:background="@drawable/auvasa_button"/&gt;

    &lt;Button
        android:id="@+id/buttonList"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/listaparadas" 
        android:background="@drawable/auvasa_button"/&gt;
&lt;/LinearLayout&gt;

&lt;LinearLayout android:orientation="horizontal"
   android:layout_width="fill_parent" 
   android:layout_height="wrap_content"
   android:id="@+id/AdLayout"&gt;
</code></pre>

<p></p>

<p></p>

<p>and here is the Log of the bunch of exceptions I'm getting:</p>

<pre><code>03-26 12:37:30.929: E/AdWhirl SDK(5705): Caught IOException in fetchConfig()
03-26 12:37:30.929: E/AdWhirl SDK(5705): org.apache.http.conn.HttpHostConnectException: Connection to http://mob.adwhirl.com refused
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:183)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at com.adwhirl.AdWhirlManager.fetchConfig(AdWhirlManager.java:232)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at com.adwhirl.AdWhirlLayout$InitRunnable.run(AdWhirlLayout.java:376)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:150)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:264)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.lang.Thread.run(Thread.java:856)
03-26 12:37:30.929: E/AdWhirl SDK(5705): Caused by: java.net.ConnectException: failed to connect to /127.0.0.1 (port 80): connect failed: ECONNREFUSED (Connection refused)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at libcore.io.IoBridge.connect(IoBridge.java:114)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.net.Socket.connect(Socket.java:842)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    ... 16 more
03-26 12:37:30.929: E/AdWhirl SDK(5705): Caused by: libcore.io.ErrnoException: connect failed: ECONNREFUSED (Connection refused)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at libcore.io.Posix.connect(Native Method)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:85)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at libcore.io.IoBridge.connect(IoBridge.java:112)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    ... 21 more
03-26 12:37:30.929: D/AdWhirl SDK(5705): Received jsonString: null
03-26 12:37:30.929: E/AdWhirl SDK(5705): Unable to parse response from JSON. This may or may not be fatal.
03-26 12:37:30.929: E/AdWhirl SDK(5705): java.lang.NullPointerException
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at org.json.JSONTokener.nextValue(JSONTokener.java:94)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at org.json.JSONObject.&lt;init&gt;(JSONObject.java:154)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at org.json.JSONObject.&lt;init&gt;(JSONObject.java:171)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at com.adwhirl.AdWhirlManager.parseConfigurationString(AdWhirlManager.java:290)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at com.adwhirl.AdWhirlManager.fetchConfig(AdWhirlManager.java:257)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at com.adwhirl.AdWhirlLayout$InitRunnable.run(AdWhirlLayout.java:376)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:150)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:264)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
03-26 12:37:30.929: E/AdWhirl SDK(5705):    at java.lang.Thread.run(Thread.java:856)
</code></pre>

<p>Can anybody tell me what am I doing wrong? I've revised the code dozens of times and I cannot get it to work. I know the server is returning a null json, and I don't really know why.</p>
