1. ์ ๋๋ชน ํ์๊ฐ์ / ์ฑ ๋ฑ๋ก
๊ตฌ๊ธ ์ ๋๋ชน ํ์๊ฐ์ ์ ํ๋ฉด ์ฒซ ํ์ด์ง์ ์๋์ ๊ฐ์ด ๋์ต๋๋ค.
์ฒซ ๋ฒ์งธ ์ฑ ์ถ๊ฐ๋ฅผ ๋๋ฆ ๋๋ค.



2. ์ ๋๋ชน - ๊ด๊ณ ๋จ์(์ ๋ฉด, ๋ฐฐ๋ ๊ด๊ณ ์ถ๊ฐ)



3. Android ์ฝ๋ ์ถ๊ฐ
build.gradle (Module: app)
๊ตฌ๊ธ ์ ๋๋ชน(google admob) dependencies๋ฅผ ์ถ๊ฐํด์ค๋๋ค.
dependencies {
// ์ถ๊ฐํ๊ธฐ
implementation 'com.google.android.gms:play-services-ads:22.6.0'
}
AndroidManifest.xml
AndroidManifest ํ์ผ์ application ํ๊ทธ์์ meta-data๋ฅผ ์๋์ ๊ฐ์ด ์ ๋ ฅํฉ๋๋ค.
value ๊ฐ์ ํ ์คํธ ๊ด๊ณ ID๋ฅผ ์ ๋ ฅํ์ต๋๋ค.
๊ตฌ๊ธ ์ ๋๋ชน(google admob)์ ํ
์คํธ ์์ด๋๋ ca-app-pub-3940256099942544~3347511713
์
๋๋ค.
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<application
...
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
</application>
</manifest>
์์ ์ com.google.android.gms.ads.APPLICATION_ID
๋ ์ ๋๋ชน - ์ฑ ์ค์
์์ ์ ์ ์์ต๋๋ค.

์ ๋๋ชน ๋ ์ด์์ ๊ตฌ์ฑ (activity_main.xml)
๋ ์ด์์์ ๊ด๊ณ ๋ฐฐ๋๋ฅผ ์ถ๊ฐํด์ค๋๋ค.
๋ณดํต ํ๋จ์ ๋ง์ด ๋ฐฐ์นํ๊ธฐ ๋๋ฌธ์ ํ๋จ์ ๋ฐฐ์นํ์ต๋๋ค.
adSize๋ ๋ฐฐ๋, adUnitId์๋ ํ ์คํธ ๊ด๊ณ ๋จ์ ID๋ฅผ ์ ๋ ฅํ์ต๋๋ค.
adUnitId๋ ์ ๋๋ชน - ๊ด๊ณ ๋จ์ ์์ ๋ณผ ์ ์์ต๋๋ค.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:text="Hello World!!!"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
// ์ถ๊ฐํ๊ธฐ
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintBottom_toBottomOf="parent"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978123">
</com.google.android.gms.ads.AdView>
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.kt ์ฝ๋ ์์ฑํ๊ธฐ
๋ฉ์ธ ์กํฐ๋นํฐ์ onCreate๋ฉ์๋ ์์ MobileAds๋ฅผ Intiailize ํ๋ ์ฝ๋๋ฅผ ๋ฃ์ด์ค๋๋ค.
๋น๋ํจํด์ ํตํด AdRequest ๊ฐ์ฒด๋ฅผ ์์ฑํ๊ณ , AdView์ loadAd๋ฅผ ํธ์ถ ๋ฐ ํ๋ผ๋ฏธํฐ๋ก ์ ๋ฌํฉ๋๋ค.
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
MobileAds.initialize(this)
val adRequest = AdRequest.Builder().build()
binding.adView.loadAd(adRequest)
}
}
๊ฒฐ๊ณผ
