【问题标题】:Not able to use Google Play Services library in Android Studio无法在 Android Studio 中使用 Google Play 服务库
【发布时间】:2015-11-27 23:17:51
【问题描述】:

迁移到 Android Studio,我无法再添加和使用 Google Play 服务库。

我创建了一个简单的项目,我将库添加为模块,我的布局中的登录按钮但是当我运行应用程序时由于 ClassNotFoundException 而崩溃...

有人遇到同样的问题吗?

【问题讨论】:

标签: android-studio google-play-services


【解决方案1】:

两年后,我提出了这个问题,很多关于Android Studio 以及使用Google Play Services library 必须做的事情都发生了变化。 我想我可以回答自己报告官方文档的重要步骤,可以在这里找到:https://developers.google.com/android/guides/setup

我还假设您已经安装了Android Studio 的更新版本和最新的SDK Tools

所以这是程序:

1 - 从 SDK 管理器添加所需的 SDK 包:

  • Google 存储库
  • Google Play 服务

官方文档可以在这里找到:https://developer.android.com/sdk/installing/adding-packages.html

2 - 打开 应用程序模块 目录中的 build.gradle 文件,并在 dependencies 下添加新的构建规则以获取最新版本的播放服务。 例如:

apply plugin: 'com.android.application'
...

dependencies {
    compile 'com.google.android.gms:play-services:7.5.0'
}

确保每次更新 Google Play 服务时更新此版本号。

3 - 保存更改并点击工具栏中的Sync Project with Gradle Files

从 6.5 版开始,您可以有选择地将 Google Play 服务 API 编译到您的应用中。 在官方文档中,您可以找到individual APIs 和对应的build.gradle 描述的完整列表。

包摘要:https://developers.google.com/android/reference/com/google/android/gms/package-summary

当您创建一个新项目时,Android Studio 还提供了一个 Google Play Services Activity 模板。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-31
    相关资源
    最近更新 更多