Error:com.android.dex.DexException: Multiple dex files define Landroid/suppo

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/csdn_loveQingQing/article/details/89921352

错误环境:

       

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

       早上打开AS,神奇报错

       Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. > java.

       Error:com.android.dex.DexException: Multiple dex files define Landroid/suppo

      还有这种-->

       ':app:transformDexArchiveWithE 

      为什么不能提出来完整的报错呢,因为这个问题已经解决。

      

错误解决方法:

       网络上各种提示,

       有MultiDex的提示,让你继承application重写分包方法的

 @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

        有在app下的build.gradle文件中添加分包声明的:

compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.salesmanservice"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true//添加这句
        //        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    //添加下面这句
    dexOptions {
        javaMaxHeapSize "4g"
    }

       但是,作为常年伏案开发的你们来说,这些你们不知道?

       所以,更换sdk得版本: 27

    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.salesmanservice"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }

       然后就是不停的clean, rebuild  重复,重复,再重复……

       温馨提示:在陪UI妹子聊天的同事去clean有效果加成……

    

       为什么更改版本为27之后问题就不存在,特别是对databinding的引用问题上,有待研究,

如果您知道,请告知:

      QQ群: 88627109

      珍重

猜你喜欢

转载自blog.csdn.net/csdn_loveQingQing/article/details/89921352