Androidstudio 3.1.2版本
Android项目植入unity项目中,出现这个问题

主要原因:
Android 的 classLoader
在加载 APK 的时候限制了class.dex
包含的 Java 方法数,其总数不能超过65535(64K,不要再说成 65K 了,1K = 2^10 = 1024 , 64 * 1024 = 65535),Google 官方给出的解决方案是使用Multidex 。
解决方案:
在app的build.gradle
defaultConfig {
multiDexEnabled true
}

在application中,加入代码,进行初始化
public class XXX extends Application{
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
网友评论