릴리즈 업데이트를 받으려면 AppLovin-MAX-SDK-Android GitHub 리포지토리를 구독하세요.
다운로드한 파일의 압축을 풀고 aar 파일을 프로젝트의 libs 폴더로 드래그 앤 드롭합니다.
(프로젝트에 libs 폴더가 없는 경우, app 폴더 내부에 생성할 수 있습니다.)
build.gradle 파일에 다음을 추가합니다:
repositories {
google()
mavenCentral()
flatDir {
dirs 'libs'
}
⋮
}
dependencies {
implementation 'com.applovin:applovin-sdk:«x.y.z»@aar'
⋮
}
repositories {
google()
mavenCentral()
flatDir {
dirs("libs")
}
⋮
}
dependencies {
implementation("com.applovin:applovin-sdk:«x.y.z»@aar")
⋮
}
AndroidManifest.xml에 다음 줄을 추가합니다.
이 설정은 application 태그 내부에 들어가야 합니다:
<meta-data android:name="applovin.sdk.key" android:value="«your-SDK-key»"/>
SDK 키는 AppLovin 대시보드의 Account > General > Keys 섹션에서 확인할 수 있습니다.
MAX Ad Review 서비스를 활성화하려면 build.gradle 파일에 다음을 추가합니다:
build.gradle 파일에 추가할 사항buildscript {
repositories {
maven { url 'https://artifacts.applovin.com/android' }
}
dependencies {
classpath "com.applovin.quality:AppLovinQualityServiceGradlePlugin:+"
}
}
buildscript {
repositories {
maven { url = uri("https://artifacts.applovin.com/android") }
}
dependencies {
classpath ("com.applovin.quality:AppLovinQualityServiceGradlePlugin:+")
}
}
build.gradle 파일에 추가할 사항apply plugin: 'applovin-quality-service'
applovin {
apiKey "«your-ad-review-key»"
}
plugins {
id("applovin-quality-service")
}
applovin {
apiKey = "«your-ad-review-key»"
}
Ad Review Key는 AppLovin 대시보드의 Account > General > Keys 섹션에서 확인할 수 있습니다.
SDK를 초기화하기 전에 SDK용 초기화 구성 객체를 생성합니다.
이 객체를 사용하면 SDK가 초기화될 때 사용할 속성을 구성할 수 있습니다.
이러한 초기화 속성은 앱의 수명 동안 변경될 수 있는 가변 속성을 포함하는 AppLovinSdkSettings를 제외하고는 불변(immutable)입니다.
// Create the initialization configuration
AppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration.builder( "«SDK-key»" )
.setMediationProvider( AppLovinMediationProvider.MAX )
// Perform any additional configuration/setting changes
.build();
// Create the initialization configuration
val initConfig = AppLovinSdkInitializationConfiguration.builder("«SDK-key»")
.setMediationProvider(AppLovinMediationProvider.MAX)
// Perform any additional configuration/setting changes
.build()
SDK 키는 AppLovin 대시보드의 Account > General > Keys 섹션에서 확인할 수 있습니다.
가능한 한 빨리(예: 시작 액티비티의 onCreate() 또는 Application 클래스에서) 초기화 구성 객체를 사용하여 AppLovin SDK를 초기화합니다.
이렇게 하면 SDK가 mediation 파트너 네트워크의 광고를 캐싱할 수 있는 시간이 극대화되어 더 나은 사용자 경험을 제공할 수 있습니다.
public class MainActivity extends Activity
{
protected void onCreate(Bundle savedInstanceState)
{
// Create the initialization configuration
AppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration.builder( "«SDK-key»" )
.setMediationProvider( AppLovinMediationProvider.MAX )
.build();
// Initialize the SDK with the configuration
AppLovinSdk.getInstance( this ).initialize( initConfig, new AppLovinSdk.SdkInitializationListener()
{
@Override
public void onSdkInitialized(final AppLovinSdkConfiguration sdkConfig)
{
// Start loading ads
}
} );
}
}
class MainActivity : Activity()
{
override fun onCreate(savedInstanceState: Bundle?)
{
// Create the initialization configuration
val initConfig = AppLovinSdkInitializationConfiguration.builder("«SDK-key»")
.setMediationProvider(AppLovinMediationProvider.MAX)
.build()
// Initialize the SDK with the configuration
AppLovinSdk.getInstance(this).initialize(initConfig) { sdkConfig ->
// Start loading ads
}
}
}
아래는 연동 샘플입니다.
// Create the initialization configuration
AppLovinSdkInitializationConfiguration initConfig = AppLovinSdkInitializationConfiguration.builder( "«SDK-key»" )
.setMediationProvider( AppLovinMediationProvider.MAX )
.setSegmentCollection( MaxSegmentCollection.builder()
.addSegment( new MaxSegment( 849, Arrays.asList( 1, 3 ) ) )
.build() )
.build();
// Configure the SDK settings if needed before or after SDK initialization.
val settings = AppLovinSdk.getInstance( this ).getSettings();
settings.setUserIdentifier( "«user-ID»" );
settings.setExtraParameter( "uid2_token", "«token-value»" );
settings.getTermsAndPrivacyPolicyFlowSettings().setEnabled( true );
settings.getTermsAndPrivacyPolicyFlowSettings().setPrivacyPolicyUri( Uri.parse( "«https://your-company-name.com/privacy-policy»" ) );
settings.getTermsAndPrivacyPolicyFlowSettings().setTermsOfServiceUri( Uri.parse( "«https://your-company-name.com/terms-of-service»" ) );
// Initialize the SDK with the configuration
AppLovinSdk.getInstance( this ).initialize( initConfig, new AppLovinSdk.SdkInitializationListener()
{
@Override
public void onSdkInitialized(final AppLovinSdkConfiguration sdkConfig)
{
// Start loading ads
}
} );
// Create the initialization configuration
val initConfig = AppLovinSdkInitializationConfiguration.builder("«SDK-key»")
.setMediationProvider(AppLovinMediationProvider.MAX)
.setSegmentCollection(MaxSegmentCollection.builder()
.addSegment(MaxSegment(849, listOf(1, 3)))
.build()
)
.build()
// Configure the SDK settings if needed before or after SDK initialization.
val settings = AppLovinSdk.getInstance(this).settings
settings.userIdentifier = "«user-ID»"
settings.setExtraParameter("uid2_token", "«token-value»")
settings.termsAndPrivacyPolicyFlowSettings.apply {
isEnabled = true
privacyPolicyUri = Uri.parse("«https://your-company-name.com/privacy-policy»")
termsOfServiceUri = Uri.parse("«https://your-company-name.com/terms-of-service»")
}
// Initialize the SDK with the configuration
AppLovinSdk.getInstance(this).initialize(initConfig) { sdkConfig ->
// Start loading ads
}
interstitial ad를 로드하려면 ad unit으로 MaxInterstitialAd 객체를 인스턴스화하고 loadAd()를 호출합니다.
광고가 준비되었을 때와 기타 광고 관련 이벤트에 대한 알림을 받을 수 있도록 MaxAdListener를 구현합니다.
public class ExampleActivity extends Activity
implements MaxAdListener
{
private MaxInterstitialAd interstitialAd;
private int retryAttempt;
void createInterstitialAd()
{
interstitialAd = new MaxInterstitialAd( "«ad-unit-ID»" );
interstitialAd.setListener( this );
// Load the first ad
interstitialAd.loadAd();
}
// MAX Ad Listener
@Override
public void onAdLoaded(final MaxAd maxAd)
{
// Interstitial ad is ready to be shown. interstitialAd.isReady() will now return 'true'
// Reset retry attempt
retryAttempt = 0;
}
@Override
public void onAdLoadFailed(final String adUnitId, final MaxError error)
{
// Interstitial ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)
retryAttempt++;
long delayMillis = TimeUnit.SECONDS.toMillis( (long) Math.pow( 2, Math.min( 6, retryAttempt ) ) );
new Handler().postDelayed( new Runnable()
{
@Override
public void run()
{
interstitialAd.loadAd();
}
}, delayMillis );
}
@Override
public void onAdDisplayFailed(final MaxAd maxAd, final MaxError error)
{
// Interstitial ad failed to display. AppLovin recommends that you load the next ad
interstitialAd.loadAd();
}
@Override
public void onAdDisplayed(final MaxAd maxAd) {}
@Override
public void onAdClicked(final MaxAd maxAd) {}
@Override
public void onAdHidden(final MaxAd maxAd)
{
// Interstitial ad is hidden. Pre-load the next ad
interstitialAd.loadAd();
}
}
class ExampleActivity : Activity(), MaxAdListener
{
private lateinit var interstitialAd: MaxInterstitialAd
private var retryAttempt = 0.0
fun createInterstitialAd()
{
interstitialAd = MaxInterstitialAd( "«ad-unit-ID»", this )
interstitialAd.setListener( this )
// Load the first ad
interstitialAd.loadAd()
}
// MAX Ad Listener
override fun onAdLoaded(maxAd: MaxAd)
{
// Interstitial ad is ready to be shown. interstitialAd.isReady() will now return 'true'
// Reset retry attempt
retryAttempt = 0.0
}
override fun onAdLoadFailed(adUnitId: String?, error: MaxError?)
{
// Interstitial ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)
retryAttempt++
val delayMillis = TimeUnit.SECONDS.toMillis( Math.pow( 2.0, Math.min( 6.0, retryAttempt ) ).toLong() )
Handler().postDelayed( { interstitialAd.loadAd() }, delayMillis )
}
override fun onAdDisplayFailed(ad: MaxAd?, error: MaxError?)
{
// Interstitial ad failed to display. AppLovin recommends that you load the next ad
interstitialAd.loadAd()
}
override fun onAdDisplayed(maxAd: MaxAd) {}
override fun onAdClicked(maxAd: MaxAd) {}
override fun onAdHidden(maxAd: MaxAd)
{
// Interstitial ad is hidden. Pre-load the next ad
interstitialAd.loadAd()
}
}
interstitial ad를 표시하려면 위에서 생성한 MaxInterstitialAd 객체에서 showAd()를 호출합니다.
if ( interstitialAd.isReady() )
{
interstitialAd.showAd();
}
if ( interstitialAd.isReady )
{
interstitialAd.showAd()
}
rewarded ad를 로드하려면 rewarded ad unit으로 MaxRewardedAd 객체를 가져와 loadAd()를 호출합니다.
광고가 준비되었을 때와 기타 광고 관련 이벤트에 대한 알림을 받을 수 있도록 MaxRewardedAdListener를 구현합니다.
public class ExampleActivity extends Activity
implements MaxRewardedAdListener
{
private MaxRewardedAd rewardedAd;
private int retryAttempt;
void createRewardedAd()
{
rewardedAd = MaxRewardedAd.getInstance( "«ad-unit-ID»" );
rewardedAd.setListener( this );
rewardedAd.loadAd();
}
// MAX Ad Listener
@Override
public void onAdLoaded(final MaxAd maxAd)
{
// Rewarded ad is ready to be shown. rewardedAd.isReady() will now return 'true'
// Reset retry attempt
retryAttempt = 0;
}
@Override
public void onAdLoadFailed(final String adUnitId, final int errorCode)
{
// Rewarded ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)
retryAttempt++;
long delayMillis = TimeUnit.SECONDS.toMillis( (long) Math.pow( 2, Math.min( 6, retryAttempt ) ) );
new Handler().postDelayed( new Runnable()
{
@Override
public void run()
{
rewardedAd.loadAd();
}
}, delayMillis );
}
@Override
public void onAdDisplayFailed(final MaxAd maxAd, final MaxError error)
{
// Rewarded ad failed to display. AppLovin recommends that you load the next ad
rewardedAd.loadAd();
}
@Override
public void onAdDisplayed(final MaxAd maxAd) {}
@Override
public void onAdClicked(final MaxAd maxAd) {}
@Override
public void onAdHidden(final MaxAd maxAd)
{
// rewarded ad is hidden. Pre-load the next ad
rewardedAd.loadAd();
}
@Override
public void onUserRewarded(final MaxAd maxAd, final MaxReward maxReward)
{
// Rewarded ad was displayed and user should receive the reward
}
}
class ExampleActivity : Activity(), MaxRewardedAdListener
{
private lateinit var rewardedAd: MaxRewardedAd
private var retryAttempt = 0.0
fun createRewardedAd()
{
rewardedAd = MaxRewardedAd.getInstance( "«ad-unit-ID»" )
rewardedAd.setListener( this )
rewardedAd.loadAd()
}
// MAX Ad Listener
override fun onAdLoaded(maxAd: MaxAd)
{
// Rewarded ad is ready to be shown. rewardedAd.isReady() will now return 'true'
// Reset retry attempt
retryAttempt = 0.0
}
override fun onAdLoadFailed(adUnitId: String?, error: MaxError?)
{
// Rewarded ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)
retryAttempt++
val delayMillis = TimeUnit.SECONDS.toMillis( Math.pow( 2.0, Math.min( 6.0, retryAttempt ) ).toLong() )
Handler().postDelayed( { rewardedAd.loadAd() }, delayMillis )
}
override fun onAdDisplayFailed(ad: MaxAd?, error: MaxError?)
{
// Rewarded ad failed to display. AppLovin recommends that you load the next ad
rewardedAd.loadAd()
}
override fun onAdDisplayed(maxAd: MaxAd) {}
override fun onAdClicked(maxAd: MaxAd) {}
override fun onAdHidden(maxAd: MaxAd)
{
// rewarded ad is hidden. Pre-load the next ad
rewardedAd.loadAd()
}
override fun onUserRewarded(maxAd: MaxAd, maxReward: MaxReward)
{
// Rewarded ad was displayed and user should receive the reward
}
}
rewarded ad를 표시하려면 위에서 생성한 MaxRewardedAd 객체에서 showAd()를 호출합니다.
if ( rewardedAd.isReady() )
{
rewardedAd.showAd();
}
if ( rewardedAd.isReady() )
{
rewardedAd.showAd();
}
가상화폐 서버로 콜백을 받는 방법을 알아보려면 MAX S2S rewarded 콜백 API 가이드를 참조하고 Edit Ad Unit 페이지에서 S2S Rewarded Callback URL을 업데이트하세요.
banner 광고 또는 MREC를 로드하려면 ad unit으로 MaxAdView 객체를 생성하고 loadAd()를 호출합니다.
표시하려면 MaxAdView 객체를 뷰 계층 구조의 하위 뷰로 추가합니다.
광고가 준비되었을 때와 기타 광고 관련 이벤트에 대한 알림을 받을 수 있도록 MaxAdViewAdListener를 구현합니다.
public class ExampleActivity extends Activity
implements MaxAdViewAdListener
{
private MaxAdView adView;
void createBannerAd()
{
adView = new MaxAdView( "«ad-unit-ID»" );
adView.setListener( this );
// Stretch to the width of the screen for banners to be fully functional
int width = ViewGroup.LayoutParams.MATCH_PARENT;
// Banner height on phones and tablets is 50 and 90, respectively
int heightPx = getResources().getDimensionPixelSize( R.dimen.banner_height );
adView.setLayoutParams( new FrameLayout.LayoutParams( width, heightPx ) );
// Set background or background color for banners to be fully functional
adView.setBackgroundColor( ... );
ViewGroup rootView = findViewById( android.R.id.content );
rootView.addView( adView );
// Load the ad
adView.loadAd();
}
// MAX Ad Listener
@Override
public void onAdLoaded(final MaxAd maxAd) {}
@Override
public void onAdLoadFailed(final String adUnitId, final int errorCode) {}
@Override
public void onAdDisplayFailed(final MaxAd maxAd, final MaxError error) {}
@Override
public void onAdClicked(final MaxAd maxAd) {}
@Override
public void onAdExpanded(final MaxAd maxAd) {}
@Override
public void onAdCollapsed(final MaxAd maxAd) {}
@Override
public void onAdDisplayed(final MaxAd maxAd) { /* use this for impression tracking */ }
@Override
public void onAdHidden(final MaxAd maxAd) { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
}
class ExampleActivity : Activity(), MaxAdViewAdListener
{
private var adView: MaxAdView? = null
fun createBannerAd()
{
adView = MaxAdView("«ad-unit-ID»")
adView?.setListener(this)
// Stretch to the width of the screen for banners to be fully functional
val width = ViewGroup.LayoutParams.MATCH_PARENT
// Banner height on phones and tablets is 50 and 90, respectively
val heightPx = resources.getDimensionPixelSize(R.dimen.banner_height)
adView?.layoutParams = FrameLayout.LayoutParams(width, heightPx)
// Set background or background color for banners to be fully functional
adView?.setBackgroundColor(...)
val rootView = findViewById<ViewGroup>(android.R.id.content)
rootView.addView(adView)
// Load the ad
adView?.loadAd()
}
// MAX Ad Listener
override fun onAdLoaded(maxAd: MaxAd) {}
override fun onAdLoadFailed(adUnitId: String?, error: MaxError?) {}
override fun onAdDisplayFailed(ad: MaxAd?, error: MaxError?) {}
override fun onAdClicked(maxAd: MaxAd) {}
override fun onAdExpanded(maxAd: MaxAd) {}
override fun onAdCollapsed(maxAd: MaxAd) {}
override fun onAdDisplayed(maxAd: MaxAd) { /* use this for impression tracking */ }
override fun onAdHidden(maxAd: MaxAd) { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
}
public class ExampleActivity extends Activity
implements MaxAdViewAdListener
{
private MaxAdView adView;
void createMrecAd
{
adView = new MaxAdView( "«ad-unit-ID»", MaxAdFormat.MREC );
adView.setListener( this );
// MREC width and height are 300 and 250 respectively, on phones and tablets
int widthPx = AppLovinSdkUtils.dpToPx( this, 300 );
int heightPx = AppLovinSdkUtils.dpToPx( this, 250 );
adView.setLayoutParams( new FrameLayout.LayoutParams( widthPx, heightPx ) );
// Set background or background color for MRECs to be fully functional
adView.setBackgroundColor( ... );
ViewGroup rootView = findViewById( android.R.id.content );
rootView.addView( adView );
// Load the ad
adView.loadAd();
}
// MAX Ad Listener
@Override
public void onAdLoaded(final MaxAd maxAd) {}
@Override
public void onAdLoadFailed(final String adUnitId, final int errorCode) {}
@Override
public void onAdDisplayFailed(final MaxAd maxAd, final MaxError error) {}
@Override
public void onAdClicked(final MaxAd maxAd) {}
@Override
public void onAdExpanded(final MaxAd maxAd) {}
@Override
public void onAdCollapsed(final MaxAd maxAd) {}
@Override
public void onAdDisplayed(final MaxAd maxAd) { /* use this for impression tracking */ }
@Override
public void onAdHidden(final MaxAd maxAd) { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
}
class ExampleActivity : Activity(), MaxAdViewAdListener
{
private var adView: MaxAdView? = null
fun createMrecAd
{
adView = MaxAdView("«ad-unit-ID»", MaxAdFormat.MREC)
adView?.setListener(this)
// MREC width and height are 300 and 250 respectively, on phones and tablets
val widthPx = AppLovinSdkUtils.dpToPx(this, 300)
val heightPx = AppLovinSdkUtils.dpToPx(this, 250)
adView?.layoutParams = FrameLayout.LayoutParams(widthPx, heightPx)
// Set background or background color for MRECs to be fully functional
adView?.setBackgroundColor(...)
val rootView = findViewById<ViewGroup>(android.R.id.content)
rootView.addView(adView)
// Load the ad
adView?.loadAd()
}
// MAX Ad Listener
override fun onAdLoaded(maxAd: MaxAd) {}
override fun onAdLoadFailed(adUnitId: String?, error: MaxError?) {}
override fun onAdDisplayFailed(ad: MaxAd?, error: MaxError?) {}
override fun onAdClicked(maxAd: MaxAd) {}
override fun onAdExpanded(maxAd: MaxAd) {}
override fun onAdCollapsed(maxAd: MaxAd) {}
override fun onAdDisplayed(maxAd: MaxAd) { /* use this for impression tracking */ }
override fun onAdHidden(maxAd: MaxAd) { /* DO NOT USE - THIS IS RESERVED FOR FULLSCREEN ADS ONLY AND WILL BE REMOVED IN A FUTURE SDK RELEASE */ }
}
뷰 레이아웃 XML에 MAX banner 또는 MREC를 추가할 수도 있습니다.
배경 또는 배경색(android:background)을 설정하여 광고가 정상적으로 작동하도록 하세요.
banner의 경우, 너비(android:layout_width)를 화면 너비에 맞게 늘립니다.
MREC의 경우, 다음과 같이 android:adFormat을 설정합니다:
<com.applovin.mediation.ads.MaxAdView
xmlns:maxads="http://schemas.applovin.com/android/1.0"
maxads:adUnitId="«ad-unit-ID»"
android:background="@color/banner_background_color"
android:layout_width="match_parent"
android:layout_height="@dimen/banner_height" />
<com.applovin.mediation.ads.MaxAdView
xmlns:maxads="http://schemas.applovin.com/android/1.0"
maxads:adUnitId="«ad-unit-ID»"
maxads:adFormat="MREC"
android:background="@color/mrec_background_color"
android:layout_width="300dp"
android:layout_height="250dp" />
res/values/attrs.xml에 기본 banner 높이인 50 dp를 선언합니다:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="banner_height">50dp</dimen>
</resources>
res/values-sw600dp/attrs.xml에 태블릿 banner 높이인 90 dp를 선언합니다:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="banner_height">90dp</dimen>
</resources>
banner 또는 MREC 광고를 숨기려면 다음을 호출합니다:
adView.setVisibility( View.GONE );
adView.stopAutoRefresh();
adView.visibility = View.GONE
adView.stopAutoRefresh()
banner 또는 MREC 광고를 표시하려면 다음을 호출합니다:
adView.setVisibility( View.VISIBLE );
adView.startAutoRefresh();
adView.visibility = View.VISIBLE
adView.startAutoRefresh()
연동할 광고 네트워크를 선택합니다. 그 다음 특정 안내를 따르세요.
AndroidX 라이브러리를 프로젝트에 연동합니다. 프로젝트 마이그레이션 방법에 대한 자세한 내용은 AndroidX로 마이그레이션 가이드를 참조하세요.
Google AdSense, AdManager 또는 AdMob을 사용하는 개발자 및 퍼블리셔는 Google이 인증한 동의 관리 플랫폼(CMP)을 사용해야 합니다. 유럽 경제 지역(EEA) 또는 영국의 사용자에게 광고를 게재할 때는 CMP가 IAB의 투명성 및 동의 프레임워크(TCF)와 연동되어야 합니다. 자세한 내용은 개인정보 보호: “TCF v2 동의”를 참조하세요.
앱의 AndroidManifest.xml에서 <application> 태그 내부에 <meta-data> 태그를 추가합니다.
아래 예제는 이 태그의 올바른 속성을 보여줍니다.
«your-admob-app-id»를 귀하의 Google bidding 및 Google AdMob / Google Ad Manager 앱 ID로 교체하세요.
<?xml version="1.0" encoding="utf-8"?>
<manifest … >
<application … >
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="«your-admob-app-id»"/>
⋮
</application>
</manifest>
Google AdMob은 Android Gradle 플러그인 버전 4.2.0 이상 및 Gradle 버전 6.7.1 이상을 요구합니다. 다음 에러가 발생하는 경우, Android Gradle 플러그인 및 Gradle 버전을 업데이트하세요:
AAPT: error: unexpected element <property> found in <manifest><application>.
compileSdkVersionGoogle Mobile Ads SDK 버전 23.1.0 이상은 최소 34의 compileSdkVersion을 요구합니다.
앱의 build.gradle에서 compileSdkVersion을 34 이상으로 설정하세요.
최신 compileSdkVersion 요구 사항은 Google Mobile Ads SDK 릴리즈 노트를 참조하세요.
Amazon Publisher Services SDK는 MAX SDK 외부에서 초기화해야 합니다:
// Amazon requires an 'Activity' instance
AdRegistration.getInstance( "AMAZON_APP_ID", this );
AdRegistration.setMRAIDSupportedVersions( new String[] { "1.0", "2.0", "3.0" } );
AdRegistration.setMRAIDPolicy( MRAIDPolicy.CUSTOM );
Amazon 광고를 MAX에 연동하려면 먼저 Amazon 광고를 로드해야 합니다.
MAX 광고를 로드하기 전에 DTBAdResponse 또는 AdError를 MaxAdView 인스턴스에 전달합니다.
이는 MaxAdView#setLocalExtraParameter()를 호출하여 수행할 수 있습니다.
자동 새로고침되는 banner 광고의 경우, 광고를 한 번만 로드하면 됩니다.
class ExampleActivity
extends Activity
{
⋮
private void loadAd()
{
String amazonAdSlotId;
MaxAdFormat adFormat;
if ( AppLovinSdkUtils.isTablet( getApplicationContext() ) )
{
amazonAdSlotId = "«Amazon-leader-slot-ID»";
adFormat = MaxAdFormat.LEADER;
}
else
{
amazonAdSlotId = "«Amazon-banner-slot-ID»";
adFormat = MaxAdFormat.BANNER;
}
// Raw size will be 320x50 for BANNERs on phones, and 728x90 for LEADERs on tablets
AppLovinSdkUtils.Size rawSize = adFormat.getSize();
DTBAdSize size = new DTBAdSize( rawSize.getWidth(), rawSize.getHeight(), amazonAdSlotId );
DTBAdRequest adLoader = new DTBAdRequest( getApplicationContext(), new DTBAdNetworkInfo( ApsAdNetwork.MAX ) );
adLoader.setSizes( size );
adLoader.loadAd( new DTBAdCallback()
{
@Override
public void onSuccess(@NonNull final DTBAdResponse dtbAdResponse)
{
// 'adView' is your instance of MaxAdView
adView.setLocalExtraParameter( "amazon_ad_response", dtbAdResponse );
adView.loadAd();
}
@Override
public void onFailure(@NonNull final AdError adError)
{
// 'adView' is your instance of MaxAdView
adView.setLocalExtraParameter( "amazon_ad_error", adError );
adView.loadAd();
}
} );
}
}
class ExampleActivity : Activity()
{
private val adView: MaxAdView? = null
private fun loadAd()
{
val amazonAdSlotId: String
val adFormat: MaxAdFormat
if (AppLovinSdkUtils.isTablet(applicationContext))
{
amazonAdSlotId = "«Amazon-leader-slot-ID»"
adFormat = MaxAdFormat.LEADER
}
else
{
amazonAdSlotId = "«Amazon-banner-slot-ID»"
adFormat = MaxAdFormat.BANNER
}
// Raw size will be 320x50 for BANNERs on phones, and 728x90 for LEADERs on tablets
val rawSize = adFormat.size
val size = DTBAdSize(rawSize.width, rawSize.height, amazonAdSlotId)
val adLoader = DTBAdRequest( applicationContext, DTBAdNetworkInfo( ApsAdNetwork.MAX ) )
adLoader.setSizes(size)
adLoader.loadAd(object : DTBAdCallback
{
override fun onSuccess(dtbAdResponse: DTBAdResponse)
{
// 'adView' is your instance of MaxAdView
adView?.setLocalExtraParameter("amazon_ad_response", dtbAdResponse)
adView?.loadAd()
}
override fun onFailure(adError: AdError)
{
// 'adView' is your instance of MaxAdView
adView?.setLocalExtraParameter("amazon_ad_error", adError)
adView?.loadAd()
}
})
}
}
class ExampleActivity
extends Activity
{
⋮
private void loadAd()
{
String amazonAdSlotId;
DTBAdRequest adLoader = new DTBAdRequest( getApplicationContext(), new DTBAdNetworkInfo( ApsAdNetwork.MAX ) );
adLoader.setSizes( new DTBAdSize( 300, 250, amazonAdSlotId ) );
adLoader.loadAd( new DTBAdCallback()
{
@Override
public void onSuccess(@NonNull final DTBAdResponse dtbAdResponse)
{
// 'adView' is your instance of MaxAdView
adView.setLocalExtraParameter( "amazon_ad_response", dtbAdResponse );
adView.loadAd();
}
@Override
public void onFailure(@NonNull final AdError adError)
{
// 'adView' is your instance of MaxAdView
adView.setLocalExtraParameter( "amazon_ad_error", adError );
adView.loadAd();
}
} );
}
}
class ExampleActivity : Activity()
{
private val adView: MaxAdView? = null
private fun loadAd()
{
val amazonAdSlotId: String
val adLoader = DTBAdRequest( applicationContext, DTBAdNetworkInfo( ApsAdNetwork.MAX ) )
adLoader.setSizes(DTBAdSize(300, 250, amazonAdSlotId))
adLoader.loadAd(object : DTBAdCallback
{
override fun onSuccess(dtbAdResponse: DTBAdResponse)
{
// 'adView' is your instance of MaxAdView
adView!!.setLocalExtraParameter("amazon_ad_response", dtbAdResponse)
adView.loadAd()
}
override fun onFailure(adError: AdError)
{
// 'adView' is your instance of MaxAdView
adView!!.setLocalExtraParameter("amazon_ad_error", adError)
adView.loadAd()
}
})
}
}
Amazon interstitial ad를 MAX에 연동하려면 먼저 Amazon 광고를 로드해야 합니다.
MAX 광고를 로드하기 전에 DTBAdResponse 또는 AdError를 MaxInterstitialAd 인스턴스에 전달합니다.
이는 MaxInterstitialAd#setLocalExtraParameter()를 호출하여 수행할 수 있습니다.
세션당 한 번만 Amazon DTBAdResponse 또는 DTBAdErrorInfo를 로드하여 MaxInterstitialAd 인스턴스에 전달해야 합니다.
class ExampleActivity
extends Activity
{
private static MaxInterstitialAd interstitialAd; // static to ensure only one instance exists
private static boolean isFirstLoad = true;
private void loadAd()
{
if ( isFirstLoad )
{
isFirstLoad = false;
if ( interstitialAd == null )
{
interstitialAd = new MaxInterstitialAd( "«MAX-inter-ad-unit-ID»" );
}
DTBAdRequest adLoader = new DTBAdRequest( getApplicationContext(), new DTBAdNetworkInfo( ApsAdNetwork.MAX ) );
adLoader.setSizes( new DTBAdSize.DTBInterstitialAdSize( "«Amazon-inter-slot-ID»" ) );
adLoader.loadAd( new DTBAdCallback()
{
@Override
public void onSuccess(@NonNull final DTBAdResponse dtbAdResponse)
{
// 'interstitialAd' is your instance of MaxInterstitialAd
interstitialAd.setLocalExtraParameter( "amazon_ad_response", dtbAdResponse );
interstitialAd.loadAd();
}
@Override
public void onFailure(@NonNull final AdError adError)
{
// 'interstitialAd' is your instance of MaxInterstitialAd
interstitialAd.setLocalExtraParameter( "amazon_ad_error", adError );
interstitialAd.loadAd();
}
} );
}
else
{
interstitialAd.loadAd();
}
}
}
class ExampleActivity : Activity()
{
private var interstitialAd: MaxInterstitialAd? = null // static to ensure only one instance exists
private var isFirstLoad = true
private fun loadAd()
{
if (isFirstLoad)
{
isFirstLoad = false
if (interstitialAd == null)
{
interstitialAd = MaxInterstitialAd("«MAX-inter-ad-unit-ID»", this)
}
val adLoader = DTBAdRequest( applicationContext, DTBAdNetworkInfo( ApsAdNetwork.MAX ) )
adLoader.setSizes(DTBAdSize.DTBInterstitialAdSize("«Amazon-inter-slot-ID»"))
adLoader.loadAd(object : DTBAdCallback
{
override fun onSuccess(dtbAdResponse: DTBAdResponse)
{
// 'interstitialAd' is your instance of MaxInterstitialAd
interstitialAd!!.setLocalExtraParameter("amazon_ad_response", dtbAdResponse)
interstitialAd!!.loadAd()
}
override fun onFailure(adError: AdError)
{
// 'interstitialAd' is your instance of MaxInterstitialAd
interstitialAd!!.setLocalExtraParameter("amazon_ad_error", adError)
interstitialAd!!.loadAd()
}
})
}
else
{
interstitialAd!!.loadAd()
}
}
}
Amazon 비디오 interstitial ad를 MAX에 연동하려면 먼저 Amazon 광고를 로드해야 합니다.
MAX 광고를 로드하기 전에 DTBAdResponse 또는 AdError를 MaxInterstitialAd 인스턴스에 전달합니다.
이는 MaxInterstitialAd#setLocalExtraParameter()를 호출하여 수행할 수 있습니다.
세션당 한 번만 DTBAdResponse 또는 DTBAdErrorInfo를 로드하여 MaxInterstitialAd 인스턴스에 전달해야 합니다.
class ExampleActivity
extends Activity
{
private static MaxInterstitialAd interstitialAd; // static to ensure only one instance exists
private static boolean isFirstLoad = true;
private void loadAd()
{
if ( isFirstLoad )
{
isFirstLoad = false;
if ( interstitialAd == null )
{
interstitialAd = new MaxInterstitialAd( "«MAX-inter-ad-unit-ID»" );
}
DTBAdRequest adLoader = new DTBAdRequest( getApplicationContext(), new DTBAdNetworkInfo( ApsAdNetwork.MAX ) );
// Switch video player width and height values(320, 480) depending on device orientation
adLoader.setSizes( new DTBAdSize.DTBVideo(320, 480, "«Amazon-video-inter-slot-ID»") );
adLoader.loadAd( new DTBAdCallback()
{
@Override
public void onSuccess(@NonNull final DTBAdResponse dtbAdResponse)
{
// 'interstitialAd' is your instance of MaxInterstitialAd
interstitialAd.setLocalExtraParameter( "amazon_ad_response", dtbAdResponse );
interstitialAd.loadAd();
}
@Override
public void onFailure(@NonNull final AdError adError)
{
// 'interstitialAd' is your instance of MaxInterstitialAd
interstitialAd.setLocalExtraParameter( "amazon_ad_error", adError );
interstitialAd.loadAd();
}
} );
}
else
{
interstitialAd.loadAd();
}
}
}
class ExampleActivity : Activity()
{
private var interstitialAd: MaxInterstitialAd? = null // static to ensure only one instance exists
private var isFirstLoad = true
private fun loadAd()
{
if (isFirstLoad)
{
isFirstLoad = false
if (interstitialAd == null)
{
interstitialAd = MaxInterstitialAd("«MAX-inter-ad-unit-iD»", this)
}
val adLoader = DTBAdRequest( applicationContext, DTBAdNetworkInfo( ApsAdNetwork.MAX ) )
// Switch video player width and height values(320, 480) depending on device orientation
adLoader.setSizes(DTBAdSize.DTBVideo(320, 480, "«Amazon-video-inter-slot-ID»"))
adLoader.loadAd(object : DTBAdCallback
{
override fun onSuccess(dtbAdResponse: DTBAdResponse)
{
// 'interstitialAd' is your instance of MaxInterstitialAd
interstitialAd!!.setLocalExtraParameter("amazon_ad_response", dtbAdResponse)
interstitialAd!!.loadAd()
}
override fun onFailure(adError: AdError)
{
// 'interstitialAd' is your instance of MaxInterstitialAd
interstitialAd!!.setLocalExtraParameter("amazon_ad_error", adError)
interstitialAd!!.loadAd()
}
})
}
else
{
interstitialAd!!.loadAd()
}
}
}
Amazon rewarded video를 MAX에 연동하려면 먼저 Amazon 광고를 로드해야 합니다.
MAX 광고를 로드하기 전에 DTBAdResponse 또는 AdError를 MaxRewardedAd 인스턴스에 전달합니다.
이는 MaxRewardedAd#setLocalExtraParameter()를 호출하여 수행할 수 있습니다.
세션당 한 번만 DTBAdResponse 또는 AdError를 MaxRewardedAd 인스턴스에 전달해야 합니다.
class ExampleActivity
extends Activity
{
private static MaxRewardedAd rewardedAd; // static to ensure only one instance exists
private static boolean isFirstLoad = true;
private void loadAd()
{
if ( isFirstLoad )
{
isFirstLoad = false;
if ( rewardedAd == null )
{
rewardedAd = MaxRewardedAd.getInstance( "«MAX-rewarded-ad-unit-ID»" );
}
DTBAdRequest adLoader = new DTBAdRequest( getApplicationContext(), new DTBAdNetworkInfo( ApsAdNetwork.MAX ) );
// Switch video player width and height values(320, 480) depending on device orientation
adLoader.setSizes( new DTBAdSize.DTBVideo( 320, 480, "«Amazon-video-rewarded-slot-ID»" ) );
adLoader.loadAd( new DTBAdCallback()
{
@Override
public void onSuccess(@NonNull final DTBAdResponse dtbAdResponse)
{
// 'rewardedAd' is your instance of MaxRewardedAd
rewardedAd.setLocalExtraParameter( "amazon_ad_response", dtbAdResponse );
rewardedAd.loadAd();
}
@Override
public void onFailure(@NonNull final AdError adError)
{
// 'rewardedAd' is your instance of MaxRewardedAd
rewardedAd.setLocalExtraParameter( "amazon_ad_error", adError );
rewardedAd.loadAd();
}
} );
}
else
{
rewardedAd.loadAd();
}
}
}
class ExampleActivity
extends Activity
{
private static MaxRewardedAd rewardedAd; // static to ensure only one instance exists
private static boolean isFirstLoad = true;
private void loadAd()
{
if ( isFirstLoad )
{
isFirstLoad = false;
if ( rewardedAd == null )
{
rewardedAd = MaxRewardedAd.getInstance( "«MAX-rewarded-ad-unit-ID»" );
}
DTBAdRequest adLoader = new DTBAdRequest( getApplicationContext(), new DTBAdNetworkInfo( ApsAdNetwork.MAX ) );
// Switch video player width and height values(320, 480) depending on device orientation
adLoader.setSizes( new DTBAdSize.DTBVideo( 320, 480, "«Amazon-video-rewarded-slot-ID»" ) );
adLoader.loadAd( new DTBAdCallback()
{
@Override
public void onSuccess(@NonNull final DTBAdResponse dtbAdResponse)
{
// 'rewardedAd' is your instance of MaxRewardedAd
rewardedAd.setLocalExtraParameter( "amazon_ad_response", dtbAdResponse );
rewardedAd.loadAd();
}
@Override
public void onFailure(@NonNull final AdError adError)
{
// 'rewardedAd' is your instance of MaxRewardedAd
rewardedAd.setLocalExtraParameter( "amazon_ad_error", adError );
rewardedAd.loadAd();
}
} );
}
else
{
rewardedAd.loadAd();
}
}
}
AppLovin은 Amazon SDK에 대해 테스트 모드를 활성화할 것을 권장합니다. 이를 통해 테스트 광고를 수신할 수 있습니다. 다음 호출을 통해 테스트 모드를 활성화합니다:
AdRegistration.enableTesting( true );
AdRegistration.enableLogging( true );
Amazon 광고만 포함하도록 waterfall을 필터링할 수 있습니다. 이를 위해 Mediation Debugger에서 Select Live Network로 이동하여 Amazon 네트워크를 선택합니다.
Limited Data Use (LDU) 모드를 활성화하지 않으려면 SetDataProcessingOptions()에 빈 문자열 배열을 전달합니다:
import com.facebook.ads.AdSettings;
⋮
AdSettings.setDataProcessingOptions( new String[] {} );
⋮
// Initialize MAX SDK
import com.facebook.ads.AdSettings
⋮
AdSettings.setDataProcessingOptions( arrayOf<String>() )
⋮
// Initialize MAX SDK
사용자에게 LDU를 활성화하고 사용자 지역을 지정하려면 다음과 같은 형식으로 SetDataProcessingOptions()를 호출합니다:
import com.facebook.ads.AdSettings;
⋮
AdSettings.setDataProcessingOptions( new String[] {"LDU"}, «country», «state» );
⋮
// Initialize MAX SDK
import com.facebook.ads.AdSettings
⋮
AdSettings.setDataProcessingOptions( arrayOf("LDU"), «country», «state» )
⋮
// Initialize MAX SDK
Google UMP를 CMP로 사용하는 경우, 사용자가 Meta에 동의했는지 여부를 확인할 수 있습니다. 이를 위해 다음과 같은 코드를 사용합니다:
Boolean hasMetaConsent = AppLovinPrivacySettings.getAdditionalConsentStatus( 89 );
if ( hasMetaConsent != null )
{
// Set Meta Data Processing Options accordingly.
}
else
{
// AC String is not available on disk. Please check for consent status after the user completes the CMP flow.
}
val hasMetaConsent = AppLovinPrivacySettings.getAdditionalConsentStatus(89)
if ( hasMetaConsent != null )
{
// Set Meta Data Processing Options accordingly.
}
else
{
// AC String is not available on disk. Please check for consent status after the user completes the CMP flow.
}
캘리포니아에서 Meta Audience Network의 “Limited Data Use” 플래그를 구현하는 방법을 알아보려면 Meta for Developers 문서를 방문하세요.
일부 네트워크 SDK는 번들로 제공되는 Android Manifest 파일에 <queries> 요소를 포함합니다.
호환되지 않는 버전의 Android Gradle 플러그인을 사용하는 경우, 이로 인해 다음과 같은 빌드 에러 중 하나가 발생합니다:
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
error: unexpected element <queries> found in <manifest>.
Missing 'package' key attribute on element package at [:com.my.target.mytarget-sdk-5.11.3:]
AndroidManifest Validation failed
이 에러를 해결하려면 <queries> 요소를 지원하는 다음 버전 중 하나로 Android Gradle 플러그인을 업그레이드하세요:
Gradle Build Tools가 아닌 Android Gradle 플러그인을 업그레이드하세요.
| 현재 Android Gradle 플러그인 버전 | <queries> 요소를 지원하는 버전 |
|---|---|
| 4.1.* | 전체 |
| 4.0.* | 4.0.1+ |
| 3.6.* | 3.6.4+ |
| 3.5.* | 3.5.4+ |
| 3.4.* | 3.4.3+ |
| 3.3.* | 3.3.3+ |