2014-04-17 73 views
4

这是我的第一篇文章,但我没能解决我自己或者与谷歌搜索这一个。任何有识之士都会认真考虑,非常感激。谷歌Play游戏服务LibGDX项目设置与最新BaseGameUtils

我正在使用LibGDX框架,我的目标是通过AdMob通过Google Play游戏服务和广告获得工作成果&排行榜。

我能够设置使用Theinvader360的谷歌Play游戏服务功能教程成就/排行榜。

AdMob的呼吁清单项早期步骤制得的不是提供@integer错误。最新版本的“google-play-services_lib”解决了这个问题,但显示BaseGameUtils中的三个类已折旧。然后我从主要来源获取最新版本的BaseGameUtils库。 (我会包括更多的联系,但我没有足够的很高的声誉)

有什么好笑的当前版本是结构比过去有所不同。在导入到Eclipse之前,我即刻将“主”文件夹的标题改为“BaseGameUtils”。然后我将他们的“java”文件夹中的三个类移动到“src”中。这引发了FragmentActivity错误,所以我创建了一个“libs”文件夹,并放在android-support-v4.jar中以缓解这个问题。

当前:
-BaseGameUtils已选中“Is Library”并将“google-play-services_lib”添加为参考。
-google-play-services_lib检查了“Is Library”。
-The android游戏项目是引用这两个库。

我转身MainActivity使用这种源的东西转化为跟上时代的道:
https://developers.google.com/games/services/android/init
和向下滚动到“使用GameHelper没有BaseGameActivity”

由于是,应用程序将跳过它的启动画面并在碰撞之前看到启动屏幕的一瞥。这里的日志:

