Facebook Mediation Guide - uc-union/union-ads-sdk-demo GitHub Wiki
For more details please go to Facebook website
Add the following repositories
info to project section of build.gradle
file, more details in build.gradle.
repositories {
mavenCentral()
}
Add dependencies
dependency (usually defined in app/build.gradle
), more details in app/build.gradle
dependencies {
'com.facebook.android:audience-network-sdk:4.+'
}
Add the following contents to AndroidManifest.xml
, more details in AndroidManifest.xml.
<application android:label="@string/app_name">
...
<activity android:name="com.facebook.ads.InterstitialAdActivity"
android:configChanges="keyboardHidden|orientation|screenSize" />
</application>
Note: If you use Android Studio,you can skip this section.
NOTE: Facebook Audience Network SDK is in aar format.
Download the corresponding SDK from official Facebook site Download Page
Decompress AudienceNetwork.aar
locally, you will get the following directory structure.
AudienceNetwork.aar
|--(Directories)
|--AndroidManifest.xml
|--proguard.txt
|--classes.jar
Follow the steps below:
-
Rename
classes.jar
intofacebookads.jar
and put it in thelibs
directory -
Merge the content of
proguard.txt
intoproguard.pro
of the developer's project. -
Add the following content to
AndroidManifest.xml
<!-- Include required permissions --> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <application android:label="@string/app_name"> ... <activity android:name="com.facebook.ads.InterstitialAdActivity" android:configChanges="keyboardHidden|orientation|screenSize" /> </application>
When running on the simulator, test ads will be shown by default. To enable test ads on a device, add the HASH_ID
before loading an ad:
AdRequest request =
AdRequest.newBuilder().testDeviceId("YOUR_HASH_ID").put("YOUR_PUB").build();
YOUR_HASH_ID
is printed to the logcat when you first make a request to load an ad on a device. Example:
Once you load an ad with test device id, you should see something like this:
-
Banner
-
Interstitial
-
See AdMob Mediation Guide to know about integration of AdMob.
-
Follow our guide on Initialize SDK to start sdk integration.