Nice programing

Android Studio 여러 라이브러리 프로젝트에서 단일 AAR을 패키징하는 방법은 무엇입니까?

nicepro 2021. 1. 8. 22:51
반응형

Android Studio 여러 라이브러리 프로젝트에서 단일 AAR을 패키징하는 방법은 무엇입니까?


다른 내부 라이브러리 프로젝트에 대한 종속성이있는 Android 라이브러리 프로젝트를 구축 중입니다.

내부 라이브러리가 이미 포함 된 단일 AAR 라이브러리를 패키징하는 방법이 있는지 궁금합니다. 응용 프로그램 개발자에게 하나의 AAR 라이브러리 패키지 만 공유하고 싶습니다.

이것이 현재 내 build.gradle 파일의 모습이지만 현재는 별도의 AAR 파일을 생성하며 둘 다 응용 프로그램의 build.gradle에 포함되어야합니다. 다른 회사에서 애플리케이션을 구축하고 있으므로 전체 라이브러리 프로젝트가 아닌 최종 AAR 파일을 해당 회사와 공유해야합니다.

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

ReferenceURL : https://stackoverflow.com/questions/20700581/android-studio-how-to-package-single-aar-from-multiple-library-projects

반응형