Tag Archives: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed

[Solved] com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed

The solution for error reporting in case of record import into Google Android is as follows: com.android.builder.internal.aapt.v2.aapt2exception: Android resource linking failed

The details are as follows:

Android resource linking failed
Output:  /Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:221: error: resource android:attr/fontStyle not found.
/Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:222: error: resource android:attr/font not found.
/Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:223: error: resource android:attr/fontWeight not found.
/Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:224: error: resource android:attr/fontVariationSettings not found.
/Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:225: error: resource android:attr/ttcIndex not found.
error: failed linking references.

Command: /Users/chmy/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-4818971-osx.jar/cc4633529fe8cee26cd686b6b28203cf/aapt2-3.2.0-4818971-osx/aapt2 link -I\
        /Users/chmy/Library/Android/sdk/platforms/android-24/android.jar\
        --manifest\
        /Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml\
        -o\
        /Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/processed_res/debug/processDebugResources/out/resources-debug.ap_\
        -R\
        @/Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/incremental/processDebugResources/resources-list-for-resources-debug.ap_.txt\
        --auto-add-overlay\
        --java\
        /Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/generated/not_namespaced_r_class_sources/debug/processDebugResources/r\
        --custom-package\
        com.example.android.messagingservice\
        -0\
        apk\
        --output-text-symbols\
        /Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/symbols/debug/R.txt\
        --no-version-vectors
Daemon:  AAPT2 aapt2-3.2.0-4818971-osx Daemon #0

Many people on the Internet say to add a configuration in gradle.properties, but the increase is not solved

Solution: the compiled version is not configured correctly. Original version number:

android {
    //
    compileSdkVersion 24

    buildToolsVersion '28.0.3'

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 24

    }
...

After modification:

android {
    // 
    compileSdkVersion 28

    buildToolsVersion '28.0.3'

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 28

    }

After compiling again, the problem is solved. This is the solution that I met, and I haven’t met others for the time being