React Native Android Release Build Failing - Gradle

送分小仙女□ 提交于 2019-12-03 02:59:32

Building upon GenericJam's answer, you can do this programatically to all sub libraries by doing something like this in your project build.gradle file:

subprojects { subproject ->
    afterEvaluate{
        if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

The way to solve this that worked for me is to dive into the node_modules code for the supporting libraries that are triggering the error.

You will need to go into node_modules/project-name/android/build.gradle and change this

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    ...
}

to whatever the sdk version is in your /android/app/build.gradle is. For example:

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.1"
    ...
}

Hopefully this will be fixed in React Native so this workaround isn't necessary.

Edit: I suspect Petter's solution is the better one although I haven't tried it myself. Probably try that one first and if it doesn't work, try this next.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!