2013-06-25 112 views
1

我在写游戏并添加了admob(版本6.4.1)。当点击AD时,它会有两个问题,我不知道如何解决或调试。点击admob的广告后游戏将退出

我正在使用以下代码将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)当点击广告,谷歌的播放或资源管理器将运行。 Logcat将出现以下错误。 2)按“返回”键返回游戏时,若再次按“返回”键,游戏将跳转到后台。它喜欢使用finish()或按“Home”键。游戏不会崩溃,再次按下图标后可以回叫。

如果我没有点击AD,一切都运行正常。

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

请谁能帮帮我?它让我疯狂!

回答

1

我想你可能会让你的EGL Surface和context被多个线程使用。 Android要求所有针对给定上下文的OpenGL ES调用都必须来自单个线程。本文详细阐述了:

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

+0

但我的游戏不是3D游戏,它会使用OpenGL? – John

+0

自ICS版本开始,Android默认使用OpenGL ES 2.0。既然你说过它可以在AVD仿真器上工作,那么问题可能是你的设备上的OpenGL ES或EGL驱动有错误。什么是设备?尝试一个不同的。 – ClayMontgomery

+0

我曾尝试三星i9000和平板电脑极光2. – John