android.netazure-devopsazure-pipelinesmaui

How to deploy Android .NET MAUI app to different environments (Dev/Test/Prod) via Azure DevOps CI/CD?


Before we upgraded from Xamarin to .NET MAUI, we had a single Build Pipeline to compile the app for Android, using Release Configuration and settings for Dev environment. Then we had a Release Pipeline which deployed that to App Center in the 1st Stage. The next stage (after approval), unpacked the .apk file, updated a config.json and the AndroidManifest.xml files with values for Test environment, then re-packed, signed the .apk file and deployed it to App Center.

We were using Scott McDougall's "Pack or unpack an apk file." tool in the Release Pipeline, but now with .NET MAUI, the re-pack of the .apk file is failing with this error...

No resource identifier found for attribute 'lStar' in package 'XXXXXXXX' & Resource is not public

Has anyone experience this, and know a way to fix it? Or is there a better way to deploy to Test and Production with different config/xml values? My workaround is to have separate Test and Production branches in our repo, which have the specific values for each config/xml file, and do a complete build/deploy. But I'd rather not have to re-build for each environment.

Update below...

The Release Pipeline has these settings...

 Agent pool.........: Azure Pipelines
 Agent Specification: windows-latest
 Demands............: java, JDK

The Tasks are as follows...

Output of the re-pack apk step...

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

Thanks, Pete


Solution

  • error: No resource identifier found for attribute 'lStar' in package 'android'

    The cause of the issue is related to the apktool version used by the extension task: Pack or unpack an apk file.

    The extension task will use the old version: 2.4.1 to do the APK repack action and cause the issue.

    Based on your confirmation, we can install latest version(2.10.0) of apktool to solve the issue.

    In Azure Pipelines, we can use the following command to install the latest version of apktool.

    choco install apktool
    

    To verify the latest version of apktool, you can navigate to this site: APKTool release note. It will list all versions of apktool.