‘:app:mergeDebugAssets‘. :app:debugRuntimeClasspath

一,报错内容

Could not determine the dependencies of task ‘:app:mergeDebugAssets’.

Could not resolve all task dependencies for configuration ‘:app:debugRuntimeClasspath’.
Could not find com.facebook.react:react-native:0.62.2.

主要是因为eact-native-community相关的一系列库,因为版本问题,链接不上.
我的react native版本是0.62.2.
具体的报错截图如下:
‘:app:mergeDebugAssets‘. :app:debugRuntimeClasspath_第1张图片

二,解决方案

在andriod的文件夹下,修改build.gradle配置,增加:

 // Top-level build file where you can add configuration options common to all sub-projects/modules.
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())

allprojects {
    //...其他配置
    configurations.all {
        resolutionStrategy {
            // Remove this override in 0.65+, as a proper fix is included in react-native itself.
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
        }
    }
}

参考文章:
https://stackoverflow.com/questions/74430295/could-not-find-any-matches-for-com-facebook-reactreact-native-as-no-version

你可能感兴趣的:(前端报错,前端)