近日升級到react native0.49版本后 ?android studio升級到了3.0開發(fā)版殿如, gradle從2.14升級到4.1版本,支持android8.0涉馁,
打包的時候出現(xiàn)異常:
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需要改的地方:
導(dǎo)包:
import android.support.multidex.MultiDex;
重新實現(xiàn)一個方法:
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this):
}