【发布时间】:2020-07-20 06:14:50
【问题描述】:
我有一个 android 基础项目,其中有一些可重用的模块,以便我可以在任何项目中使用它们,我有 4 个模块依赖项,例如 -
- 模块一
- 模块二
- 模块三
- 模块四
我在 moduleThree 的 gragle 中定义的地方 -
implementation project(':moduleOne')
implementation project(':moduleTwo')
implementation project(':moduleFour')
这意味着我正在使用 moduleThree 中的所有 3 个模块。
在我的项目 gradle 文件中,我已经这样定义了 -
implementation project(':moduleOne')
implementation project(':moduleTwo')
implementation project(':moduleThree')
implementation project(':moduleFour')
在我的应用程序的 setting.gradle 文件中 -
include ':app', ':moduleOne', ':moduleTwo', ':moduleThree', ':moduleFour'
所以到目前为止,我在我的应用程序中将其用作模块,因此我必须复制文件夹,然后将其粘贴到我的原始项目中。我发现这是一项乏味的工作,所以我决定创建一个 aar 文件并直接在我的项目中使用它们。
但是当我将所有四个 aar 都放入我的项目 B 中时,我无法访问它的资源文件,它引发了一些异常 - Android 资源链接失败。喷射。 我试过了
- 清理项目
- 使缓存失效并重新启动
- 重建项目
- 删除构建文件夹
所以我的问题是除了提供我只想提供 aar 文件的所有模块,然后任何项目都可以将它们添加为依赖项。我已经生成了 aar 文件,但运行项目时遇到问题 -
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:TagsEditText="http://schemas.android.com/apk/res-auto"
android:id="@+id/sv_scan_description"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.example.moduleThree.ui.TagsEditText
android:id="@+id/tagsEditText"
style="@style/TextEditTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
TagsEditText:tagsBackground="@drawable/send_to_email_bg"
---/>
</ScrollView>
AAPT:错误:找不到属性 tagsBackground(又名 com.example.myproject:tagsBackground)。
注意-生成的 Aar 文件是 moduleOne-debug.aar 和 moduleOne-release.aar,我将第一个版本重命名为 moduleOne.aar 并在项目中使用。还好吗?
【问题讨论】:
标签: android gradle aar android-module