【问题标题】:gradle build with AAR failed with No resource found errorgradle build with AAR failed with No resource found 错误
【发布时间】:2015-03-12 14:23:38
【问题描述】:

我在项目中有两个模块。

  • app - 那是我的应用模块
  • app-base - 这是我的应用使用的 android 库模块。

当我使用构建工具 21 和 gradle android 插件 1.1.1 构建时 有以下依赖,它会失败。

compile 'com.company.android:app-base:1.0.0@aar'

我通过以下命令将 app-base aar 部署到公司 sonatype Nexus。

gradle uploadArchives

错误信息如下:

:app:processCustomAppDebugResources
 Position 34:21-35 : No resource found that matches the given name: attr 'actionBarStyle'.
 Position 34:21-35 : No resource found that matches the given name: attr 'actionBarStyle'.
 Position 37:29-51 : No resource found that matches the given name: attr 'windowActionBarOverlay'.
 Position 29:21-36 : No resource found that matches the given name: attr 'windowActionBar'.
 Position 1 : Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
 Position 1 : Error retrieving parent for item: No resource found that matches the given name '@style/Widget.AppCompat.ActionBar.Solid'.
 Position 19:21-44 : No resource found that matches the given name: attr 'actionBarItemBackground'.
 Position 7:21-31 : No resource found that matches the given name: attr 'background'.
 Position 17:21-45 : No resource found that matches the given name: attr 'selectableItemBackground'.
 Position 14:32-46 : No resource found that matches the given name: attr 'titleTextStyle'.
 Position 7:21-31 : No resource found that matches the given name: attr 'background'.
 Position 1 : Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
 Position 1 : Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.

:app:processCustomAppDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processCustomAppDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/service/android/default/sdk/build-tools/21.0.0/aapt'' finished with non-zero exit value 1

要成功构建它,我只需要删除相同依赖项上的@aar。

compile 'com.company.android:app-base:1.0.0'

有人能解释一下为什么会这样吗?使用 AAR 依赖与不使用有什么区别?

【问题讨论】:

  • 我也有这个问题?使用remote aar的时候会报错,如果我把这个aar下载为本地文件就可以了。你解决了吗?
  • @Carl,我不确定您的问题是什么,但就我而言,我确实删除了依赖配置中的“@aar”。 “@aar”不会传播对该 AAR 模块的依赖。我想知道你是如何定义你的应用程序模块的 AAR 文件依赖关系的。
  • 我正在将项目从sub-modlue更改为依赖aar,在我们公司的maven server.so发生了这个问题。
  • @Carl,如果你定义compile 'com.yourcompany.android:your-applib-aar:1.0.0',那么它会抛出错误?
  • 是的,现在我已经解决了这个问题。我只是清理了我的PC中的.m\repository\myuseAAR,因为第一次构建使用arr有错误,之后构建将使用本地存储库。

标签: android android-gradle-plugin aapt


【解决方案1】:

这些参数来自 Android 支持库。您是否已将 Android 支持库包含在您的依赖项列表中?

compile 'com.android.support:appcompat-v7:21.0.3'

【讨论】:

  • 我想抓东西,它是在 app-base 而不是 app 模块中声明的。所以@AAR 依赖使不传播来自应用程序基础模块的依赖关系?
  • 是的。 app 模块从 app-base 传播依赖关系,但反之则不然。在您的情况下,您要将 app-base 模块编译为 aar 文件,因此只编译 app-base 模块。您还必须在 app-base 模块中声明依赖项。
猜你喜欢
  • 2021-04-17
  • 1970-01-01
  • 2020-11-06
  • 1970-01-01
  • 2019-05-12
  • 2019-06-11
  • 2021-09-04
  • 1970-01-01
  • 2015-06-05
相关资源
最近更新 更多