90 words
1 minute

Integrating AdMob into Unity

2024-01-20
Views —

Reference documentation#

Resolve dependencies#

In Unity, use the Google Mobile Ads dependency tools:

  • Android: Assets → Google Mobile Ads → Android → Resolve.
  • iOS: Assets → Google Mobile Ads → iOS → CocoaPods.

Fix a missing initialization-listener class#

I encountered this error:

AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.ads.initialization.OnInitializationCompleteListener

Go to Build Settings → Player Settings → Publishing Settings and enable Custom Proguard File.

Add the following rules to proguard-user.txt:

-keep class com.google.unity.** {
*;
}
-keep public class com.google.android.gms.ads.**{
public *;
}
-keep public class com.google.ads.**{
public *;
}
-keepattributes *Annotation*
-dontobfuscate
Integrating AdMob into Unity
https://blog.coding1024.com/en/posts/1621995/
Author
huangjx
Published at
2024-01-20
License
CC BY-NC-SA 4.0

Comments

Questions, ideas and experiences are welcome. Please be kind and avoid sharing private information.

Loading comments…