Azure Pipeline中android-manifest-version@1任务报“Unable to find matched key”求助
解决Azure Pipeline android-manifest-version@1任务报错“Unable to find matched key”
可能原因及修复步骤
检查AndroidManifest.xml核心结构
确保AndroidManifest.xml的<manifest>标签中存在android:versionCode属性(任务需要匹配到该属性才能完成修改),正确结构示例:<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.your.app.package" android:versionCode="1" android:versionName="1.0.0"> <!-- 其他内容 --> </manifest>如果原本没有
android:versionCode,先手动添加初始值,任务才能识别并替换。验证Manifest文件路径正确性
任务配置的sourcePath可能指向错误位置,添加前置脚本验证文件是否存在:- script: | ls -la $(Build.SourcesDirectory)/android/app/src/main/AndroidManifest.xml displayName: 'Verify Manifest File Exists'查看Pipeline日志,确认文件确实存在于该路径下,若路径错误则修正
sourcePath。调整任务参数配置
若不需要修改versionName,直接移除versionName:这一行(留空可能导致任务尝试匹配该属性却找不到),修改后的任务配置示例:- task: android-manifest-version@1 inputs: sourcePath: '$(Build.SourcesDirectory)/android/app/src/main/AndroidManifest.xml' versionCodeOption: 'buildid' versionCode: '$(Build.BuildId)' versionCodeOffset: '1' printFile: true确认命名空间正确性
确保<manifest>标签顶部声明了xmlns:android="http://schemas.android.com/apk/res/android",否则android:versionCode会被视为无效属性,任务无法匹配。
内容的提问来源于stack exchange,提问作者Kapil G
相关产品推荐
相关产品推荐

