android 报错Cannot fit requested classes in a single dex file. Try supplying a main-dex list

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

添加新的类库之后编译报错
在这里插入图片描述
解决办法:
1. 在当前项目的build.gradle里dependencies添加

implementation 'com.android.support:multidex:1.0.3'

如图
在这里插入图片描述
2.在当前项目的build.gradle文件里defaultConfig里添加

 multiDexEnabled true

如图在这里插入图片描述
3.在AndroidMainfest.xml中application下添加代码

android:name="android.support.multidex.MultiDexApplication"

如图在这里插入图片描述

三步解决,运行即可

猜你喜欢

转载自blog.csdn.net/qq_38357358/article/details/83180613