04-17 02:43:28.994: D/dalvikvm(21249): Trying to load lib /data/app-lib/com.crtgames.cavebat-2/libgdx.so 0x424b0c00 
04-17 02:43:29.004: D/dalvikvm(21249): Added shared lib /data/app-lib/com.crtgames.cavebat-2/libgdx.so 0x424b0c00 
04-17 02:43:29.004: D/dalvikvm(21249): No JNI_OnLoad found in /data/app-lib/com.crtgames.cavebat-2/libgdx.so 0x424b0c00, skipping init 
04-17 02:43:29.014: D/libEGL(21249): loaded /system/lib/egl/libEGL_adreno200.so 
04-17 02:43:29.014: D/libEGL(21249): loaded /system/lib/egl/libGLESv1_CM_adreno200.so 
04-17 02:43:29.014: D/libEGL(21249): loaded /system/lib/egl/libGLESv2_adreno200.so 
04-17 02:43:29.024: I/Adreno200-EGL(21249): <qeglDrvAPI_eglInitialize:265>: EGL 1.4 QUALCOMM build: (CL3544079) 
04-17 02:43:29.024: I/Adreno200-EGL(21249): Build Date: 03/28/13 Thu 
04-17 02:43:29.024: I/Adreno200-EGL(21249): Local Branch: adreno_20130328 
04-17 02:43:29.024: I/Adreno200-EGL(21249): Remote Branch: 
04-17 02:43:29.024: I/Adreno200-EGL(21249): Local Patches: 
04-17 02:43:29.024: I/Adreno200-EGL(21249): Reconstruct Branch: 
04-17 02:43:29.094: D/dalvikvm(21249): GC_FOR_ALLOC freed 210K, 7% free 16805K/18028K, paused 19ms, total 19ms 
04-17 02:43:29.104: I/dalvikvm-heap(21249): Grow heap (frag case) to 19.648MB for 2359312-byte allocation 
04-17 02:43:29.134: D/dalvikvm(21249): GC_FOR_ALLOC freed <1K, 7% free 19108K/20336K, paused 24ms, total 24ms 
04-17 02:43:29.144: D/dalvikvm(21249): GC_CONCURRENT freed <1K, 7% free 19111K/20336K, paused 2ms+1ms, total 14ms 
04-17 02:43:29.144: D/GameHelper(21249): GameHelper: Debug log enabled. 
04-17 02:43:29.144: D/GameHelper(21249): GameHelper: Setup: requested clients: 7 
04-17 02:43:29.154: W/PopupManager(21249): You have not specified a View to use as content view for popups. Falling back to the Activity content view which may not work properly in future versions of the API. Use setViewForPopups() to set your content view. 
04-17 02:43:29.154: D/GameHelper(21249): GameHelper: onStart 
04-17 02:43:29.154: D/GameHelper(21249): GameHelper: Connecting client. 
04-17 02:43:29.154: W/ResourceType(21249): Failure getting entry for 0x7f06000d (t=5 e=13) in package 0 (error -75) 
04-17 02:43:29.154: E/GooglePlayServicesUtil(21249): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. 
04-17 02:43:29.174: W/ResourceType(21249): Failure getting entry for 0x7f06000d (t=5 e=13) in package 0 (error -75) 
04-17 02:43:29.174: E/GooglePlayServicesUtil(21249): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. 
04-17 02:43:29.184: W/ResourceType(21249): Failure getting entry for 0x7f06000d (t=5 e=13) in package 0 (error -75) 
04-17 02:43:29.184: E/GooglePlayServicesUtil(21249): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. 
04-17 02:43:29.194: I/AndroidInput(21249): sensor listener setup 
04-17 02:43:29.234: I/Adreno200-EGL(21249): <qeglDrvAPI_eglInitialize:265>: EGL 1.4 QUALCOMM build: (CL3544079) 
04-17 02:43:29.234: I/Adreno200-EGL(21249): Build Date: 03/28/13 Thu 
04-17 02:43:29.234: I/Adreno200-EGL(21249): Local Branch: adreno_20130328 
04-17 02:43:29.234: I/Adreno200-EGL(21249): Remote Branch: 
04-17 02:43:29.234: I/Adreno200-EGL(21249): Local Patches: 
04-17 02:43:29.234: I/Adreno200-EGL(21249): Reconstruct Branch: 
04-17 02:43:29.264: D/OpenGLRenderer(21249): Enabling debug mode 0 
04-17 02:43:29.274: W/GL2JNIView(21249): creating OpenGL ES 2.0 context 
04-17 02:43:29.284: D/AndroidRuntime(21249): Shutting down VM 
04-17 02:43:29.284: W/dalvikvm(21249): threadid=1: thread exiting with uncaught exception (group=0x41355ac8) 
04-17 02:43:29.284: E/AndroidRuntime(21249): FATAL EXCEPTION: main 
04-17 02:43:29.284: E/AndroidRuntime(21249): java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information. 
04-17 02:43:29.284: E/AndroidRuntime(21249): at com.google.android.gms.internal.eh$h.b(Unknown Source) 
04-17 02:43:29.284: E/AndroidRuntime(21249): at com.google.android.gms.internal.eh$h.a(Unknown Source) 
04-17 02:43:29.284: E/AndroidRuntime(21249): at com.google.android.gms.internal.eh$b.ec(Unknown Source) 
04-17 02:43:29.284: E/AndroidRuntime(21249): at com.google.android.gms.internal.eh$a.handleMessage(Unknown Source) 
04-17 02:43:29.284: E/AndroidRuntime(21249): at android.os.Handler.dispatchMessage(Handler.java:99) 
04-17 02:43:29.284: E/AndroidRuntime(21249): at android.os.Looper.loop(Looper.java:137) 
04-17 02:43:29.284: E/AndroidRuntime(21249): at android.app.ActivityThread.main(ActivityThread.java:5293) 
04-17 02:43:29.284: E/AndroidRuntime(21249): at java.lang.reflect.Method.invokeNative(Native Method) 
04-17 02:43:29.284: E/AndroidRuntime(21249): at java.lang.reflect.Method.invoke(Method.java:511) 
04-17 02:43:29.284: E/AndroidRuntime(21249): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) 
04-17 02:43:29.284: E/AndroidRuntime(21249): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) 
04-17 02:43:29.284: E/AndroidRuntime(21249): at dalvik.system.NativeStart.main(Native Method) 
04-17 02:43:29.304: D/dalvikvm(21249): Trying to load lib /data/app-lib/com.crtgames.cavebat-2/libgdx.so 0x424b0c00 
04-17 02:43:29.304: D/dalvikvm(21249): Shared lib '/data/app-lib/com.crtgames.cavebat-2/libgdx.so' already loaded in same CL 0x424b0c00 
04-17 02:43:29.304: I/GL2(21249): all initialized 2 
04-17 02:43:29.304: I/AndroidGraphics(21249): OGL renderer: Adreno (TM) 320 
04-17 02:43:29.304: I/AndroidGraphics(21249): OGL vendor: Qualcomm 
04-17 02:43:29.304: I/AndroidGraphics(21249): OGL version: OpenGL ES 2.0 [email protected] [email protected] ([email protected]) 
04-17 02:43:29.304: I/AndroidGraphics(21249): OGL extensions:      GL_AMD_compressed_ATC_texture GL_AMD_performance_monitor GL_AMD_program_binary_Z400 GL_EXT_debug_labelGL_EXT_debug_markerGL_EXT_robustness GL_EXT_texture_format_BGRA8888 GL_EXT_texture_type_2_10_10_10_REV GL_NV_fence GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_texture GL_OES_depth24 GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_fragment_precision_high GL_OES_get_program_binary GL_OES_packed_depth_stencil GL_OES_depth_texture_cube_map GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_3D GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_texture_npot GL_OES_vertex_half_float GL_OES_vertex_type_10_10_10_2 GL_OES_vertex_array_object GL_QCOM_alpha_test GL_QCOM_binning_control GL_QCOM_driver_control GL_QCOM_perfmon_global_mode GL_QCOM_extended_get GL_QCOM_extended_get2 GL_QCOM_tiled_rendering GL_QCOM_writeonly_rendering GL_EXT_sRGB GL_EXT_texture_filter_anisotropic GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float 
04-17 02:43:29.304: W/Adreno200-EGL(21249): <qeglDrvAPI_eglGetConfigAttrib:487>: EGL_BAD_ATTRIBUTE 
04-17 02:43:29.304: W/Adreno200-EGL(21249): <qeglDrvAPI_eglGetConfigAttrib:487>: EGL_BAD_ATTRIBUTE 
04-17 02:43:29.304: I/AndroidGraphics(21249): framebuffer: (5, 6, 5, 0) 
04-17 02:43:29.304: I/AndroidGraphics(21249): depthbuffer: (16) 
04-17 02:43:29.304: I/AndroidGraphics(21249): stencilbuffer: (0) 
04-17 02:43:29.304: I/AndroidGraphics(21249): samples: (0) 
04-17 02:43:29.304: I/AndroidGraphics(21249): coverage sampling: (false) 
04-17 02:43:29.314: I/AndroidGraphics(21249): Managed meshes/app: { } 
04-17 02:43:29.314: I/AndroidGraphics(21249): Managed textures/app: { } 
04-17 02:43:29.314: I/AndroidGraphics(21249): Managed shaders/app: { } 
04-17 02:43:29.314: I/AndroidGraphics(21249): Managed buffers/app: { } 
04-17 02:43:31.026: V/MediaPlayer(21249): decode(53, 100761, 16502) 
04-17 02:43:31.066: V/MediaPlayer(21249): decode(54, 117313, 10400) 
04-17 02:43:31.096: V/MediaPlayer(21249): decode(55, 66517, 34194) 

