Reputation: 3673
I have a library project which is using androidx
dependency in it.
implementation 'androidx.appcompat:appcompat:1.0.0-rc01'
After adding library project in my app, i am getting multiple errors related to dexMerger
, MultiDex
, Multiple dex files define Landroid/support/v4/...
.
So i searched for that file by using window+O
(Navigate --> Class). Then i found that same class is used in 'androidx.appcompat:appcompat:1.0.0-rc01'
and android.support.v4..
libraries . So I tried to exclude like below -
implementation('androidx.appcompat:appcompat:1.0.0-rc01') {
exclude module: 'support-v4'
}
Also i have added multidex true
but nothing helped. I read about AndroidX
looks like it contains many classes that are similar to support libraries. What should be done in this case ? I have latest version of Android Studio and my compileSdkVersion
is 28
. My all dependencies are up to date.
I have already added multidex
dependency and my application class is also extending MultiDexApplication
.
Upvotes: 3
Views: 2396
Reputation: 1969
Use the Following Command to check which dependency has duplicate class
./gradlew app:dependencies
Then Exclude the module like this
{
exclude group: 'com.android.support'
}
Hope this will solve your problem! Let me know if you have any issues!
Upvotes: 1
Reputation: 192
try
android {
dexOptions {
preDexLibraries = false
}
}
Upvotes: 0
Reputation: 14825
Just setting the multidex true
is not enough.
You need to include this dependency first
implementation 'com.android.support:multidex:1.0.3'
then
defaultConfig {
...
multiDexEnabled true
}
then in ur manifest
<application
android:name="android.support.multidex.MultiDexApplication" >
...
</application>
Upvotes: 1