Eclipse Tutorial

This project was created using Eclipse for Android Developers Version: Neon.2 Release (4.6.2)

1. Create Android application

The Minimum Required SDK dropdown should be set to 9.

Create Android Application

Create a folder named libs in your project root.

Create Libs Folder

Find the libs folder in the Eclipse sample repository.

Get Libs from Resources

Copy all of the .jar files into your new folder.

Copy Libs to folder

Go to your Config Build Path Settings.

Goto Config Build Path

Add the libraries to the project.

Add Jars Add Jars From Folder

Enable the libraries and press Apply.

Enable Jars

Copy the entire contents of the appcompat-res folder to your project res folder (Be careful not to overwrite any files, you may need to merge some - but with an empty project there are no conflicts).

Get Resources

Copy Resources

Check that the compiler version is set to use Java 1.7.

Set Java Version 1.7

Compile your application to check it builds with no errors.

2. Initialise Tapdaq

import com.tapdaq.sdk.*;
import com.tapdaq.sdk.listeners.*;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

    	TapdaqConfig config = new TapdaqConfig(this);
    	Tapdaq.getInstance().initialize(this, "<APP_ID>", "<CLIENT_KEY>", config, new TMInitListener());
    }
}

3. Declare AndroidManifest settings

  • Add Permissions required by Tapdaq.
  • Add Activities used by Tapdaq.
  • Add Google Play Ad Version.
<uses-permission android:name="android.permission.INTERNET" />

<application >
    ...

     <!-- Debug Views -->
    <activity android:name="com.tapdaq.sdk.TMTestActivity" />
    <activity android:name="com.tapdaq.sdk.TMTestNativeActivity"/>

    <!-- Cross Promo -->
    <activity android:name="com.tapdaq.sdk.TMInterstitialActivity"/>

    <!-- Chartboost SDK-less -->
    <activity
        android:name="com.tapdaq.sdk.adnetworks.chartboost.CBWebActivity"
        android:theme="@style/Theme.AppCompat.NoActionBar" />

    <!-- AdColony SDK-less -->
    <activity
        android:name="com.tapdaq.sdk.adnetworks.adcolony.ACVideoActivity"
        android:theme="@style/Theme.AppCompat.NoActionBar" />
    <activity
        android:name="com.tapdaq.sdk.adnetworks.adcolony.ACWebActivity"
        android:theme="@style/Theme.AppCompat.NoActionBar" />

    <!-- AppLovin SDK-less -->
    <activity
        android:name="com.tapdaq.sdk.adnetworks.applovin.ALVideoActivity"
        android:theme="@style/Theme.AppCompat.NoActionBar" />
    <activity
        android:name="com.tapdaq.sdk.adnetworks.applovin.ALWebActivity"
        android:theme="@style/Theme.AppCompat.NoActionBar" />

     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
</application>

4. Add adapters

Adapters are used for additional ad networks that cannot be contained within the Tapdaq SDK, you can find them in the Resources/Adapters folder. Add the adapters needed to your project.

Adapter Directory

Add the libraries for the networks you require:

UnityAds:

Add UnityAds.jar to your project.

Last version tested: 2.0.7

Vungle:

The follow files need to be added to your project.

  • dagger-2.7.jar
  • javax.inject-1.jar
  • vungle-publisher-adaptive-id-4.0.3.jar

Last version tested: 4.0.3

Facebook Audience Network:

Add audience-network-sdk-4.17.0.jar to your project.

Last version tested: 4.17.0

5. Adapter manfiest declarations

Add the activities required for each adapter.

<application>
    ...

    <!-- AdMob Adapter -->
    <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent"/>/>

    <!-- Facebook Adapter -->
    <activity
        android:name="com.facebook.ads.InterstitialAdActivity"
        android:configChanges="keyboardHidden|orientation|screenSize" />

    <!-- Unity Ads Adapter -->
    <activity android:name="com.unity3d.ads.adunit.AdUnitActivity"/>
    <activity android:name="com.unity3d.ads.adunit.AdUnitSoftwareActivity"/>

    <!-- Vungle Adapter -->
    <activity android:name="com.vungle.sdk.VungleAdvert"
        android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize"
        android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>

    ...
</application>

6. Register adapters

Before initiasing Tapdaq, register the adapters.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Tapdaq.getInstance().registerAdapter(this, new TMAdMobAdapter(this));
    Tapdaq.getInstance().registerAdapter(this, new TMFacebookAdapter(this));
    Tapdaq.getInstance().registerAdapter(this, new TMUnityAdsAdapter());
    Tapdaq.getInstance().registerAdapter(this, new TMVungleAdapter());

    TapdaqConfig config = new TapdaqConfig(this);
    Tapdaq.getInstance().initialize(this, "<APP_ID>", "<CLIENT_KEY>", config, new TMInitListener());
}