AdMob Aggregation Guide - uc-union/union-ads-sdk-demo GitHub Wiki
For more details please visit Google AdMob official site
SDK Manager
In the Android SDK Manager window,select Extras
> Google Repository
, and click on Install Packages start to download after accepting the license agreement。If the Install Packages button cannot be used,don't worry. It means you have the latest version already. You don't need to take any action in SDK Manger.
Add dependencies
to build.gradle
dependencies {
compile 'com.google.android.gms:play-services-ads:8.4.0'
}
For more details: app/build.gradle
Note: if you use Android Studio,you can skip this section.
-
Import the content under
<android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/
into current project. -
Add the following content to
AndroidManifest.xml
<!-- Include required permissions for Google Mobile Ads to run--> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <application android:label="@string/app_name" > ... <!--This meta-data tag is required to use Google Play Services.--> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <!--Include the AdActivity configChanges and theme. --> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" /> </application>
-
Add the following content to
proguard.pro
-keep class * extends java.util.ListResourceBundle { protected java.lang.Object[][] getContents(); } # Keep SafeParcelable value, needed for reflection. This is required to support backwards # compatibility of some classes. -keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable { public static final *** NULL; } # Keep the names of classes/members we need for client functionality. -keep @interface com.google.android.gms.common.annotation.KeepName -keepnames @com.google.android.gms.common.annotation.KeepName class * -keepclassmembernames class * { @com.google.android.gms.common.annotation.KeepName *; } # Needed for Parcelable/SafeParcelable Creators to not get stripped -keepnames class * implements android.os.Parcelable { public static final ** CREATOR; } # Needed when building against pre-Marshmallow SDK. -dontwarn android.security.NetworkSecurityPolicy # Keep metadata about included modules. -keep public class com.google.android.gms.dynamite.descriptors.** { public <fields>; } # Keep the implementation of the flags api for google-play-services-flags -keep public class com.google.android.gms.flags.impl.FlagProviderImpl { public <fields>; public <methods>; }