解决com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

记录导入google android事例报错解决方案 如下: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed

具体如下:

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

网上有很多说在gradle.properties中增加个配置,但是增加也是没有解决。

解决方案: 编译的版本配置不正确。 原版本号:

android {
    //
    compileSdkVersion 24

    buildToolsVersion '28.0.3'

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 24

    }
...

修改之后:

android {
    // 
    compileSdkVersion 28

    buildToolsVersion '28.0.3'

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 28

    }

再次进行编译,则问题解决。 这是我遇到的解决方案,其他的暂时没有遇到。

转载于:https://my.oschina.net/who7708/blog/2236811

你可能感兴趣的:(解决com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed)