简体   繁体   English

Google Play游戏服务 - 无法解锁成就

[英]Google Play Game Service - Cannot unlock Achievements

I have implemented Google Play Game Service into my game by referring to the quick start given by Google. 我已经通过参考Google提供的快速入门在我的游戏中实施了Google Play游戏服务。

I have added the achievement ids in my 'id.xml' file. 我在'id.xml'文件中添加了成就ID。 My game has around 10 achievements. 我的游戏有大约10个成就。 The code to unlock my achievements is as follows: 解锁我的成就的代码如下:

Games.Achievements.unlock(getApiClient(), "achievement_1_0");

where 'achievement_1_0' is the string name of one of my achievements. 其中'achievement_1_0'是我成就之一的字符串名称。

My issue is that non of my achievements are getting unlocked, even when the conditions are correct. 我的问题是,即使条件正确,我的成就也没有解锁。 After viewing my log, I got this E/AchievementAgent(13528): Couldn't find local achievement to update for achievement ID achievement_1_0 from the session filter com.google.android.gms(Session Filter) 查看我的日志后,我收到了此E/AchievementAgent(13528): Couldn't find local achievement to update for achievement ID achievement_1_0从会话过滤器com.google.android.gms(Session Filter) E/AchievementAgent(13528): Couldn't find local achievement to update for achievement ID achievement_1_0

Any thoughts on what might have gone wrong? 有什么可能出错的想法? or is it a bug ..??? 还是一个bug .. ???

The code for unlocking an achievement is as follows: 解锁成就的代码如下:

Games.Achievements.unlock(getApiClient(), "your_achievement_id");

Here the achievement id is the id you get while creating achievement in Google Game Services. 这里的成就ID是您在Google Game Services中创建成就时获得的ID。

That is in Google developer Console->Game Services->Your Application->Achievement 这是在谷歌开发者控制台 - >游戏服务 - >你的应用程序 - >成就

在此输入图像描述

Hope this will help you.. 希望对你有帮助..

@Anu is 100% correct. @Anu是100%正确的。 You are indeed using an incorrect ID for your achievements. 您确实使用了不正确的ID来表示您的成就。 However, using the codes from the Game services console is a very bad way to refer to your achievements (and it is very error prone). 但是,使用游戏服务控制台中的代码是一种非常糟糕的方式来引用您的成就(并且它非常容易出错)。

The better way to refer to an achievement is to export your achievement IDs by using the Get resources link at the bottom of the Achievements screen in the Game services console. 引用成就的更好方法是使用游戏服务控制台中“ 成就”屏幕底部的“ Get resources链接导出成就ID。 These are then placed inside a xml file in your apps resources. 然后将它们放在应用程序资源的xml文件中。 It seems like this is what you are referring to in your question (the id.xml file), so you may have already completed this step. 看起来这就是您在问题中引用的内容( id.xml文件),因此您可能已经完成了此步骤。

Once the xml file is in place you can then refer to your achievements using the descriptive IDs that were exported from the console. 一旦xml​​文件到位,您就可以使用从控制台导出的描述性ID来引用您的成就。 Do that as follows: 这样做如下:

activity.getBaseContext().getString( R.string.achievement_1_0 );

Use your main Activity for activity and change the achievement_1_0 to the achievement's name attribute from the xml file. 使用主Activity作为activity ,并将achievement_1_0更改为xml文件中的achievement的name属性。 NOTE : achievement_1_0 must NOT be a string (ie not in quotes as in your current code), since it is referring to a string resource. 注意achievement_1_0不能是字符串(即不在当前代码中的引号中),因为它指的是字符串资源。

Always use this method to refer to your achievements - do not hardcode either the strings or the codes from the console as it will make your code much harder to maintain. 始终使用此方法来引用您的成就 - 不要对控制台中的字符串或代码进行硬编码,因为这会使您的代码难以维护。

Im get this error debugging an app not in release. 我在调试未发布的应用程序时遇到此错误。 I fix the problem adding my account/email as a new tester. 我修复了将我的帐户/电子邮件添加为新测试人员的问题。

Google play console > Game Services > Testing > Add tester

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM