之前打包盒上传 aab 包一直没问题,今天突然报错如下:
针对您上传的 App Bundle 运行 bundletool build-apks 时出错。
请在本地运行 bundletool build-apks,确保您的 App Bundle 有效,然后重试。
错误:Invalid uncompressed glob: '**['.[uU][nN][iI][tT][yY]3[dD]', '.[rR][eE][sS][sS]', '.[rR][eE][sS][oO][uU][rR][cC][eE]', '.[oO][bB][bB]', '.[bB][uU][nN][dD][lL][eE]', '.[uU][nN][iI][tT][yY][eE][xX][pP]'] + [uU][nN][iI][tT][yY][sS][tT][rR][eE][aA][mM][iI][nN][gG][aA][sS][sS][eE][tT][sS].[tT][oO][kK][eE][nN][iI][zZ][eE](', ')'.
通过本地的 bundletool 工具测试报错如下:
c
[BT:1.17.1] Error: Invalid uncompressed glob: '**['.[uU][nN][iI][tT][yY]3[dD]', '.[rR][eE][sS][sS]', '.[rR][eE][sS][oO][uU][rR][cC][eE]', '.[oO][bB][bB]', '.[bB][uU][nN][dD][lL][eE]', '.[uU][nN][iI][tT][yY][eE][xX][pP]'] + [uU][nN][iI][tT][yY][sS][tT][rR][eE][aA][mM][iI][nN][gG][aA][sS][sS][eE][tT][sS].[tT][oO][kK][eE][nN][iI][zZ][eE](', ')'.
com.android.tools.build.bundletool.model.exceptions.InvalidBundleException: Invalid uncompressed glob: '**['.[uU][nN][iI][tT][yY]3[dD]', '.[rR][eE][sS][sS]', '.[rR][eE][sS][oO][uU][rR][cC][eE]', '.[oO][bB][bB]', '.[bB][uU][nN][dD][lL][eE]', '.[uU][nN][iI][tT][yY][eE][xX][pP]'] + [uU][nN][iI][tT][yY][sS][tT][rR][eE][aA][mM][iI][nN][gG][aA][sS][sS][eE][tT][sS].[tT][oO][kK][eE][nN][iI][zZ][eE](', ')'.
at com.android.tools.build.bundletool.model.exceptions.UserExceptionBuilder.build(UserExceptionBuilder.java:58)
at com.android.tools.build.bundletool.validation.BundleConfigValidator.validateCompression(BundleConfigValidator.java:78)
at com.android.tools.build.bundletool.validation.BundleConfigValidator.validateBundle(BundleConfigValidator.java:59)
at com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundleUsingSubValidator(ValidatorRunner.java:79)
at com.android.tools.build.bundletool.validation.ValidatorRunner.lambda$validateBundle$4(ValidatorRunner.java:64)
at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:422)
at com.android.tools.build.bundletool.validation.ValidatorRunner.validateBundle(ValidatorRunner.java:64)
at com.android.tools.build.bundletool.validation.AppBundleValidator.validate(AppBundleValidator.java:114)
at com.android.tools.build.bundletool.commands.BuildApksCommand.execute(BuildApksCommand.java:920)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:83)
at com.android.tools.build.bundletool.BundleToolMain.main(BundleToolMain.java:55)
Caused by: com.android.tools.build.bundletool.model.utils.PathMatcher$GlobPatternSyntaxException: Unable to parse glob pattern '**['.[uU][nN][iI][tT][yY]3[dD]', '.[rR][eE][sS][sS]', '.[rR][eE][sS][oO][uU][rR][cC][eE]', '.[oO][bB][bB]', '.[bB][uU][nN][dD][lL][eE]', '.[uU][nN][iI][tT][yY][eE][xX][pP]'] + [uU][nN][iI][tT][yY][sS][tT][rR][eE][aA][mM][iI][nN][gG][aA][sS][sS][eE][tT][sS].[tT][oO][kK][eE][nN][iI][zZ][eE](', ')' at character 173. Error: No matching '[' found.
at com.android.tools.build.bundletool.model.utils.PathMatcher.convertGlobToRegexp(PathMatcher.java:142)
at com.android.tools.build.bundletool.model.utils.PathMatcher.createFromGlob(PathMatcher.java:52)
at com.android.tools.build.bundletool.validation.BundleConfigValidator.validateCompression(BundleConfigValidator.java:73)
... 9 more
但是可以正常打 apk 包,运行也正常,查了半天没有什么有用的信息,下面是最后解决问题的方案:
查看 build.gradle
文件中的 noCompress
配置
noCompress '['.unity3d', '.ress', '.resource', '.obb', '.bundle', '.unityexp'] + unityStreamingAssets.tokenize(', ')'
我遇到的问题是该配置过时了,需要改成如下的写法
noCompress = ['.unity3d', '.ress', '.resource', '.obb', '.bundle', '.unityexp'] + unityStreamingAssets.tokenize(', ')
更改完成后就没问题了。