Android resource linking failed

Mars-xq發表於2018-11-27

編譯報錯:

Android resource linking failed
Output:  C:\Users\13579\Desktop\early\MyLoading\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:3082: 
error: expected reference but got (raw string) #00000000.
error: failed linking references.

Command: C:\Users\13579\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\d7e688e38fe8878f08b5bcf541788205\aapt2-3.2.0-4818971-windows\aapt2.exe link -I\
        E:\sdk\platforms\android-28\android.jar\
        --manifest\
        C:\Users\13579\Desktop\early\MyLoading\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
        -o\
        C:\Users\13579\Desktop\early\MyLoading\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
        -R\
        @C:\Users\13579\Desktop\early\MyLoading\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
        --auto-add-overlay\
        --java\
        C:\Users\13579\Desktop\early\MyLoading\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
        --custom-package\
        com.xq.e.myloading\
        -0\
        apk\
        --output-text-symbols\
        C:\Users\13579\Desktop\early\MyLoading\app\build\intermediates\symbols\debug\R.txt\
        --no-version-vectors
Daemon:  AAPT2 aapt2-3.2.0-4818971-windows Daemon #0

在gradle.property中新增:

android.enableAapt2=false

繼續報錯:

The option 'android.enableAapt2' is deprecated and should not be used anymore.
Use 'android.enableAapt2=true' to remove this warning.
It will be removed at the end of 2018..

Process 'command 'E:\sdk\build-tools\28.0.2\aapt.exe'' finished with non-zero exit value 1

最後通過逐段註釋發現:

 <style name="custom_dialog_style" parent="android:Theme.Dialog">
          <item name="android:windowBackground">@android:color/transparent</item>
    	     <!--<item name="android:windowBackground">#00000000</item>-->
 </style>

在styles中不可直接使用顏色值,需要引用。

正確為:

 <style name="custom_dialog_style" parent="android:Theme.Dialog">
          <item name="android:windowBackground">@android:color/transparent</item>
 </style>

相關文章