android - 在 android 的 build.gradle 中添加位置服务时出现问题

标签 android firebase google-play-services build.gradle androidx

我想在 android 中添加此 google play 位置服务

实现“com.google.android.gms:play-services-location:17.0.0”

我的支持:appcompat 库是

实现“com.android.support:appcompat-v7:27.1.1”

targetSdkVersion 为 27

compileSdkVersion 为 27

当尝试构建时出现错误

Android resource linking failed D:\AndroidStudioProject\GpsLocationApp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2015: error: resource android:attr/fontVariationSettings not found.

D:\AndroidStudioProject\GpsLocationApp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2015: error: resource android:attr/ttcIndex not found. error: failed linking references.

最佳答案

Google Play 服务和 Firebase 在最新版本中迁移到 AndroidX。 这意味着您正在使用支持库和 androidx 库。

你可以:

  • 按照如下所述迁移到 androidx
  • 降级您的 Google Play 服务依赖项(但这不是真正的解决方案,因为您必须在之前或之后进行迁移)

您可以查看 official release notes :

Warning: This release is a MAJOR version update and breaking change. The latest update to Google Play services and Firebase includes the following changes:

从 Android 支持库迁移到 Jetpack (AndroidX) 库。除非您在应用程序中进行以下更改,否则库将无法工作:

  • com.android.tools.build:gradle 升级到 v3.2.1 或更高版本。
  • compileSdkVersion 升级到 28 或更高版本。
  • 更新您的应用以使用 Jetpack (AndroidX);按照 Migrating to AndroidX 中的说明进行操作.

另外关于答案中描述的具体错误:

错误是:

AAPT: error: resource android:attr/fontVariationSettings not found.
AAPT: error: resource android:attr/ttcIndex not found

compileSdkVersion 更改为:

compileSdkVersion 28

fontVariationSettingsttcIndex添加到 API 级别 28 中。

关于android - 在 android 的 build.gradle 中添加位置服务时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56897331/

相关文章:

android - Marshmallow 上的分析损坏了吗?

android - 服务中无法访问 AsyncTask

Javascript - 在长触摸期间做一些事情,在触摸结束时停止(Android)

android - 身份验证 token 与 ~/.emulator_console_auth_token 不匹配

ios - iOS的Firebase应用索引:在搜索结果中没有应用图标

android - Android:gradle中应包含哪个Google Play服务版本

android - Google Play 服务(融合位置提供商)会显着增加应用程序大小吗?

Android 打印,为什么当我尝试从我的手机打印时收到警告

android - 没有 google-services.json 但仍从我的 Firebase 项目中获取远程配置

typescript - 传递 typescript 类方法作为回调