近日升级到react native0.49版本后 android studio升级到了3.0开发版, gradle从2.14升级到4.1版本,支持android8.0,
打包的时候出现异常:
Error:The number of method references in a .dex file cannot exceed 64K.
Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_77\bin\java.exe'' finished with non-zero exit value 2‘’?
build.gradle下面添加:
defaultConfig{
.....
multiDexEnabled true
.....
}
dexOptions{
preDexLibraries = fales
jumboMode true
javaMaxHeapSize "2g"
}
dependencies{
.....
compile 'com.android.support:multidex:1.0.1'
......
}
MainApplication需要改的地方:
导包:
import android.support.multidex.MultiDex;
重新实现一个方法:
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this):
}