3

For some reason,StartApp ads are not showing on my application, despite having followed their setup instructions in the pdf they provided on their site.

I implemented callbacks on the showAd() and loadAd() methods and noted that ads are received but not shown. I later created a rectangular background on the view where start app Ad would be shown.I noticed the view with my rectangular border is shown when the ad is loaded but their is no ad content inside the view. See attached image.

In the log cat, 'Ad received' is reported but never ' Ad displayed' or 'Ad hidden' messages from my callbacks.

When I click on the Ad view, my app crashed with Array Index out of bounds exception thrown from the StartApp lib.

See images and code snippets.

My Show add runnable:

    private Runnable showAdRunnable = new Runnable() {

    @Override
    public void run() {
          /* 
               WAS HERE BUT STILL COULDNT SHOW
               startAppAd.showAd(new AdDisplayListener() {
                @Override
                public void adHidden(Ad ad) {
                    Log.d(TAG, "Ad hidden "+ad.getErrorMessage());
                }
                @Override
                public void adDisplayed(Ad ad) {
                    Log.d(TAG, "Ad displayed "+ad.getErrorMessage());
                }
                }); 
                */
        startAppAd.loadAd (new AdEventListener() {
            @Override
            public void onReceiveAd(Ad ad) {
                Log.d(TAG, "Ad received "+ad.getErrorMessage());

                startAppAd.showAd(new AdDisplayListener() {
                    @Override
                    public void adHidden(Ad ad) {
                        Log.d(TAG, "Ad hidden "+ad.getErrorMessage());
                    }
                    @Override
                    public void adDisplayed(Ad ad) {
                        Log.d(TAG, "Ad displayed "+ad.getErrorMessage());
                    }
                    }); 
            }
            @Override
            public void onFailedToReceiveAd(Ad ad) {
                Log.d(TAG, "Ad not received "+ad.getErrorMessage());
            }
            });
        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        showing = false;
    }

};

My onCreate()

/**
 * Called when the activity is first created.
 */
@Override
public void onCreate(final Bundle savedInstanceState) {
    Log.d(TAG, "onCreate()");
    StartAppAd.init(this, "XXXXXXX", "YYYYYYY");
    super.onCreate(savedInstanceState);

           setContentView(R.layout.main);

    // initialize the coin image and result text views
    initViews();

    // initialize the onclick listener
    coinImage.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            tossCoin();
        }
    });

    initSounds();

    showing = true;
    new Handler().postDelayed(showAdRunnable , 2*1000);
}

tossmyCoin() method. This is called when the user clicks on the coin image on my app to toss the coin. I want to refresh the Ad every time the user tosses a coin, so I did:

private void tossCoin() {
    ....

    if (!showing) {
        showing = true;
        new Handler().postDelayed(showAdRunnable , 2*1000);
    }
}

How Ad is shown: Empty Ad section

When I click on the Ad section, my app crashes and the log cat contains the following:

10-21 01:38:47.851: E/AndroidRuntime(23900): FATAL EXCEPTION: main
10-21 01:38:47.851: E/AndroidRuntime(23900): java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
10-21 01:38:47.851: E/AndroidRuntime(23900):    at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
10-21 01:38:47.851: E/AndroidRuntime(23900):    at java.util.ArrayList.get(ArrayList.java:311)
10-21 01:38:47.851: E/AndroidRuntime(23900):    at com.startapp.android.publish.banner.banner3d.Banner3D.onTouchEvent(Unknown Source)
10-21 01:38:47.851: E/AndroidRuntime(23900):    at android.view.View.dispatchTouchEvent(View.java:3885)
10-21 01:38:47.851: E/AndroidRuntime(23900):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
nmvictor
  • 1,109
  • 1
  • 15
  • 30
  • I'm Miki from StartApp. It seems like you have two issues, both with the interstitial and the banner. As your integration seems ok, and this bug is not familiar to us, I suggest you contact us from the developers portal or at support@startapp.com. Please attach your manifest and your main activity to your support request. – mikibe Oct 21 '13 at 07:11
  • Thank you Mike, I will do that right away. – nmvictor Oct 21 '13 at 17:18

5 Answers5

4

I don't know why they provide such an incorrect documentation. Every documentation I referred says the same method to show Interstitial ads like this:

startAppAd.showAd();
startAppAd.loadAd();

The order of method calls itself is wrong here. Here's the bit that worked for me:

  • First you loadAd() with its AdEventListener.
  • On its onReceiveAd() method, call the showAd() method.

So it will be something like this:

startAppAd.loadAd(new AdEventListener() {
    @Override
    public void onReceiveAd(Ad ad) {
        System.out.println("Ad received");

        startAppAd.showAd();
    }
}
Neerkoli
  • 2,423
  • 3
  • 16
  • 21
2

I was facing similar issue with StartApp Banner Adds. Adds were not visible despite of all the steps mentioned in their document were completed.

I resolved the issue as follows. Make sure that in banner adds, Height of the add view must be 50dp(android:layout_height="50dp") or more. Adds will not be visible in height less than that.

Hope it helps.

Suraj Singh
  • 4,041
  • 1
  • 21
  • 36
matramroid
  • 103
  • 2
  • 9
0

you can use this way

import com.searchboxsdk.android.StartAppSearch;
import com.startapp.android.publish.StartAppAd;

//After setContentView(R.layout.main_layout);

startAppAd = new StartAppAd(this);

    StartAppAd.init(this, "App ID", "Dev ID");
    StartAppSearch.init(this, "App ID", "Dev ID");

//and use these methods

@Override
public void onResume() {
    startAppAd.onResume();
    super.onResume();

}

@Override
public void onBackPressed() {
    startAppAd.onBackPressed();
    super.onBackPressed();
}

@Override
public void onPause() {
    super.onPause();
    startAppAd.onPause();
}

//also add activity in manifest.xml

    <activity
        android:name="com.startapp.android.publish.list3d.List3DActivity"
        android:taskAffinity="packagename.AppWall"
        android:theme="@android:style/Theme" />
    <activity
        android:name="com.startapp.android.publish.AppWallActivity"
        android:configChanges="orientation|keyboardHidden"
        android:taskAffinity="packagename.AppWall"
        android:theme="@android:style/Theme.Translucent" />

//add permissions

 <uses-permission android:name="android.permission.INTERNET"/>
 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
 <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
 <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
 <uses-permission android:name="android.permission.GET_TASKS"/>
Muhammad Usman Ghani
  • 1,279
  • 13
  • 19
0

I have solved my problem by using handler..

 new Handler().postDelayed(new Runnable()
        {
            @Override
            public void run()
            {
                startAppAd.showAd();
                startAppAd.loadAd();
            }
        }, 5000);
Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300
0

I realized that the ads display only on the Release build of the app and not Debug variant For me, changing the build variant from Release to Debug did the trick.