Search code examples
javaandroidgoogle-vision

Android studio error: "Android resource linking failed. error: failed linking references" with google services API


Hello I am trying to add this google play service: com.google.android.gms:play-services-vision:18.0.0 to my application, but it gives to me this error:

Android resource linking failed
Output:  /home/user/java/Project/android-storage-permissions-master/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:460: error: resource android:attr/fontVariationSettings not found.
/home/user/java/Project/android-storage-permissions-master/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:460: error: resource android:attr/ttcIndex not found.
error: failed linking references.

Command: /home/user/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-4818971-linux.jar/9bc4b7764b45753075ab29399a857b9f/aapt2-3.2.0-4818971-linux/aapt2 link -I\
        /home/user/Android/Sdk/platforms/android-27/android.jar\
        --manifest\
        /home/user/java/Project/android-storage-permissions-master/app/build/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml\
        -o\
        /home/user/java/Project/android-storage-permissions-master/app/build/intermediates/processed_res/debug/processDebugResources/out/resources-debug.ap_\
        -R\
        @/home/user/java/Project/android-storage-permissions-master/app/build/intermediates/incremental/processDebugResources/resources-list-for-resources-debug.ap_.txt\
        --auto-add-overlay\
        --java\
        /home/user/java/Project/android-storage-permissions-master/app/build/generated/not_namespaced_r_class_sources/debug/processDebugResources/r\
        --custom-package\
        com.google.samples.dataprivacy\
        -0\
        apk\
        --output-text-symbols\
        /home/user/java/Project/android-storage-permissions-master/app/build/intermediates/symbols/debug/R.txt\
        --no-version-vectors
Daemon:  AAPT2 aapt2-3.2.0-4818971-linux Daemon #0

Those are my build.gradle(Module.App) dependencies:

dependencies {
    implementation "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
    implementation "com.android.support.constraint:constraint-layout:$rootProject.ext.constraintLayoutVersion"
    implementation "com.android.support:design:$rootProject.ext.supportLibraryVersion"
    implementation "com.android.support:recyclerview-v7:$rootProject.ext.supportLibraryVersion"
    implementation "com.android.support:support-core-utils:$rootProject.ext.supportLibraryVersion"
    implementation "com.google.android.gms:play-services-vision:18.0.0"
    implementation "pub.devrel:easypermissions:$rootProject.ext.easypermissionsVersion"

    androidTestImplementation("com.android.support.test.espresso:espresso-core:$rootProject.ext.espressoVersion", {
        exclude group: "com.android.support", module: "support-annotations"
    })

    // Dependencies for local unit tests
    testImplementation "junit:junit:$rootProject.ext.junitVersion"
    testImplementation "org.mockito:mockito-all:$rootProject.ext.mockitoVersion"
    testImplementation "org.hamcrest:hamcrest-all:$rootProject.ext.hamcrestVersion"
    testImplementation "org.powermock:powermock-module-junit4:$rootProject.ext.powerMockito"
    testImplementation "org.powermock:powermock-api-mockito:$rootProject.ext.powerMockito"
    testImplementation "junit:junit:$rootProject.ext.junitVersion"

}

And in the top level gradle file I am using supportLibraryVersion = '27.1.1'. I tried to change compile sdk version to v28, but it gave to me other errors because many other parts of my code are written for v27. For now I resolved it using com.google.android.gms:play-services-vision:17.0.2. I want to know if there are other ways to fix this error keep using the more updated version of API.


Solution

  • This is because the attributes used in that library were only added in API 28. The only way to get fontVariationSettings and ttcIndex is to upgrade your compile SDK version to 28. Another option is to downgrade the version of that library.