Integrate the SAN SDK - san-sdk/sample GitHub Wiki

Prerequisites

  • Use Android Studio 3.2 or higher
  • Support androidX
  • minSdkVersion 16 or higher
  • compileSdkVersion 30 or higher

Step 1. Download the SAN Android SDK

The SAN Open SDK is available as an AAR via mavenCentral.To add the san-sdk dependency, open your project and update the app module’s build.gradle to have the following repositories and dependencies:

repositories {
    // ... other project repositories
    mavenCentral()
}
//...

dependencies {
    // ... other project dependencies
    api "com.myadsget:san-sdk:${LATEST_VERSION}"
}

You should get the LATEST_VERSION from CHANGELOG

To support Java 8, add the language feature support:

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

Step 2.Update Your Android Manifest

Update your AndroidManifest.xml in order to complete the SDK integration. Add the following permissions and activity declarations according to the bundle you are integrating.

  1. Declare the following permissions:
<!-- Required permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<!-- Optional permissions. Will pass Lat/Lon values when available. Choose either Coarse or Fine -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  1. Add meta-data and queries
<manifest>
   <application>
        <meta-data android:name="com.san.APP_KEY"
            android:value="YOUR_APP_KEY"/>
   </application>
</manifest> 

Step 3:Add network_security_config.xml

Oct 01, 2020 - Android 9.0 (API 28) blocks cleartext (non-HTTPS) traffic by default, which can prevent ads from serving correctly. To mitigate that, publishers whose apps run on Android 9.0 or above should ensure to add a network security config file. Doing so allowlists cleartext traffic and allows non-HTTPS ads to serve.

  1. In your AndroidManifest.xml file, add the following:
    <manifest>
        <application
            ...
            android:networkSecurityConfig="@xml/network_security_config"
            ...>
        </application>
    </manifest>
  1. In your network_security_config.xml file, add a base-config that sets cleartextTrafficPermitted to true:
<?xml version="1.0" encoding="utf-8"?>
    <network-security-config>
        ...
        <base-config cleartextTrafficPermitted="true">
            <trust-anchors>
                <certificates src="system"/>
            </trust-anchors>
        </base-config>
        ...
</network-security-config>
⚠️ **GitHub.com Fallback** ⚠️