我的MainActivity代码:

public class MainActivity extends AndroidApplication implements GameHelperListener, ActionResolver { 

private static final int REQUEST_LEADERBOARD = 0; 
private GameHelper gameHelper; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    gameHelper = new GameHelper(this, GameHelper.CLIENT_ALL); 

    AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration(); 
    cfg.useAccelerometer = false; 
    cfg.useCompass = false; 
    initialize(new CaveBat(this), cfg); 

    gameHelper.enableDebugLog(true); 

    GameHelperListener listener = new GameHelper.GameHelperListener() { 
     @Override 
     public void onSignInSucceeded() { 
      // handle sign-in succeess 
     } 
     @Override 
     public void onSignInFailed() { 
      // handle sign-in failure (e.g. show Sign In button) 
     } 
    }; 
    gameHelper.setup(listener); 
} 

@Override 
public void onStart(){ 
    super.onStart(); 
    gameHelper.onStart(this); 
} 

@Override 
public void onStop(){ 
    super.onStop(); 
    gameHelper.onStop(); 
} 

@Override 
public void onActivityResult(int request, int response, Intent data) { 
    super.onActivityResult(request, response, data); 
    gameHelper.onActivityResult(request, response, data); 
} 

@Override 
public boolean getSignedInGPGS() { 
    return gameHelper.isSignedIn(); 
} 

@Override 
public void loginGPGS() { 
    try { 
     runOnUiThread(new Runnable(){ 
      public void run() { 
       gameHelper.beginUserInitiatedSignIn(); 
      } 
     }); 
    } catch (final Exception ex) { 
    } 
} 

@Override 
public void submitScoreGPGS_Classic(int score) { 
} 

@Override 
public void unlockAchievementGPGS(String achievementId) { 
} 

@Override 
public void getLeaderboardGPGS_Classic() { 
    startActivityForResult(Games.Leaderboards.getLeaderboardIntent(
    gameHelper.getApiClient(), "CgkIio298M4HEAIQAA"), REQUEST_LEADERBOARD); 
} 

@Override 
public void getAchievementsGPGS() { 
} 

@Override 
public void onSignInFailed() { 
} 

@Override 
public void onSignInSucceeded() { 
} 

}

可能是构建路径或生命周期的问题?另外,当注释onStart(),onStop(),onActivityResult()时,我的项目运行得非常好,直到我点击排行榜按钮,再次崩溃。任何帮助!

+1

你有没有得到这个解决? –

+0

如何更改清单让它正确导入?当您尝试将依赖项导入到项目中时,我总是惊讶于什么都不工作。 – Barodapride

回答

2

这似乎是相关型号到Google Play服务。您应该在清单中的标签中添加元数据。

<meta-data android:name="com.google.android.gms.games.APP_ID" 
    android:value="@string/app_id" /> 
+1

谢谢。我的清单包含这个元标记,以及:

+1

给予回答这个是因为我的问题是明显相关的。我的一句话是关闭的,我意识到这一点,同时仔细检查Android Dev网站 –

+0

@Sinan Kozak我有这个错误“找不到与给定名称匹配的资源(值为'@ string/app_id')'。你有什么建议吗? –

相关问题