Reputation: 21
I see a lot of dependencies, when I create an android studio project. So I decided to remove the ones, I believe are not being used. I am wondering, what are these dependencies used for, and are they safe to remove?
my build.gradle looked like this (Navigation View Activity)
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
and after removing the 'unused' dependencies, I am left with:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
My app compiles, and runs fine after removing those. Are they really useless?
Upvotes: 0
Views: 346
Reputation: 7683
Let's go through each of them:
Espresso
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
This is a testing library. It lets you write automated tests which run through your app as a user might and test for certain conditions. Note the androidTestCompile
- this means that it only gets included when you compile your app for automation testing and not when you do a normal compile
Constraint Layout
compile 'com.android.support.constraint:constraint-layout:1.0.2'
This is the new ViewGroup
which Google is now recommending that you use instead of RelativeLayout
. It is much more flexible and can lead to performance improvements on very complicated layouts. You are not required to use it if you don't want to though.
JUnit
testCompile 'junit:junit:4.12'
This is another testing library. This one is used for running unit tests. Again notice the testCompile
- this library will only be included in builds done for running unit tests and won't be included in your app when you do a normal compile.
Summary
None of the libraries is useless. However it may be that you don't need any of them for your purposes. For both the test libraries you can safely leave the dependencies in place and it won't affect your actual app compile.
Upvotes: 0
Reputation: 5020
Neither of dependencies is actually mandatory to compile and run an Android application. Android Studio just puts some dependencies, which a developer will likely use in every project.
Here is the list of the dependencies you have removed:
'com.android.support.test.espresso:espresso-core:2.2.2' - the Espresso testing framework, that provides APIs for writing UI tests. Only required if you are going to write UI tests for your application;
'junit:junit:4.12' - the JUnit testing framework for write your unit or integration tests. Not required if you are not going to write any tests;
'com.android.support.constraint:constraint-layout:1.0.2' - a ViewGroup, which allows you to create large and complex layouts with a flat view hierarchy (no nested view groups). This dependency is required if you want to use ConstraintLayout in your project. If you don't need it, you can delete this dependency.
Upvotes: 1
Reputation: 2209
The librarie removed concern ConstraintLayout , a way to create layout more easely with the graphic interface of AndroidStudio.
And the the libraries to create Unit and UI test.
They are not indispensable, but they are not useless as well. In fact you haven't a this point a lot of dependencies.
Sorry for my english.
Hope this help.
Upvotes: 0