apply plugin: 'android' or apply plugin: 'com.android.application'
Asked Answered
F

2

45

As in topic. Gradle require to set up plugin and there are times that it is mentioned to apply plugin: 'android', and other to apply plugin: 'com.android.application' .

What are the differenceres? Which one should be used ?

Flowering answered 7/12, 2014 at 12:9 Comment(0)
D
58

apply plugin: 'android' specifies that It's an Android project but it does not specify Its an Application or Library project. To make life easier you can tell gradle the type of project and indicate which plugin should be used. I recommend to use apply plugin: 'com.android.application' if project is an app and apply plugin: 'com.android.library' if project is a lib. It helps gradle to compile project efficiently.

Click here for detailed explanation -

Dunnite answered 7/12, 2014 at 12:21 Comment(4)
"apply plugin: 'android' specifies that It's an Android project but it does not specify Its an Application or Library project" -- yes, it does. It was apply plugin: 'android-library' for library projects.Hutchinson
Yes but we were still be able to create libs by using apply plugin: 'android'. But in newer (and better) approach you can't create a lib while using apply plugin: 'com.android.application. You have to use apply plugin: 'com.android.libraryDunnite
Where should I find the source of this information? I cannot find it anywhere in the internet.Liam
The answer is pretty good, but ATM the linked gradle guide plugins page says absolutely nothing about android plugin working with 'android' vs 'com.android.library'. A complete answer would tell something about when was 'com.android.application' introduced and if 'android' is scheduled for retirement.Liaison
H
17

Which one should be used ?

apply plugin: 'com.android.application'

What are the differenceres?

They renamed the plugin to comply with the naming convention that Gradle is starting to adopt for plugins, with an eye towards a new plugin system in future versions of Gradle.

Hutchinson answered 7/12, 2014 at 12:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.