gpt4 book ai didi

android - 如何导出 AAR 及其依赖项?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:03:17 34 4
gpt4 key购买 nike

我有一个使用 library.aarlibrary.jar 的 Android Studio 库项目。当我将它导出为 mylib.aar 并将这个新的 AAR 用于不同的应用程序/项目时,它找不到 library.aarlibrary 中定义的类.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')
}

我使用 New -> Module -> Import .JAR or .AAR Package 在 Android Studio 中导入了 AAR 和 JAR 文件,并将它们作为依赖项添加到 Project Structure -> Module Settings -> 依赖项 -> 添加模块依赖项

当我解压缩 mylib.aar 时它只有 25KB(考虑到 library.aar 超过 300KB,我假设 mylib.aar 的大小将在同一范围内)并且包含的​​依赖项不包含在其中。如何导出一个包含所有依赖项的 AAR?

最佳答案

你必须检查this answer :

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.

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).

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.

关于android - 如何导出 AAR 及其依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29640719/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com