使用AAR的gradle构建失败,找不到资源错误

时间:2015-03-12 14:23:39

标签: android android-gradle aapt

我在项目中有两个模块。

  • 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依赖或不使用它有什么区别?

1 个答案:

答案 0 :(得分:0)

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

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