我想在 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
fontVariationSettings
和 ttcIndex
添加到 API 级别 28 中。
关于android - 在 android 的 build.gradle 中添加位置服务时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56897331/