AdMob聚合介绍 - uc-union/union-ads-sdk-demo GitHub Wiki
SDK Manager
在 Android SDK Manager 窗口中,选择 Extras
文件夹下的 Google Repository
,然后按 **Install Packages(安装程序包)**并接受许可协议以开始下载。如果 **Install Packages(安装程序包)**按钮不能使用,请不要担心。这恰恰说明您已经拥有最新版本,因此无需在 SDK Manager 中进行任何操作。
在build.gradle
中添加dependencies
依赖
dependencies {
compile 'com.google.android.gms:play-services-ads:8.4.0'
}
注意: 如果开发者是使用Android Studio,可以跳过本节
-
把
<android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/
下的导入到当前开发项目即可。 -
在
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>
-
在
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>; }