如何导出AAR包括它的依赖? [英] How to export AAR including its dependencies?

查看:987
本文介绍了如何导出AAR包括它的依赖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 library.aar library.jar 一个Android工作室库项目。当我出口为 mylib.aar 并使用这个新的AAR到不同的应用程序/项目,它无法找到在 library.aar定义的类 library.jar

I have an Android Studio library project which uses library.aar and library.jar. When I export it as mylib.aar and use this new AAR into a different app/project, it cannot find the classes defined in the library.aar and library.jar.

我的的build.gradle 是这样的:

apply plugin: 'com.android.library'
android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':library_dot_aar')
    compile project(':library_dot_jar')
}

我使用进口新的Andr​​oid Studio中的AAR和JAR文件 - >模块 - >导入.jar或.AAR包装和它们添加为依赖项目结构 - >模块设置 - >依赖 - >添加模块依赖

当我解压 mylib.aar 也就只有25KB(考虑 library.aar 超过300KB,我假设 mylib.aar 的规模将在同一范围内)和包括依赖性并没有包括在里面。如何导出,包括内部本身所有依赖的AAR?

When I unzipped mylib.aar it was only 25KB (considering library.aar was over 300KB, I assume mylib.aar's size would be in the same range) and the included dependencies were not included in it. How do I export an AAR that includes all its dependencies inside itself?

推荐答案

您必须检查<一href=\"http://stackoverflow.com/questions/20700581/android-studio-how-to-package-single-aar-from-multiple-library-projects\">this回答:

有任何机制来库结合起来。这是一个有点复杂,因为
  你可能想控制哪些依赖得到合并(针对
  例如,您可能不希望包括在那里支持-V4)。也
  你需要合并的资源和Android清单。

There is no mechanism to combine library. It's a bit complicated as you probably want to control which dependencies get merged (for instance you probably don't want to include support-v4 in there). Also you'd need to merge the resources and Android manifest.

在这个时候有没有办法可以轻松地破解的东西,除非你是
  确保资源有两个资源文件夹之间没有冲突(为
  例如,你可以有strings_a.xml在一个lib和strings_b.xml在
  其他的LIB)。这样,由你可以合并两种资源文件夹
  复制他们两个到同一位置(而不是在做合并
  Android的资源级别)。

At this time there's no way to easily hack something, unless you are sure the resources have no conflicts between the two res folders (for instance you could have strings_a.xml in one lib and strings_b.xml in the other lib). This way you can just "merge" the two res folders by copying them both into the same location (as opposed to do a merge at the android res level).

有关舱单它会更复杂,但也有一些自定义的可行
  code。

For the Manifest it'd be more complicated, but doable with some custom code.

提供一个内置的机构,这是非常低的在我们的优先级,以便
  不要指望它很快。

Providing a built-in mechanism for this is very low on our priority so don't expect it anytime soon.

这篇关于如何导出AAR包括它的依赖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