异常:
Cannot fit requested classes in a single dex file. Try supplying a main-dex list. # methods: 99706 > 65536 Message{kind=ERROR, text=Cannot fit requested classes in a single dex file. Try supplying a main-dex list. # methods: 99706 > 65536, sources=[Unknow
翻译:这个报错是因为你的项目里单个dex文件的函数超过了65536个
无法在单个DEX文件中匹配请求的类。尝试提供主DEX列表。方法:99706>65536消息{Type=Error,Text =不能在单个DX文件中匹配请求的类。尝试提供主DEX列表。方法:99706>65536,来源= [未知]、、
原因:Android系统定义总方法数是一个short int,short int 最大值为65536。
解决:
1.在Android的模块gradle文件的defaultConfig默认配置里面增加:
defaultConfig {
multiDexEnable true
}
2.同时还需在dependencies里面增加:
implementation 'com.android.support:multidex:1.0.3'
3.另外需要把AndroidMainfest.xml里面添加自定义的App继承自MultiDexApplication。
因为MultiDexApplication也是继承Application的。