android - 将 Google Play 服务位置添加为依赖项后找不到资源标识符

标签 android gradle google-play-services

这是我的 build.gradle 文件现在的样子。如果我可以提供任何其他信息,请告诉我。在我添加依赖项中的最后一行之后出现问题。我尝试添加 google-play-services:8.4.0 也失败了。

我也尝试过旧版本,例如 8.1.0。欢迎提出任何建议。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 16
    buildToolsVersion "19.1.0"

    defaultConfig {
        applicationId "com.example.devpactapp"
        minSdkVersion 15
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    repositories {
        flatDir {
            dirs 'aars'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.google.code.gson:gson:2.3'
    compile 'com.google.guava:guava:18.0'
    compile 'com.microsoft.azure:azure-mobile-services-android-sdk:2.0.3'
    compile 'com.microsoft.azure:azure-notifications-handler:1.0.1@jar'
    compile 'com.microsoft.azure.android:azure-storage-android:0.6.0@aar'
    compile 'com.google.android.gms:play-services-location:8.4.0'
}

错误日志如下:

/Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/8.4.0/res/layout-v21/place_autocomplete_fragment.xml
Error:(18, 29) No resource found that matches the given name (at 'background' with value '?android:attr/selectableItemBackgroundBorderless').
Error:(49, 29) No resource found that matches the given name (at 'background' with value '?android:attr/selectableItemBackgroundBorderless').
/Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/8.4.0/res/layout/place_autocomplete_item_powered_by_google.xml
Error:(8) No resource identifier found for attribute 'layout_marginStart' in package 'android'
Error:(28) No resource identifier found for attribute 'layout_toEndOf' in package 'android'
Error:(28) No resource identifier found for attribute 'layout_marginStart' in package 'android'
/Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/8.4.0/res/layout/place_autocomplete_item_prediction.xml
Error:(8) No resource identifier found for attribute 'layout_alignParentStart' in package 'android'
Error:(35) No resource identifier found for attribute 'layout_toEndOf' in package 'android'
Error:(52) No resource identifier found for attribute 'layout_toEndOf' in package 'android'
/Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/8.4.0/res/layout/place_autocomplete_progress.xml
Error:(2) No resource identifier found for attribute 'indeterminateTint' in package 'android'
Error:(2) No resource identifier found for attribute 'indeterminateTintMode' in package 'android'
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /Users/Debosmit/Library/Android/sdk/build-tools/19.1.0/aapt package -f --no-crunch -I /Users/Debosmit/Library/Android/sdk/platforms/android-16/android.jar -M /Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/res/debug -A /Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/assets/debug -m -J /Users/Debosmit/Documents/Workspace/devpact/app/build/generated/source/r/debug -F /Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/res/resources-debug.ap_ --debug-mode --custom-package com.example.devpact -0 apk --output-text-symbols /Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/symbols/debug
  Error Code:
    1
  Output:
    /Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/res/debug/layout-v21/place_autocomplete_fragment.xml:11: error: Error: No resource found that matches the given name (at 'background' with value '?android:attr/selectableItemBackgroundBorderless').
    /Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/res/debug/layout-v21/place_autocomplete_fragment.xml:42: error: Error: No resource found that matches the given name (at 'background' with value '?android:attr/selectableItemBackgroundBorderless').
    /Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/res/debug/layout/place_autocomplete_item_powered_by_google.xml:8: error: No resource identifier found for attribute 'layout_marginStart' in package 'android'
    /Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/res/debug/layout/place_autocomplete_item_powered_by_google.xml:28: error: No resource identifier found for attribute 'layout_toEndOf' in package 'android'
    /Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/res/debug/layout/place_autocomplete_item_powered_by_google.xml:28: error: No resource identifier found for attribute 'layout_marginStart' in package 'android'
    /Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/res/debug/layout/place_autocomplete_item_prediction.xml:8: error: No resource identifier found for attribute 'layout_alignParentStart' in package 'android'
    /Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/res/debug/layout/place_autocomplete_item_prediction.xml:35: error: No resource identifier found for attribute 'layout_toEndOf' in package 'android'
    /Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/res/debug/layout/place_autocomplete_item_prediction.xml:52: error: No resource identifier found for attribute 'layout_toEndOf' in package 'android'
    /Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/res/debug/layout/place_autocomplete_progress.xml:2: error: No resource identifier found for attribute 'indeterminateTint' in package 'android'
    /Users/Debosmit/Documents/Workspace/devpact/app/build/intermediates/res/debug/layout/place_autocomplete_progress.xml:2: error: No resource identifier found for attribute 'indeterminateTintMode' in package 'android'

最佳答案

问题出在 compileSdkVersion 上。将其更改为 23(最新)似乎可以解决问题。

与上述问题无关,我还将 targetSdkVersion 更改为 23(最新),因为 API 级别低于该级别的目标设备没有多大意义。

关于android - 将 Google Play 服务位置添加为依赖项后找不到资源标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35213311/

相关文章:

android - ContactsContract.Contacts.LAST_TIME_CONTACTED 可靠吗?

Android aar 已停止使用 extractDebugAnnotations com/intellij/psi/PsiJavaFile android 构建

android - React Native ScrollView 在 Android Landscape 上裁剪最后一个元素

android - 将 google play 服务库添加到 Cordova

java.lang.noclassdeffounderror 谷歌播放服务

android - 生成包含所有依赖项的 AAR 文件

java - 将 Android 设备的壁纸保存为图片

java - 我不知道如何从 gradle 依赖项导入包

java - 如何使用 Gradle 5.x 生成 JPA 元模型

scala - 无法注册扩展名org.sonar.plugins.scala.cobertura.CoberturaSensor