我正在尝试使用 bundletool
命令行构建 android app bundle
,并按照https://developer.android.com/studio/build/building-cmdline#bundletool-build中的说明进行操作。
使用 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链接参数中。
有人遇到过这个问题吗?欢迎任何评论。
aapt2 compile --dir input/res -o temp_dir/compiled_resources
然后执行aapt2 link --proto-format -o temporary.apk -I platforms/android-29/android.jar --manifest input/AndroidManifest.xml -R compiled_resources/*.flat --auto-add-overlay --java gen
- Yigit Alparslan