报错信息:
> Task :app:processDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform material-1.1.0.aar (com.google.android.material:material:1.1.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for AarResourcesCompilerTransform: C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-2\files-2.1\c89c81584c748fa0e0cf1ffbf8567c45\material-1.1.0.
> Android resource compilation failed
AAPT: C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-2\files-2.1\a5cd8e264da93718a63d1849cdb1e6d8\com.google.android.material: error: ??�?���?�����?��� (2).
> Failed to transform appcompat-1.1.0.aar (androidx.appcompat:appcompat:1.1.0) to match attributes {artifactType=android-compiled-dependencies-resources, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
> Execution failed for AarResourcesCompilerTransform: C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-2\files-2.1\782561e979c911de1812a5cba7f1c33f\appcompat-1.1.0.
> Android resource compilation failed
AAPT: C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-2\files-2.1\2f19e0913255172509acd381726f5fd5\androidx.appcompat: error: ??�?���?�����?��� (2).
...
以上日志中的乱码代表的应该是“系统找不到指定的文件”。出现这个问题的原因是未设置环境变量GRADILE_USER_HOME ,则gradle会直接去系统目录查找导致报错。 默认情况下,.gradle目录应该在用户目录下,因此需要设置环境变量GRADILE_USER_HOME ,值为%HOMEPATH% 另外,若是Jenkins, GitLab CI/CD 出现该问题,原理类似,解决方案也是在相应流水线设置中添加该环境变量。
|