解决 AAPT2 aapt2-3.2.0-4818971-windows Daemon 错误
异常信息:
Android resource linking failed
Output: F:\workspace\Android Gradle workspace\prj2_1\app\src\main\res\layout\content_hello_world.xml:11: error: attribute layout_constraintBottom_toBottomOf (aka com.example.xzlawin:layout_constraintBottom_toBottomOf) not found.
F:\workspace\Android Gradle workspace\prj2_1\app\src\main\res\layout\content_hello_world.xml:11: error: attribute layout_constraintLeft_toLeftOf (aka com.example.xzlawin:layout_constraintLeft_toLeftOf) not found.
F:\workspace\Android Gradle workspace\prj2_1\app\src\main\res\layout\content_hello_world.xml:11: error: attribute layout_constraintRight_toRightOf (aka com.example.xzlawin:layout_constraintRight_toRightOf) not found.
F:\workspace\Android Gradle workspace\prj2_1\app\src\main\res\layout\content_hello_world.xml:11: error: attribute layout_constraintTop_toTopOf (aka com.example.xzlawin:layout_constraintTop_toTopOf) not found.
error: failed linking file resources.
Command: E:\Software Development Kit\Android\gradle-4.9\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\6a3dffcc84adfe2ff8746605211184ae\aapt2-3.2.0-4818971-windows\aapt2.exe link -I\
E:\Android_Kit\android-sdk-windows\platforms\android-28\android.jar\
--manifest\
F:\workspace\Android Gradle workspace\prj2_1\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
-o\
F:\workspace\Android Gradle workspace\prj2_1\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
-R\
@F:\workspace\Android Gradle workspace\prj2_1\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
--auto-add-overlay\
--java\
F:\workspace\Android Gradle workspace\prj2_1\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
--custom-package\
com.example.xzlawin\
-0\
apk\
--output-text-symbols\
F:\workspace\Android Gradle workspace\prj2_1\app\build\intermediates\symbols\debug\R.txt\
--no-version-vectors
Daemon: AAPT2 aapt2-3.2.0-4818971-windows Daemon #0
问题原因:缺少依赖库
com.example.xzlawin:layout_constraintBottom_toBottomOf) not found
解决方法:导入依赖库
android 依赖库导入
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
androidx 依赖库导入
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
注意:根据项目实际环境,二者只能导入一个,两个同时导入,会出Program type already present异常