APT: error: attribute (aka com.mylib:attr_test) not found

94 阅读1分钟

问题描述

module最终编译是AAR,module有使用其他AAR提供的属性,编译时报找不到其他AAR中的属性

问题原因

未正确引入AAR,所以导致找不到属性

解决方案

没有正确引入AAR,可按照下述方法引入

1.在module libs下新建build.gradle

//module/libs/build.gradle
configurations.maybeCreate("default")
dependencies.add("default", files(
        'aar1.aar', 'aa2.aar'))

2.在module build.gradle中加入依赖

// module/build.gradle
dependencies {
    implementation project(":module:libs")
}

附module/libs/build.gradle中使用dependencies与artifacts区别:
A project generally has a number of dependencies it needs in order to do its work. Also, a project generally produces a number of artifacts, which other projects can use 参考docs.gradle.org/current/dsl…