【问题标题】:Android Studio android-play-location google play serviceAndroid Studio android-play-location 谷歌播放服务
【发布时间】:2016-11-26 16:38:23
【问题描述】:

我在github上找到https://github.com/googlesamples/android-play-location 根据https://developer.android.com/training/location/receive-location-updates.html 的建议,我在Android Studio 上测试了LocationUpdates 导入项目的各种位置类型。我在 genymotion、智能手机、平板电脑、各种 android 版本上运行应用程序,但在单击“开始更新”按钮后应用程序总是崩溃。 我发现其他指南有播放服务位置,但启动时应用程序崩溃! Android Studio 是最后一个,我下载并更新了工具等... 有人可以帮助我了解问题所在吗? 当应用程序崩溃时没有显示错误

【问题讨论】:

  • 双重检查 官方google play location示例代码中提到的先决条件?
  • 是的,API 级别 19,Android 构建工具 23,Google 存储库版本 39 已安装。也许这行代码: mCurrentLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);生成应用崩溃
  • 请分享日志猫错误信息

标签: android android-studio google-play-services


【解决方案1】:

@Jayakrishnan PM 是正确的。确保您已正确设置 Play 服务。要使用 Google Play 服务 API 开发应用程序,您需要使用 Google Play 服务 SDK 设置您的项目。

要在使用Google Play services SDK 时测试您的应用,您必须使用以下任一方法:

  • 运行 Android 2.3 或更高版本并包含 Google Play 商店的兼容 Android 设备。
  • 带有 AVD 的 Android 模拟器运行基于 Android 4.2.2 或更高版本的 Google API 平台。

除了新的平台功能外,Android 6.0 Marshmallow 还具有一个新的权限模型,可简化应用安装和自动更新过程。现在在运行时而不是在安装应用程序之前请求权限。

确保您的 API 级别和目标 SDK 设置为 23 或更高。此外,请确保您使用 V4 支持库来验证和请求权限。如果您还没有,请将其添加到您的 gradle 依赖项中:

com.android.support:support-v4:23.0.0

您还需要在 AndroidManifest.xml 文件中声明权限。这里没有任何变化——无论你的应用程序一直需要什么权限,都应该在你的 AndroidManifest.xml 文件中使用 uses-permission 标签声明。例如:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多