简体   繁体   English

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

[英]Issue while adding location service in build.gradle in android

I want to add this google play location services in android我想在 android 中添加这个 google play 位置服务

implementation 'com.google.android.gms:play-services-location:17.0.0'

and my support:appcompat library is我的支持:appcompat 库是

implementation 'com.android.support:appcompat-v7:27.1.1'

targetSdkVersion is 27

compileSdkVersion is 27

when try to build getting error尝试构建时出现错误

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. Android 资源链接失败 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. D:\\AndroidStudioProject\\GpsLocationApp\\app\\build\\intermediates\\incremental\\mergeDebugResources\\merged.dir\\values\\values.xml:2015: 错误:资源 android:attr/ttcIndex 未找到。 error: failed linking references.错误:链接引用失败。

Google Play services and Firebase migrated to AndroidX in the latest release. Google Play 服务和 Firebase 在最新版本中迁移到 AndroidX。 It means that you are using both, support libraries and androidx libraries.这意味着您同时使用支持库和 androidx 库。

You can:你可以:

  • migrate to androidx as described below如下所述迁移到 androidx
  • downgrade your google play services dependencies (but it is not a real solution because you have to migrate before or after)降级您的 google play 服务依赖项(但这不是真正的解决方案,因为您必须在之前或之后迁移)

You can check the 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: Google Play 服务和 Firebase 的最新更新包括以下更改:

Migration from Android Support Libraries to Jetpack (AndroidX) Libraries.从 Android 支持库迁移到 Jetpack (AndroidX) 库。 Libraries will not work unless you make the following changes in your app:除非您在应用程序中进行以下更改,否则库将无法工作:

  • Upgrade com.android.tools.build:gradle to v3.2.1 or later.com.android.tools.build:gradle升级到 v3.2.1 或更高版本。
  • Upgrade compileSdkVersion to 28 or later.compileSdkVersion升级到 28 或更高版本。
  • Update your app to use Jetpack (AndroidX) ;更新您的应用以使用 Jetpack (AndroidX) follow the instructions in Migrating to AndroidX .按照迁移到 AndroidX 中的说明进行操作

Also about the specific error described in the answer:另外关于答案中描述的特定错误:

The error is:错误是:

AAPT: error: resource android:attr/fontVariationSettings not found. AAPT:错误:找不到资源 android:attr/fontVariationSettings。
AAPT: error: resource android:attr/ttcIndex not found AAPT:错误:找不到资源 android:attr/ttcIndex

Change the compileSdkVersion to:compileSdkVersion更改为:

compileSdkVersion 28

fontVariationSettings andttcIndex were added in api level 28 . fontVariationSettingsttcIndex是在 api level 28中添加的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM