android - 无法从命令行使用 bundletool 构建 android app bundle
问题描述
我正在尝试按照https://developer.android.com/studio/build/building-cmdline#bundletool-build中描述的说明android app bundle
从命令行构建bundletool
一个基本从 Android Studio 创建的简单 android 项目用于调查在 Android Studio 上成功编译的项目。
编译资源的步骤是可以的,但是在与 aapt2 的链接步骤中失败了。经测试aapt2-3.4.0-5326820-windows
命令:
set ANDROID_TOOL=%ANDROID_SDK%/platforms/android-26/android.jar
%AAPT2% link --proto-format -o output.apk -I %ANDROID_TOOL% --manifest %CURRENT_DIR%/app/src/main/AndroidManifest.xml -R @compiled_resources.txt --auto-add-overlay -v
compiled_resources.txt
包含我之前处理过的 .flat 编译资源列表。
错误:
error: resource style/Theme.AppCompat.Light.DarkActionBar (aka com.example.doandominh.simpleaab:style/Theme.AppCompat.Light.DarkActionBar) not found.
I:\RnD\AAB\SimpleAAB\\app\src\main\res\values\styles.xml:6: error: style attribute 'attr/colorPrimary (aka com.example.doandominh.simpleaab:attr/colorPrimary)' not found.
I:\RnD\AAB\SimpleAAB\\app\src\main\res\values\styles.xml:7: error: style attribute 'attr/colorPrimaryDark (aka com.example.doandominh.simpleaab:attr/colorPrimaryDark)' not found.
I:\RnD\AAB\SimpleAAB\\app\src\main\res\values\styles.xml:8: error: style attribute 'attr/colorAccent (aka com.example.doandominh.simpleaab:attr/colorAccent)' not found.
error: failed linking references.
我认为这取决于类似 'com.android.support:appcompat-v7:26.1.0' 但我不知道如何将它们添加到 aapt2 链接参数。
有没有人遇到过这个问题?任何评论都非常感谢。
解决方案
tldr:您还需要编译 AppCompat 资源,因为您正在手动构建所有这些资源,并将它们传递给与本地资源相同的链接方式(顺序很重要,以保持正确的覆盖/覆盖)。
Android Gradle 插件在应用级别处理资源的方式是:
- 合并所有资源(本地应用程序、本地库、远程库、额外资源源集等)
- 使用“aapt2 compile”编译所有内容(有或没有 PNG 处理)
- 将所有内容链接到 APK
推荐阅读
- python - python速记表达式中的语法错误
- c - 我有一串字母和数字,我必须在其中找到每个数字从 0 到 9 的频率
- amazon-redshift - 删除由 Amazon Redshift 创建的临时表
- angular - 响应式断点不适用于 Angular 7 上的 ngx-slick
- linux - 执行包含特殊字符的字符串
- javascript - SequelizeValidationError : askType 不能是数组或对象
- linux - bash 在 linux 中吃掉日期格式的空格
- javascript - 如何从客户端更改翻译文件
- sql-server - 如何修复 Group By 中的聚合,缺少聚合值
- python - google-collab:如何在 Google Collab 中连接到 pymysql?