Android的工作室如何打包多个库项目单AAR? [英] Android Studio how to package single AAR from multiple library projects?

查看:1887
本文介绍了Android的工作室如何打包多个库项目单AAR?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立的Andr​​oid库项目,这对另一个内部库项目的依赖。

我想知道是否有一种方法来包装一个AAR库,其中已经包含了内部库里面。我想和大家分享只有1 AAR库包到我的应用程序的开发者。

这是我build.gradle文件怎么看当前,但目前他们生产的单独的AAR文件,既需要包括在应用程序的build.gradle。随着应用程序正由另一家公司建造,我们需要分享最后的AAR文件,他们,而不是完整的库项目。

----- internalLib -------- >>>>>>>>>>

  buildscript {
    库{
        mavenCentral()
    }
    依赖{
        类路径com.android.tools.build:gradle:0.7.+
    }
}
应用插件:机器人库

库{
    mavenCentral()
}

安卓{
    compileSdkVersion 18
    buildToolsVersion '18 .1.1
}

依赖{
    编译com.android.support:support-v4:18.0.0
}
 

----- externalLib --------

  buildscript {
    库{
        mavenCentral()
    }
    依赖{
        类路径com.android.tools.build:gradle:0.7.+
    }
}
应用插件:机器人库

库{
    mavenCentral()
}

安卓{
    compileSdkVersion 18
    buildToolsVersion '18 .1.1
}

依赖{
    编译com.android.support:support-v4:18.0.0
    编制项目(:internalLib)
}
 

解决方案

没有任何机制来组合库。这是一个有点复杂,因为你可能想控制哪些依赖关系得到合并(比如你可能不希望包括支持-V4在那里)。另外你需要合并的资源和Android清单。

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

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

提供了一个内置的机制,这是非常低的在我们优先考虑的,所以不要指望它很快。

I am building android library project, which has a dependency on another internal library project.

I am wondering if there is a way to package a single AAR library, which already contains internal library inside it. I would like to share only 1 AAR library package to my application developers.

This is how my build.gradle files look currently, but currently they produce separate AAR files and both needs to be included in Application's build.gradle. As application is being built by another company, we need to share the final AAR file with them and not the complete library projects.

----- internalLib -------->>>>>>>>>>

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.7.+'
    }
}
apply plugin: 'android-library'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 18
    buildToolsVersion '18.1.1'
}

dependencies {
    compile 'com.android.support:support-v4:18.0.0'
}

----- externalLib --------

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.7.+'
    }
}
apply plugin: 'android-library'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 18
    buildToolsVersion '18.1.1'
}

dependencies {
    compile 'com.android.support:support-v4:18.0.0'
    compile project(':internalLib')
}

解决方案

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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