Multiple dex files define Landroid/support/design/widget/CoordinatorLayout$LayoutParams

Android多dex处理,按照谷歌官方文档https://developer.android.com/studio/build/multidex处理方式依然报错

    android {
        defaultConfig {
            ...
            minSdkVersion 15
            targetSdkVersion 28
            multiDexEnabled true
        }
        ...
    }

    dependencies {
      implementation 'com.android.support:multidex:1.0.3'
    }
    
    public class MyApplication extends SomeOtherApplication {
      @Override
      protected void attachBaseContext(Context base) {
         super.attachBaseContext(base);
         MultiDex.install(this);
      }
    }
    

原因是 com.android.suppert:design:26.1.0 的版本过低不支持多Dex处理

如下

compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:mediarouter-v7:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:support-v13:26.1.0'
compile 'com.android.support:support-v4:26.1.0'

更新升级更改为

compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support:design:27.1.0'
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support:mediarouter-v7:27.1.0'
compile 'com.android.support:recyclerview-v7:27.1.0'
compile 'com.android.support:cardview-v7:27.1.0'
compile 'com.android.support:support-v13:27.1.0'
compile 'com.android.support:support-v4:27.1.0'

 

你可能感兴趣的:(Android开发技巧)