‘: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.
具体的报错截图如下:
请添加图片描述

二,解决方案

在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

猜你喜欢

转载自blog.csdn.net/weixin_42349568/article/details/131848486
app