将Admob添加到Libgdx游戏 [英] adding Admob to Libgdx game

查看:69
本文介绍了将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 :

考虑:

不推荐使用Android(6.4.1和更早版本的SDK). 2014年8月1日,Google Play将停止接受使用旧版本的新应用或更新的应用 独立的Google Mobile Ads SDK v6.4.1或更低版本.您必须升级到 届时,Google Play版本的移动广告SDK.

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 Wiki:

According to Libgdx wiki :

Barebones Sample App

Barebones Sample App

我使用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平台,然后 Google API(在撰写本文时:4.4.2/API19),2.3.1/API9 SDK 平台以及Extras-Google Play服务.

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)\ Android \ android-sdk \ extras \ google \ google_play_services \ libproject \ google-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)\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib) and copy into your working directory alongside the existing libgdx projects.

文件>导入> Android>现有的Android代码,下一步,浏览, 在工作中导航到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项目,选择属性",然后选择"Android",滚动 并单击添加,选择google-play-services_lib项目,确定.

Right-click your android project, select Properties, Android, scroll down and click Add, select the google-play-services_lib project, Ok.

在这一点上,日食的刷新和清洁可能不会受到伤害, 所以继续吧.

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:

将这两个权限添加为清单"元素的子级:

Add these two permissions as children of the 'manifest' element:

保存更改,然后刷新并进行日食清洁以求好运...

Save changes, then refresh and clean in eclipse for good luck...

横幅广告

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 , 支付 注意日食中的问题!您将需要创建一个 google-play-services_lib和 tutorial-libgdx-google-ads-android项目,并确保您拥有 必需的android SDK已安装.与日食一样, 大量的刷新和清洁不会有任何危害...

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游戏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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