Nongthonbam Tonthoi
Nongthonbam Tonthoi

Reputation: 12963

Why is Android Studio generating duplicate gradle dependency automatically?

I am using Android Studio 2.3.3 on Windows 10. I already have these in my dependencies:

compile 'com.android.support:recyclerview-v7:25.4.0'
compile 'com.android.support:cardview-v7:25.4.0'
compile 'com.android.support:customtabs:25.4.0'
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:design:25.4.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:25.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'

But these lines are always auto generated in gradle file:

dependencies {
    compile 'com.android.support:support-v4:25.+'
}
dependencies {
    compile 'com.android.support.constraint:constraint-layout:+'
}
dependencies {
    compile 'com.android.support.constraint:constraint-layout:+'
}

Gradle Version: 3.3 Android Plugin Version: 2.3.3

How do it stop Android Studio from generating these unnecessary dependencies and why is it doing so?

Upvotes: 2

Views: 118

Answers (1)

Nongthonbam Tonthoi
Nongthonbam Tonthoi

Reputation: 12963

For those who are also facing this.

I have found out that whenever we create an Activity using the Activity creation wizard with

New -> Activity

this line:

dependencies {
    compile 'com.android.support.constraint:constraint-layout:+'
}

is added automatically to build.gradle file.

And

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

is added automatically whenever we create a Fragment using

New -> Fragment

Even if dependencies are already added.

I have not found any solution to prevent it so for now I am removing those manually after the Activity/Fragment are created.

Upvotes: 1

Related Questions