同时利用播放服务和AdMob SDK [英] Utilize both Play Services and AdMob SDK

查看:220
本文介绍了同时利用播放服务和AdMob SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于MH。指出这个问题,人们不再需要包括GoogleAdMobAdsSdk-xxxjar在他们的Andr​​oid项目是否包括谷歌播放服务(见在迁移指南)。不过,我想,和我有麻烦。

As MH. pointed out in this question, one no longer needs to include GoogleAdMobAdsSdk-x.x.x.jar in their Android project if they include Google Play Services (see the migration guide). However, I want to, and I'm having trouble.

问题:谷歌的播放,services_lib项目包括那就是德precated为 com.google.ads.AdRequest 的定义,并有一个私人的构造。它结束了在AdMob的罐子前面的类路径(在Android的私人图书馆项),所以当我尝试使用它在我的code中,它最终要使用去precated之一,导致错误:构造AdRequest()是不可见的。我看不出有什么办法重新排序Android的私人图书馆里的条目。

The problem: the google-play-services_lib project includes a definition for com.google.ads.AdRequest that is deprecated, and has a private constructor. It ends up in the classpath in front of the AdMob jar (within the "Android Private Libraries" entry), so when I try to use it in my code it end up trying to use the deprecated one, resulting in the error: The constructor AdRequest() is not visible. I see no way to re-order the entries inside "Android Private Libraries".

我为什么要同时使用,你问?我有一个单一的库项目有许多有用的类,其中包括用于处理都发挥服务和AdMob一些实用工具类。我的一些应用程序,使用该库项目使用AdMob的实用工具类,但不能播放服务。

Why do I want to use both, you ask? I have a single library project with many useful classes, including some utility classes for dealing both Play Services and AdMob. Some of my apps that use that library project use the AdMob utility classes, but not Play Services.

推荐答案

我一直在测试这一点,有些变化是必需的,以获得通过谷歌这个工作播放服务。

I've been testing this, and some changes are required in order to get this working through Google Play Services.

在第一个地方,你应该删除引用旧 com.google.ads全部进口。* ,因为他们现在位于 com.google .android.gms.ads。*

In first place you should remove all imports referencing to old com.google.ads.* , since they are now located on com.google.android.gms.ads.*.

正如你提到的,一些更多的变化需要做的:

As you mentioned, some more changes need to be done:

您不能实例化AdRequest以前做的方式,但使用 AdRequest.Builder 如下:

You cannot instantiate an AdRequest the way it used to be done, but using an AdRequest.Builder as follows:

AdRequest adRequest = new AdRequest.Builder().build();

此外,还要确保你更换包装上所有布局的名字,所以他们叫< com.google.android.gms.ads.AdView 而不是< com.google.ads.AdView

我觉得就是这样。祝你好运!

I think that's all. Good luck!

这篇关于同时利用播放服务和AdMob SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