Android studio 添加admob googgle play services

 MainActivity 
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.MobileAds;
private InterstitialAd mInterstitialAd;
 // Initialize the Mobile Ads SDK.
MobileAds.initialize(getApplicationContext(), "ca-app-pub-8067415904846806/59920985");
// Create the InterstitialAd and set the adUnitId.
mInterstitialAd = new InterstitialAd(this);
// Defined in res/values/strings.xml
mInterstitialAd.setAdUnitId("xxx"); mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
// startGame();
}
@Override
public void onAdLoaded() {
super.onAdLoaded();
Log.i("sdf","Ad loaded !");
}
});
AdRequest adRequest = new AdRequest.Builder().addTestDevice("0E1F15F35CE93F7A77BDDB59F7FE29AF").build();
mInterstitialAd.loadAd(adRequest); AndroidManifest.xml

<!-- Used to request banner and interstitial ads. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Used to avoid sending an ad request if there is no connectivity. -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<!-- Required permissions for video ads. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" /> <activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" /> app build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
}) compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
compile 'com.google.android.gms:play-services-ads:10.2.0'
compile 'com.android.support:multidex:1.0.1' }
apply plugin: 'com.google.gms.google-services'

project  build.gradle

dependencies {
classpath 'com.android.tools.build:gradle:2.4.0-alpha6'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}

Android studio 添加admob googgle play services的更多相关文章

  1. 在Xcode5和Android Studio添加工程间的依赖

    正在编辑中,尚未完成 先看看ios的target是什么,请先参看http://www.cocoachina.com/bbs/read.php?tid-10884.html做个大概了解 这里有一篇文章, ...

  2. Eclipse / android studio 添加第三方jar包 步骤

    eclipse 将第三方包放到libs文件夹后并没有引用. 基本步骤分为3步,具体介绍如下: 打开自己的Eclipse,在自己的Android工程上名上右键->Build Path ->C ...

  3. Android Studio 添加Assets目录

    Android Studio 添加Assets目录: 法一: Since Android Studio uses the new Gradle-based build system, you shou ...

  4. 【Android Studio安装部署系列】十五、Android studio添加Assets目录

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 概述 Android Studio新建项目时是没有assets目录,需要自己手动创建. app右键——New——Folder——Asset ...

  5. 在Android Studio添加本地aar包引用

    1.如何在Android Studio添加本地aar包引用 https://jingyan.baidu.com/article/2a13832890d08f074a134ff0.html 2.完成上述 ...

  6. android studio 添加get,set方法快捷方式

    android studio 添加get,set方法快捷方式

  7. Android Studio 添加 Genymotion插件

    原文:Android Studio 添加 Genymotion插件 1.下载Genymotion:官网地址,必须先注册才能下载,下载带有VirtualBox的版本 2.安装:安装时会连VirtualB ...

  8. Android Studio(六):Android Studio添加注释模板

    Android Studio相关博客: Android Studio(一):介绍.安装.配置 Android Studio(二):快捷键设置.插件安装 Android Studio(三):设置Andr ...

  9. 2.5、Android Studio添加多适配的向量图片

    Android Studio包含一个Vector Asset Studio的工具,可以帮助你添加Material图标和导入SVG(Scalable Vector Graphic)文件到你的项目中作为向 ...

随机推荐

  1. js获取时间戳的三种方式

      js获取时间戳的三种方式 CreateTime--2018年5月23日08:44:10 Author:Marydon // 方式一:推荐使用 var timestamp=new Date().ge ...

  2. servlet request

    request.getRequestURI(); request.getRequestURL(); getQueryString();//返回查询信息 getRemoteAddr();//得到来访者地 ...

  3. 【MySQL锁】MySQL悲观锁和乐观锁概念

    悲观锁与乐观锁是两种常见的资源并发锁设计思路,也是并发编程中一个非常基础的概念.本文将对这两种常见的锁机制在数据库数据上的实现进行比较系统的介绍. 悲观锁(Pessimistic Lock) 悲观锁的 ...

  4. 打通前后端全栈开发node+vue进阶【课程学习系统项目实战详细讲解】(3):用户添加/修改/删除 vue表格组件 vue分页组件

    第三章 建议学习时间8小时      总项目预计10章 学习方式:详细阅读,并手动实现相关代码(如果没有node和vue基础,请学习前面的vue和node基础博客[共10章] 演示地址:后台:demo ...

  5. Linux命令-目录处理命令:mv

    注意:在linux下面,剪切文件和改名是同一个命令mv,而不是两个独立的命令. mv /tmp/beijing/chaoyangqu /root 移动chaoyangqu目录到root目录下面 mv ...

  6. 调整弹出对话框在ASP.NET应用程序的大小

    调整弹出对话框在ASP.NET应用程序的大小 #region 调整弹出对话框在ASP.NET应用程序的大小    protected void PopupWindowControl_Customize ...

  7. EntityFramework Data Annotations

    详细的实体映射介绍(Data Annotation) http://msdn.microsoft.com/en-us/data/jj591583

  8. 使用maven开发OSGI样例

    一:创建maven项目,在pom.xml里面增加例如以下依赖 <dependency> <groupId>org.osgi</groupId> <artifa ...

  9. Web服务(Web Service)相关概念

    1.概述 Web服务技术(Web Service )是一种面向服务的架构技术,通过标准的Web协议提供服务,保证不同平台的应用服务能够互相操作. 因为Web服务公布的数据基于XML格式和 SOAP协议 ...

  10. Python 爬虫 去掉网页注释,去掉网页注释

    在爬虫中,我们遇到了网页注释的问题,这些内容,第一,耗费内存资源,第二,在解析网页的时候,不易匹配出来信息.那么我们该如何去掉他们呢??? 我们可以去使用正则去过滤掉他们 方法如下 result = ...