简体   繁体   中英

How can I use the dependency of the aar in Android Studio?

I have a problem of using aar package in Android Studio Project. Yesterday I wrote a Android Studio library called xEditText , adding a dependency like this:

compile com.nineoldandroids:library:2.4.0

and then I build this library to an aar package. When I use this aar package in my project like this:

compile xEditText-release

and run,I found it crashed,it was an 'Error inflating class' error.Later I got the answer,when I add the compiling in my project like this:

compile com.nineoldandroids:library:2.4.0

it runs well.

But I don't know why that I have to compile the dependency com.nineoldandroids:library:2.4.0 what had compiled in my library to my project again?

But I don't know why that I have to compile the dependency(com.nineoldandroids:library:2.4.0) what had compiled in my library to my project again?

Because xEditText is a library, nineoldandroids becomes the transitive dependency for any project which uses xEditText . Transitive dependencies are not icnluded in the output aar file by default.

You can fix this behavior by specifying that nineoldandroid should be included in the xEditText like so:

compile ('com.nineoldandroids:library:2.4.0') {
    transitive = true
}

您可以将aar-Files添加为模块:文件 - >新建 - >新模块 - >导入.JAR或.AAR包。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM