简体   繁体   English

没有依赖项的create.aar文件

[英]create.aar file without dependencies

I am trying to create .aar file from Android Studio. 我正在尝试从Android Studio创建.aar文件。 The code I have written needs appcomapt v7 library. 我编写的代码需要appcomapt v7库。 I don't want to add the dependency in the build.gradle file of my aar package but want it to take from the project it is added. 我不想在我的aar软件包的build.gradle文件中添加依赖项,但希望它从添加的项目中获取。 Please suggest how to do it ? 请提出建议怎么做?

Thanks. 谢谢。

You need to add it to your library module to use all the classes that Android needs, if your library doesn't use any of those classes, then you can make a jar library. 您需要将其添加到库模块以使用Android所需的所有类,如果您的库不使用这些类中的任何一个,则可以创建一个jar库。

Now, when you compile your library in the app module, you can exclude the library dependency adding this to the compile line 现在,当您在应用程序模块中编译库时,可以排除库依赖项并将其添加到编译行中

compile('com.yourpage:yourlibrary:1.0.0'){
     exclude module: 'appcompat-v7'
}

I don't want to add the dependency in the build.gradle file of my aar package 我不想在我的aar包的build.gradle文件中添加依赖项

You have to include it there, otherwise you can not compile your aar 您必须在其中包含它,否则您将无法编译aar

but want it to take from the project it is added 但希望它从项目中提取

You can still do that: 您仍然可以这样做:

If your library declares appcompat-v7 version 23 and your app does not declare appcompat-v7 , version 23 will be used in your app. 如果您的库声明了appcompat-v7版本23而您的应用程序未声明appcompat-v7 ,则将在您的应用程序中使用版本23

If your library declares appcompat-v7 version 23 and your app declares appcompat-v7 version 24 , version 24 will be used in your app. 如果您的库声明了appcompat-v7版本23而您的应用程序声明了appcompat-v7版本24 ,则将在您的应用程序中使用版本24

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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