记录一个Android构建错误

本文约 500 字,阅读需 1 分钟。

今天发现个人Devcloud可以升级到32核,于是升级了下(+重启),升级完成后Android就构建失败了,错误日志如下:

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
   > Android resource linking failed
     /data/work/****App/****App/build/app/intermediates/packaged_manifests/debug/AndroidManifest.xml:245: error: resource attr/??? (aka com.tencent.docs:attr/???) not found.
     error: failed processing manifest.

打开这个文件,发现如下:

  <activity
      android:name="com.tencent.docs.wxapi.WXEntryActivity"
      android:exported="true"
      android:label="????"
      android:launchMode="singleTask"
      android:taskAffinity="com.tencent.docs"
      android:theme="@android:style/Theme.Translucent.NoTitleBar" />

这个时候,如果全局查com.tencent.docs.wxapi.WXEntryActivity,其实找不到关键信息,但注意到..../build/app/outputs/logs/manifest-merger-debug-report.txt有如下内容

ADDED from /data/work/*****App/*****App/android/app/src/main/AndroidManifest.xml:142:9-144:67
	android:value
		ADDED from /data/work/*****App/*****App/android/app/src/main/AndroidManifest.xml:144:13-64
	android:name
		ADDED from /data/work/*****App/*****App/android/app/src/main/AndroidManifest.xml:143:13-41
activity#com.tencent.docs.wxapi.WXEntryActivity

于是找到*****App/android/app/src/main/AndroidManifest.xml,使用Vim从Terminal打开:

  <activity
      android:name=".wxapi.WXEntryActivity"
      android:label="~E讯~V~G档"
      android:theme="@android:style/Theme.Translucent.NoTitleBar"
      android:exported="true"
      android:taskAffinity="com.tencent.docs"
      android:launchMode="singleTask" />

但使用VSCode打开是正常的,容易猜到是编译问题:

$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
# ...... skip
LC_ALL=

结合debian - How can I enable UTF-8 support in the Linux console? - Unix & Linux Stack Exchange作如下配置即可:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
总阅读量次。