如何在 aab 格式(android 应用程序包)中处理 R class?
How R class are handled inside aab format (android app bundle)?
我有一个在 Delphi 中制作的本机应用程序(我的意思是在 ARM 中编译)。此应用程序在 Android32 中使用 apk 包运行良好。但是现在我想迁移到 android 64 然后改用 aab 格式但是当我这样做并且当我 运行 我收到错误的应用程序时: android.content.res.Resources$NotFoundException: Resource ID #0x7f04001d type #0x1c
is无效。 因为它是本机应用程序,所以我必须手动生成 R class
,我是这样做的
- 我使用 aapt.exe 创建 R.java
- 然后用 javac 我将 R.java 编译成 R$ 类
- 最后我构建了一个包含 R$ 类
的 classes.dex
我做了 2 次这个过程,一次构建 android32 dex 和 SO 库,另一次构建 android64 dex 和 SO 库
最后,我使用 bundletool-all-0.10 构建了 aab 文件。3.jar
我错过了什么?为什么使用 apk 我的过程运行良好,但使用 aab 却失败了?
Dex 文件对于 32 位和 64 位必须相同,所以你应该有一个 classes.dex 和一个资源 table (resources.arsc) 来生成。
此外,AAB 使用不同格式的资源 table,必须使用 aapt2 而不是 aapt 生成。看
https://developer.android.com/studio/build/building-cmdline#bundletool-build 所有细节。
我有一个在 Delphi 中制作的本机应用程序(我的意思是在 ARM 中编译)。此应用程序在 Android32 中使用 apk 包运行良好。但是现在我想迁移到 android 64 然后改用 aab 格式但是当我这样做并且当我 运行 我收到错误的应用程序时: android.content.res.Resources$NotFoundException: Resource ID #0x7f04001d type #0x1c
is无效。 因为它是本机应用程序,所以我必须手动生成 R class
,我是这样做的
- 我使用 aapt.exe 创建 R.java
- 然后用 javac 我将 R.java 编译成 R$ 类
- 最后我构建了一个包含 R$ 类 的 classes.dex
我做了 2 次这个过程,一次构建 android32 dex 和 SO 库,另一次构建 android64 dex 和 SO 库
最后,我使用 bundletool-all-0.10 构建了 aab 文件。3.jar
我错过了什么?为什么使用 apk 我的过程运行良好,但使用 aab 却失败了?
Dex 文件对于 32 位和 64 位必须相同,所以你应该有一个 classes.dex 和一个资源 table (resources.arsc) 来生成。
此外,AAB 使用不同格式的资源 table,必须使用 aapt2 而不是 aapt 生成。看 https://developer.android.com/studio/build/building-cmdline#bundletool-build 所有细节。