多AAR文件 [英] Multiple AAR files
问题描述
我使用的Android 1.2工作室
I am using Android Studio 1.2
我创建了一个私人图书馆我想用一个在另一个应用程序。
I create a private library I want to use that one in another application.
要使用它,我创建一个AAR文件,但这个AAR不起作用。我在我的库的依赖性,以一个AAR文件。
To use it I create an AAR files, but this AAR don't work. I have in my library a dependency to an AAR file.
的AAR文件不依赖?
如果我用的罐子,我答大型的源码创建所有依赖项目的正常工作。
If I use the jar and I includ ans create all the dependencies the project works fine.
注意:
我知道如何importe的AAR文件。问题是在AAR的使用一个AAR ..
I know how to importe the AAR file. The problem is to use an AAR in the AAR..
感谢。
推荐答案
如果我正确理解你的问题,也有涉及3个项目:
If I'm understanding your question correctly, there are 3 projects involved:
图书馆计划2 - >库项目1 - >应用程序项目
Library Project 2 --> Library Project 1 --> Application Project
您正在编辑库项目1,并加入到它的应用程序/ build.grade在图书馆计划2的AAR的依赖。事情是这样的:编译com.arasthel:gnavdrawer库:1.1.5
You are editing "Library Project 1" and have added to it's app/build.grade a dependency on the Library Project 2's aar. Something like this: compile 'com.arasthel:gnavdrawer-library:1.1.5'
我不知道,你正在运行到一个问题,但无论如何,我会尝试回答。如果我完全关闭基地,可以请你阐述一下AAR的依赖是如何不工作?任何错误讯息?一类/资源没有发现,等。
I am not sure where you are running into an issue, but I'll attempt an answer anyway. If I'm completely off-base, can you please elaborate on how the AAR dependency is not working? Any error messages?, a class/resource not found, etc.
我认为这是不可能的,你无法用一个类从库项目2图书馆项目1里面,因为我只是尝试这样做我自己,它似乎工作得很好。值得注意的是,库项目1 AAR文件将不会包含类或资源于图书馆计划2.图书馆项目2 会注意,如果在图书馆项目1的POM的依赖的gradle使用的Maven插件发布库项目1发布。
I think it's unlikely you are unable to use a class from Library Project 2 inside Library Project 1, because I just tried this myself and it seems to be working just fine. It's worth noting that the Library Project 1 aar file will NOT include classes or resources from Library Project 2. Library Project 2 will be noted as a dependency in Library Project 1's pom if published using gradle's maven plugin to publish Library Project 1.
我的猜测是,您有在应用程序项目的问题吗?或许从图书馆项目2类未在应用程序项目发现了什么?
如果这是正确的,那么有两种可能的解决方案:
My guess is that you are having a problem in the Application Project? Perhaps the class from Library Project 2 is not found in the Application Project? If that is correct, then there are two possible solutions:
-
启用在应用程序项目的应用程序/的build.gradle的AAR依赖的传递性依赖:与其
编译com。示例:在MyLibrary:versionX
,使它编译('com。示例:在MyLibrary:versionX'){传递=真}
。我只是证实了这一导致gradle这个读库项目1的POM并自动添加在那里发现到应用程序项目的依赖关系。
Enable transitive dependencies on the aar dependency in the Application project's app/build.gradle: Instead of
compile 'com.example:myLibrary:versionX'
, make itcompile('com.example:myLibrary:versionX'){transitive=true}
. I just verified this causes gradle to read Library Project 1's pom and automatically add dependencies found there into the Application Project.
如果你想使用传递依赖,库项目将需要生成聚甲醛,并与AAR一起出版它。请参见 http://stackoverflow.com/a/30085677/431296 了解我如何有这样的工作一些额外的信息。
If you would like to use transitive dependencies, your Library Project will need to be generating a pom and publishing it along with the aar. See http://stackoverflow.com/a/30085677/431296 for some additional information on how I have this working.
手动图书馆项目2项中添加依赖于应用程序项目 - 使你的应用程序有两个库的依赖行。根据您的具体情况,这可能是也可能不是一个可行的解决方案。
Manually add the dependency on Library Project 2 to the Application Project - so that your Application has a dependency line for both Libraries. Depending on your specific situation this may or may not be a workable solution.
这篇关于多AAR文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!