我正在尝试将 Google Play 服务实施到我的应用程序中。
我知道有一个名为 BaseGameUtils 的示例项目,我需要将其导入到我的工作区并将其标记为库,将 google-play-services_lib 导入到我的工作区后,我将其引用为 BaseGameUtils 库中的库。最后,我在我真正想要发布到 Google Play 的项目中引用了 BaseGameUtils 和 google-play-services_lib 。
在所有这些连接中的某个位置,我的类路径中有一个同名的 jar 文件。
为了解决这个问题,我需要删除 google-play-services_lib 的引用之一,因为当我尝试导出项目时,我收到此错误:
无法执行 dex:多个 dex 文件定义 Lcom/google/ads/AdRequest$ErrorCode;
好的,如果我取消选择“Android Private Libraries”,该项目将导出,但没有任何 Google Play 服务可用。当我尝试启动该课程时,在应用程序启动时出现错误:
super.onCreate(savedInstanceState);
我明白我必须打电话
setRequestedClients(BaseGameActivity.CLIENT_GAMES
| BaseGameActivity.CLIENT_APPSTATE);
before
// call BaseGameActivity's onCreate()
super.onCreate(savedInstanceState);
但它不起作用。这意味着 GoogleApiClient 将不会启动,因为类未导出。
@Override
public void onCreate(Bundle savedInstanceState) {
// set requested clients (games and cloud save)
setRequestedClients(BaseGameActivity.CLIENT_GAMES
| BaseGameActivity.CLIENT_APPSTATE);
// call BaseGameActivity's onCreate()
super.onCreate(savedInstanceState);
// game-specific logic:
setContentView(R.layout.pillow);
findViewById(R.id.sign_in_button).setOnClickListener(this);
findViewById(R.id.sign_out_button).setOnClickListener(this);
}
因此,如果我取消选择“Android Private Libraries”,当我添加通常需要在外部使用的 .jar 并将它们添加到构建路径时,该项目将很好地导出。但是 Google Play Services。
我可以从构建路径中删除外部 jar 并将“Android Private Libraries”添加到构建路径,但随后我有多个 google-play-services_lib。
我很困惑它要么出现两次,要么根本不出现。
有人知道发生了什么事吗?