Building .apk and .aar library from same project

2019-07-05 02:09发布

问题:

is it possible to build an apk and an aar library with gradle from the same project source? Challenge is to modify the build.gradle so that both products will be built. Do you have any advice?

回答1:

Finally, Gradle offers me a really simple solution for this issue: I've created a multi module project with Android Studio and Gradle (see http://www.petrikainulainen.net/programming/gradle/getting-started-with-gradle-creating-a-multi-project-build/). One module for the app (Android Application Project) and one for the library (Android Library Project).

After moving all sources, that belong to the library, to the library project, I'm able to build the .aar file and the .apk file (which uses also sources from the library project, no problem thanks to the multi module project).