在从 Xamarin 升级到 .NET MAUI 之前,我们有一个构建管道来使用发布配置和开发环境设置来编译适用于 Android 的应用程序。 然后我们有一个发布管道,在第一阶段将其部署到应用程序中心。 下一阶段(批准后),解压 .apk 文件,使用测试环境的值更新 config.json 和 AndroidManifest.xml 文件,然后重新打包、签署 .apk 文件并将其部署到 App Center。
我们使用 Scott McDougall 的“打包或解压 apk 文件”。发布管道中的工具,但现在使用 .NET MAUI,重新打包 .apk 文件失败并出现此错误...
在包“XXXXXXXX”中找不到属性“lStar”的资源标识符并且资源不是公开的
有人经历过这种情况,并且知道解决方法吗? 或者是否有更好的方法使用不同的 config/xml 值部署到测试和生产? 我的解决方法是在我们的存储库中建立单独的测试和生产分支,其中每个配置/xml 文件都有特定的值,并执行完整的构建/部署。 但我宁愿不必为每个环境重新构建。
更新如下...
发布管道有这些设置...
代理池......: Azure Pipelines 代理规范:windows-latest 需求............:java、JDK
任务如下...
重新打包 apk 步骤的输出...
2024-11-13T15:34:52.8698566Z ##[section]Starting: Repack APK File
2024-11-13T15:34:52.8703697Z ==============================================================================
2024-11-13T15:34:52.8703854Z Task : Pack or unpack an apk file.
2024-11-13T15:34:52.8703967Z Description : Pack or unpack an apk file after modifications have been made
2024-11-13T15:34:52.8704093Z Version : 1.0.302
2024-11-13T15:34:52.8704173Z Author : Scott MacDougall
2024-11-13T15:34:52.8704277Z Help :
2024-11-13T15:34:52.8704348Z ==============================================================================
2024-11-13T15:34:53.0617144Z [command]C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\8.0.432-6\x64\bin\java.exe -jar D:\a\_tasks\PackUnpackApkFile_662de9c5-0a46-4e8f-aedf-96f8b36ea946\1.0.302\node_modules\apk-utilities\apktool.jar b D:\a\r1\a\apk-unpack\output -o D:\a\r1\a\apk-pack\output\com.centralhudson.mobileapp.test.apk
2024-11-13T15:34:53.1926873Z I: Using Apktool 2.4.1
2024-11-13T15:34:53.1927442Z
2024-11-13T15:34:53.1928038Z I: Using Apktool 2.4.1
2024-11-13T15:34:53.4555319Z I: Checking whether sources has changed...
2024-11-13T15:34:53.4555720Z
2024-11-13T15:34:53.4556261Z I: Checking whether sources has changed...
2024-11-13T15:34:53.4556643Z I: Smaling smali folder into classes.dex...
2024-11-13T15:34:53.4556849Z
2024-11-13T15:34:53.4557155Z I: Smaling smali folder into classes.dex...
2024-11-13T15:35:06.8166354Z I: Checking whether sources has changed...
2024-11-13T15:35:06.8166835Z
2024-11-13T15:35:06.8167416Z I: Checking whether sources has changed...
2024-11-13T15:35:06.8167845Z I: Smaling smali_classes2 folder into classes2.dex...
2024-11-13T15:35:06.8168078Z
2024-11-13T15:35:06.8168410Z I: Smaling smali_classes2 folder into classes2.dex...
2024-11-13T15:35:14.8801122Z I: Checking whether resources has changed...
2024-11-13T15:35:14.8801454Z
2024-11-13T15:35:14.8801830Z I: Checking whether resources has changed...
2024-11-13T15:35:14.8802115Z I: Building resources...
2024-11-13T15:35:14.8802286Z
2024-11-13T15:35:14.8802531Z I: Building resources...
2024-11-13T15:35:15.3288142Z W: fakeLogOpen(/dev/log_crash) failed
2024-11-13T15:35:15.3288703Z W: fakeLogOpen(/dev/log_stats) failed
2024-11-13T15:35:15.3289005Z W: fakeLogOpen(/dev/log_crash) failed
2024-11-13T15:35:15.3289292Z W: fakeLogOpen(/dev/log_stats) failed
2024-11-13T15:35:15.3289591Z W: fakeLogOpen(/dev/log_stats) failed
2024-11-13T15:35:16.4315297Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral12.xml:4: error: No resource identifier found for attribute 'lStar' in package 'android'
2024-11-13T15:35:16.4316358Z W:
2024-11-13T15:35:16.4317490Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral12.xml:4: error: Error: Resource is not public. (at 'color' with value '@android:color/Purple_800').
2024-11-13T15:35:16.4318277Z W:
2024-11-13T15:35:16.4318972Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral17.xml:4: error: No resource identifier found for attribute 'lStar' in package 'android'
2024-11-13T15:35:16.4320161Z W:
2024-11-13T15:35:16.4347865Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral17.xml:4: error: Error: Resource is not public. (at 'color' with value '@android:color/Purple_800').
2024-11-13T15:35:16.4348353Z W:
2024-11-13T15:35:16.4356281Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral22.xml:4: error: No resource identifier found for attribute 'lStar' in package 'android'
2024-11-13T15:35:16.4359950Z W:
2024-11-13T15:35:16.4362156Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral22.xml:4: error: Error: Resource is not public. (at 'color' with value '@android:color/Purple_800').
2024-11-13T15:35:16.4363106Z W:
2024-11-13T15:35:16.4365048Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral24.xml:4: error: No resource identifier found for attribute 'lStar' in package 'android'
2024-11-13T15:35:16.4365446Z W:
2024-11-13T15:35:16.4374012Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral24.xml:4: error: Error: Resource is not public. (at 'color' with value '@android:color/Purple_800').
2024-11-13T15:35:16.4374501Z W:
2024-11-13T15:35:16.4375995Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral4.xml:4: error: No resource identifier found for attribute 'lStar' in package 'android'
2024-11-13T15:35:16.4376376Z W:
2024-11-13T15:35:16.4380174Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral4.xml:4: error: Error: Resource is not public. (at 'color' with value '@android:color/Purple_800').
2024-11-13T15:35:16.4380990Z W:
2024-11-13T15:35:16.4383828Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral6.xml:4: error: No resource identifier found for attribute 'lStar' in package 'android'
2024-11-13T15:35:16.4384277Z W:
2024-11-13T15:35:16.4391197Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral6.xml:4: error: Error: Resource is not public. (at 'color' with value '@android:color/Purple_800').
2024-11-13T15:35:16.4391632Z W:
2024-11-13T15:35:16.4392946Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral87.xml:4: error: No resource identifier found for attribute 'lStar' in package 'android'
2024-11-13T15:35:16.4395701Z W:
2024-11-13T15:35:16.4397439Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral87.xml:4: error: Error: Resource is not public. (at 'color' with value '@android:color/Purple_800').
2024-11-13T15:35:16.4399787Z W:
2024-11-13T15:35:16.4401115Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral92.xml:4: error: No resource identifier found for attribute 'lStar' in package 'android'
2024-11-13T15:35:16.4402040Z W:
2024-11-13T15:35:16.4406276Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral92.xml:4: error: Error: Resource is not public. (at 'color' with value '@android:color/Purple_800').
2024-11-13T15:35:16.4406751Z W:
2024-11-13T15:35:16.4411204Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral94.xml:4: error: No resource identifier found for attribute 'lStar' in package 'android'
2024-11-13T15:35:16.4411576Z W:
2024-11-13T15:35:16.4414299Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral94.xml:4: error: Error: Resource is not public. (at 'color' with value '@android:color/Purple_800').
2024-11-13T15:35:16.4414702Z W:
2024-11-13T15:35:16.4419011Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral96.xml:4: error: No resource identifier found for attribute 'lStar' in package 'android'
2024-11-13T15:35:16.4420600Z W:
2024-11-13T15:35:16.4421911Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral96.xml:4: error: Error: Resource is not public. (at 'color' with value '@android:color/Purple_800').
2024-11-13T15:35:16.4422788Z W:
2024-11-13T15:35:16.4432965Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral98.xml:4: error: No resource identifier found for attribute 'lStar' in package 'android'
2024-11-13T15:35:16.4433498Z W:
2024-11-13T15:35:16.4434104Z W: D:\a\r1\a\apk-unpack\output\res\color-v31\m3_ref_palette_dynamic_neutral98.xml:4: error: Error: Resource is not public. (at 'color' with value '@android:color/Purple_800').
2024-11-13T15:35:16.4434519Z W:
2024-11-13T15:35:16.4530618Z brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\VSSADM~1\AppData\Local\Temp\brut_util_Jar_645900618191949689.tmp, p, --forced-package-id, 127, --version-code, 10664, --version-name, 106.64, --no-version-vectors, -F, C:\Users\VSSADM~1\AppData\Local\Temp\APKTOOL5412113427285104894.tmp, -e, C:\Users\VSSADM~1\AppData\Local\Temp\APKTOOL332445739321605887.tmp, -0, arsc, -I, C:\Users\VssAdministrator\AppData\Local\apktool\framework\1.apk, -S, D:\a\r1\a\apk-unpack\output\res, -M, D:\a\r1\a\apk-unpack\output\AndroidManifest.xml]
2024-11-13T15:35:16.5358845Z ##[error]Unable to pack apk
2024-11-13T15:35:16.5396009Z ##[section]Finishing: Repack APK File
谢谢, 皮特
错误:在包“android”中找不到属性“lStar”的资源标识符
问题原因与扩展任务使用的apktool版本有关:打包或解压apk文件。
扩展任务将使用旧版本:2.4.1 进行 APK 重新打包操作并导致问题。
根据您的确认,我们可以安装最新版本(2.10.0)的apktool来解决该问题。
在Azure Pipelines中,我们可以使用以下命令来安装最新版本的apktool。
choco install apktool
要验证 apktool 的最新版本,您可以导航到此站点:APKTool 发行说明。它将列出 apktool 的所有版本。