React Native Android Release Build Failing - Gradle

后端 未结 2 1812
南旧
南旧 2021-02-04 12:34

I\'ve got a rather complicated project some of which is older code from the past year or so which in React Native time is forever. The regular debug build is working fine but th

相关标签:
2条回答
  • 2021-02-04 13:03

    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.

    0 讨论(0)
  • 2021-02-04 13:17

    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
                }
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题