To run dex in process, the Gradle daemon needs a larger heap. It currently has 1024 MB. For faster builds, increase the maximum heap size for the Gradle daemon to at least 1536 MB. To do this set org.

andorid studio 运行正常,通过命令行react-native run-android 报错。
如图:


To run dex in process, the Gradle daemon needs a larger heap. It currently has 1024 MB. For faster builds, increase the maximum heap size for the Gradle daemon to at least 1536 MB. To do this set org._第1张图片
android1024.png

解决:
1:app下build.gradle修改

  defaultConfig {
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0.1"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        multiDexEnabled true
    }
    dexOptions {
        javaMaxHeapSize "2g"
        preDexLibraries = false;
    }

2:项目目录下gradle.properties添加

org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2560m 

至于2560这个数字根据它提示的修改。
然后编译同步gradle
react-native run-android.
成功。

你可能感兴趣的:(To run dex in process, the Gradle daemon needs a larger heap. It currently has 1024 MB. For faster builds, increase the maximum heap size for the Gradle daemon to at least 1536 MB. To do this set org.)