1

我正在编写游戏并添加 admob(版本 6.4.1)。当点击AD时,会出现两个问题,我不知道如何解决或调试。

我正在使用以下代码将 admob 添加到surfaceview。基本上,它参考了这里的其他帖子。

adView = new AdView(this, AdSize.SMART_BANNER, "My_ID");
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
       RelativeLayout.LayoutParams.WRAP_CONTENT, 
       RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
adView.setLayoutParams(lp);
RelativeLayout layout = new RelativeLayout(this);
layout.addView(new MySurfaceViewX(this));
layout.addView(adView);
adView.loadAd(new AdRequest());
setContentView(layout);

以下是logcat信息:

06-25 15:08:24.214: I/System.out(25294): Pause all Music
06-25 15:08:24.218: I/System.out(25294): onPause
06-25 15:08:25.007: I/Ads(25294): onPresentScreen()
06-25 15:08:25.007: I/System.out(25294): onPresentScreen
06-25 15:08:25.148: I/Ads(25294): onLeaveApplication()
06-25 15:08:25.148: I/System.out(25294): onLeaveApplication
06-25 15:08:25.273: I/System.out(25294): SurfaceDestoryed
06-25 15:08:25.402: I/System.out(25294): onStop (Game exit temperory and AD is running)
06-25 15:08:28.261: D/webviewglue(25294): OnTrimMemory with EGL Context 0x0
06-25 15:08:28.308: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:28.308: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:28.308: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:28.308: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:28.308: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:32.652: D/webviewglue(25294): OnTrimMemory with EGL Context 0x0
06-25 15:08:32.656: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:32.656: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:32.656: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:32.656: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:32.656: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:35.789: I/Ads(25294): onDismissScreen()
06-25 15:08:35.800: I/System.out(25294): onDismissScreen
06-25 15:08:35.960: I/System.out(25294): onRestart
06-25 15:08:35.960: I/System.out(25294): onResume
06-25 15:08:36.035: I/System.out(25294): SurfaceCreated
06-25 15:08:36.050: I/System.out(25294): surfaceChanged 
06-25 15:08:39.722: I/System.out(25294): Pause all Music (when press "Back" key, it will go to  background at here)
06-25 15:08:39.722: I/System.out(25294): onPause
06-25 15:08:40.164: I/System.out(25294): SurfaceDestoryed
06-25 15:08:41.285: W/IInputConnectionWrapper(25294): showStatusIcon on inactive InputConnection
06-25 15:08:42.621: D/webviewglue(25294): OnTrimMemory with EGL Context 0x0
06-25 15:08:42.621: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:42.621: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:42.625: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:42.625: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:42.625: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)
06-25 15:08:42.636: I/System.out(25294): onStop
06-25 15:08:42.699: E/webview(25294): Error: WebView.destroy() called while still attached!
06-25 15:08:42.699: D/webviewglue(25294): nativeDestroy view: 0x52039c80
06-25 15:08:42.703: I/System.out(25294): onDestory

问题 :

1)当点击广告时,google play 或 explorer 将运行。Logcat 会出现以下错误。

06-25 15:08:41.285: W/IInputConnectionWrapper(25294): showStatusIcon on inactive InputConnection
06-25 15:08:42.621: D/webviewglue(25294): OnTrimMemory with EGL Context 0x0
06-25 15:08:42.621: E/libEGL(25294): call to OpenGL ES API with no current context (logged once per thread)

2)当按“Back”键返回游戏时,再按“Back”键,游戏将进入后台。它喜欢使用finish() 或按“Home”键。游戏不会崩溃,再次按下图标后可以回调。

如果我没有点击广告,一切运行正常。

我还发现如果它在模拟器上运行,它不会有上述错误。

请问,谁能帮帮我?它让我发疯!

4

1 回答 1

1

我认为您可能允许多个线程使用您的 EGL Surface 和上下文。Android 要求对给定上下文的所有 OpenGL ES 调用必须仅来自单个线程。这篇文章详细解释:

http://software.intel.com/en-us/articles/porting-opengl-games-to-android-on-intel-atom-processors-part-1/

于 2013-06-25T18:18:19.087 回答