adding Admob to Libgdx game(将 Admob 添加到 Libgdx 游戏)
问题描述
我正在闲置本教程,但是当我尝试进入获利页面时却无法获利或添加任何横幅,因为与教程不同,我的游戏不在商店中.
I was fallowing this tutorial but when I tried to go to monetize page I wasn't able to monetize or add any banner because my game isn't in the store unlike the tutorial.
我的问题是:我是否需要在不添加 admob 代码的情况下上传我的游戏,然后将其添加到我的游戏中,或者我应该在上传之前添加代码,然后从 admob 网站设置内容?
My question is: do I need to upload my game without adding the code of admob then add it latter to my game or shall I add the code before uploading it then set the things from admob website?
这可能是一个愚蠢的问题,但我只是一个关于 admob 的新手
It might be a silly question but I'm just a newbie when it comes to admob
推荐答案
Libgdx 官方文档中有一个漏洞部分解释了如何使用 Admob:
There is a hole section in Libgdx official docs that explain how to use Admob :
- libgdx 中的 Admob
考虑一下:
Android(6.4.1 和更早的 SDK)已弃用.2014 年 8 月 1 日,谷歌Play 将停止接受使用旧应用的新应用或更新应用独立的 Google Mobile Ads SDK v6.4.1 或更低版本.您必须升级到届时移动广告 SDK 的 Google Play 版本.
Android (6.4.1 and earlier SDKs) Deprecated. On August 1, 2014, Google Play will stop accepting new or updated apps that use the old standalone Google Mobile Ads SDK v6.4.1 or lower. You must upgrade to the Google Play version of the Mobile Ads SDK by then.
根据 Libgdx 维基:
According to Libgdx wiki :
准系统示例应用
我使用 gdx-setup-ui.jar 创建了一个新的 libgdx 项目,添加了一个.gitignore 文件,并进行了我的初始提交.
I created a new libgdx project using gdx-setup-ui.jar, added a .gitignore file, and made my initial commit.
Eclipse 设置
在 Eclipse 中,导入准系统示例应用程序(文件 > 导入 > 现有项目到工作区) - 你现在应该至少有三个项目在包资源管理器(核心、android 和桌面)中.
In eclipse, import the barebones sample app (file > import > existing projects into workspace) - you should now have at least three projects in package explorer (core, android, and desktop).
打开 Android SDK Manager,下载最新的 SDK Platform 和Google API(撰写本文时:4.4.2/API19),2.3.1/API9 SDK平台,以及来自 Extras - Google Play Services.
Open the Android SDK Manager, download the latest SDK Platform and Google APIs (at time of writing: 4.4.2/API19), the 2.3.1/API9 SDK Platform, and from Extras - Google Play Services.
找到/extras/google/google_play_services/libproject/google-play-services_lib/您机器上的目录(在我的 Windows 机器上 - C:Program Files(x86)Androidandroid-sdkextrasgooglegoogle_play_serviceslibprojectgoogle-play-services_lib)并复制到现有 libgdx 旁边的工作目录中项目.
Locate the /extras/google/google_play_services/libproject/google-play-services_lib/ directory on your machine (on my windows machine - C:Program Files (x86)Androidandroid-sdkextrasgooglegoogle_play_serviceslibprojectgoogle-play-services_lib) and copy into your working directory alongside the existing libgdx projects.
File > Import > Android > Existing Android Code, Next, Browse,在您的工作中导航到 google-play-services_lib 的本地副本目录,好的,完成.
File > Import > Android > Existing Android Code, Next, Browse, navigate to the local copy of google-play-services_lib in your working directory, Ok, Finish.
右击你的android项目,选择Properties,Android,滚动向下点击添加,选择google-play-services_lib项目,OK.
Right-click your android project, select Properties, Android, scroll down and click Add, select the google-play-services_lib project, Ok.
此时,在 Eclipse 中刷新和清理可能不会有什么坏处,所以继续做吧.
A refresh and clean in eclipse probably wouldn't hurt at this point, so go ahead and do that.
AndroidManifest.xml
AndroidManifest.xml
确保 android 项目的 project.properties 文件中的目标是至少 13,以及 AndroidManifest.xml 中的 android:minSdkVersion至少是 9.可悲的是,这确实意味着用户运行旧版本的Android 将被排除在外,但我们对此无能为力.有非常非常非常少的设备仍在运行以下版本2.3/API9,所以至少你不会排除很多用户......
Ensure that the target in android project's project.properties file is at least 13, and the android:minSdkVersion in your AndroidManifest.xml is at least 9. Sadly this does mean users running ancient versions of Android will be excluded, but there's nothing we can do about this. There are very very VERY few devices still running versions below 2.3/API9, so at least you won't be excluding many users...
将这两行添加为 'application' 元素的子元素:
Add these two lines as children of the 'application' element:
将这两个权限添加为 'manifest' 元素的子元素:
Add these two permissions as children of the 'manifest' element:
保存更改,然后在 Eclipse 中刷新和清理以祝好运...
Save changes, then refresh and clean in eclipse for good luck...
横幅广告
查看这个版本的 android 项目的 MainActivity 类相当简单的横幅广告实施.
See this version of the android project's MainActivity class for a reasonably straightforward banner ad implementation.
插页式广告
此差异显示插页式广告实施(ActionResolver界面让我们从核心项目中触发插页式操作同时保留了宝贵的 LibGdx 跨平台功能).
This diff shows an interstitial ad implementation (ActionResolver interface lets us trigger interstitial actions from the core project while retaining the invaluable LibGdx cross-platform functionality).
仅此而已!
最后一点如果从克隆https://github.com/TheInvader360/tutorial-libgdx-google-ads, 支付注意eclipse中的问题视图!您将需要创建一个google-play-services_lib 和tutorial-libgdx-google-ads-android 项目,并确保您拥有安装所需的android sdks.就像 eclipse 经常出现的情况一样,一个大量的清爽和清洁不会造成任何伤害......
One final note if cloning from https://github.com/TheInvader360/tutorial-libgdx-google-ads, pay attention to the problems view in eclipse! You will need to create an empty 'gen' directory in both the google-play-services_lib and tutorial-libgdx-google-ads-android projects, and ensure you have the required android sdks installed. As is often the case with eclipse, a liberal amount of refreshing and cleaning will do no harm...
这篇关于将 Admob 添加到 Libgdx 游戏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 Admob 添加到 Libgdx 游戏
- 转换 ldap 日期 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- 获取数字的最后一位 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01