无法解析 com.facebook.react:react-native:0.32.0

2024-03-14

我在 android studio 的 React Native 项目中打开了 android 文件夹,做了所有可能的修改build.gradle文件。但是我收到这个重复的错误:

Error:Failed to resolve: com.facebook.react:react-native:0.32.0  

My package.json如下:

{
  "name": "empty-project-template",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios"
  },
  "dependencies": {
    "eslint": "^3.17.0",
    "expo": "^30.0.1",
    "react": "^16.4.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz",
    "react-native-elements": "^0.19.1",
    "react-native-vector-icons": "^4.2.0",
    "react-router": "^4.3.1"
  }
}   

我的 gradle 文件是:

apply plugin: "com.android.application"

import com.android.build.OutputFile

/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations
 * and their defaults. If you decide to add a configuration block, make sure to add it before the
 * `apply from: "../../node_modules/react-native/react.gradle"` line.
 *
 * project.ext.react = [
 *   // the name of the generated asset file containing your JS bundle
 *   bundleAssetName: "index.android.bundle",
 *
 *   // the entry file for bundle generation
 *   entryFile: "index.android.js",
 *
 *   // whether to bundle JS and assets in debug mode
 *   bundleInDebug: false,
 *
 *   // whether to bundle JS and assets in release mode
 *   bundleInRelease: true,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // the root of your project, i.e. where "package.json" lives
 *   root: "../../",
 *
 *   // where to put the JS bundle asset in debug mode
 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
 *
 *   // where to put the JS bundle asset in release mode
 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in debug mode
 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in release mode
 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
 *
 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
 *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
 *   // for example, you might want to remove it from here.
 *   inputExcludes: ["android/**", "ios/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"],
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 27
    buildToolsVersion '28.0.2'

    defaultConfig {
        applicationId "com.sampleprojecttemplate"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:27.1.1"
    implementation "com.facebook.react:react-native:0.32.0"   // From node_modules
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

我该如何解决这个错误?我尝试过:

implementation "com.facebook.react:react-native:+"  

但这并没有成功。


很奇怪你使用了来自expo的react-native的打包版本...最重要的是你的package.json似乎指向版本0.30?相当过时,当前的 RN 版本是 0.57.2

当对我的构建配置(android 上的 package.json、build.gradle、iOS 上的 podfile 或工作区/项目设置)有疑问时,我使用 React-native-cli 创建一个虚拟的 React-Native 项目,并比较用我的创建的项目。

  • 安装react-native-cli:npm install -g react-native-cli
  • 创建一些测试项目react-native init testProject
  • 查看package.json、build.gradle,看看与你自己的文件的差异

然后,修复构建:

  • 更新dependenciespackage.json、grade.build 的部分

  • 对 package.json 的任何更改都需要npm install(有时带有rm -rf node_modules之前,清理所有节点依赖项)。另外,请确保在键入该命令时关闭任何可能保留文件缓存版本的 IDE(XCode、Android Studio)

你绝对应该更换implementation "com.facebook.react:react-native:0.32.0" with implementation "com.facebook.react:react-native:+"

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法解析 com.facebook.react:react-native:0.32.0 的相关文章

随机推荐

  • Eclipse 中的 XML 验证和自动完成

    在android SDK中 当我编辑android布局xml文件时 它可以进行验证和自动完成 这是如何运作的 如何使用我自己定义的 xml 格式使 eclipse 验证并自动完成 Eclipse 可用于编辑和验证 XML 文件 我在 Ecl
  • 如何延迟谷歌自动完成功能以节省信用

    正如你所知 每次我们输入谷歌地图自动完成功能都会触发 我想为此设置一个延迟函数 例如250毫秒 这样可以给用户更多的时间来输入并节省积分 我尝试添加 timeout 但看起来它对我不起作用 请您帮我看看这个好吗 提前致谢 网页
  • 可以跨域获取iframe的url吗?

    如果是跨域 iframe 如何在页面加载时获取 iframe 的当前 url 背景 我正在尝试在我的网站上启用 SSL 但是 我的用户需要能够通过 iframe 加载任何 url 如果他们尝试使用 http 协议加载 iframe 它将拒绝
  • 项目中不存在目标“/t:native_metrics”

    我想在我的项目上安装 newrelic 但我从控制台收到 node modules newrelic native metrics build bind ing sln metaproj error MSB4057 The target t
  • java网格包布局:避免中心对齐

    在我的 GUI 应用程序中 我有几个 JPanel 它们在程序运行期间的不同点被实例化 并且某些操作将导致其中之一显示在滚动窗格中 mViewport setViewportView currentPanel 问题是 我的面板是使用网格包布
  • Android 中 Imageview 的圆角

    我在线性布局中有一个文本视图和图像视图 Textview 位于顶部 imageview 位于底部 我使用下面的线条来实现线性布局的圆角 但 imageview 的角不是圆角的 我看到只有线性布局的顶角是圆角的 如何使 imageview 的
  • Ansible:如何从另一个变量构造一个变量,然后获取它的值

    这是我的问题 我需要使用一个变量 target host 然后将 host 附加到它的值以获取我需要其值的另一个变量名称 如果你看看我的剧本 任务 nbr 1 2 3 获取变量的值 但是 nbr 4 无法执行我所期望的操作 有没有其他方法可
  • Rails 控制台未将 SQL 语句输出到我的开发日志

    当我通过本地主机访问 Webrick 服务器时 或者当我运行 Rails 迁移时 我的development log 会被正确写入 但是 当我使用 rails c 启动 Rails 控制台 然后尝试创建一个新的数据库对象并通过 user s
  • WSO2AM - SAML - 提供的授权无效

    我正在将 WSO2AM 与我们内部专有的身份提供商 IDP 集成 我正在关注 wso2 文档 与 OAuth2 交换 SAML2 承载令牌 SAML 扩展授予类型 https docs wso2 com display AM210 SAML
  • iOS CoreLocation 检查 CLLocation 时间戳以使用它

    如何检查 CLLocation 对象并决定是要使用它还是丢弃结果并获取新的位置更新 我在 CLLocation 上看到了时间戳属性 但我不确定如何将其与当前时间进行比较 另外 在我比较时间并发现以秒为单位的差异之后 差异应该在什么值以下才能
  • 绘制并填充自定义形状

    我正在尝试使用 Android 中的 Path 对象创建自定义形状 但遇到了一个奇怪的问题 我想要实现的目标如下图所示 这是我用来绘制和填充形状的代码 public class BallView extends RelativeLayout
  • Linux 中的调度:在计算机空闲时运行任务(= 无用户输入)

    我想跑折叠 home http folding stanford edu 我的 Ubuntu 8 10 机器上的客户端仅在空闲时运行 因为该程序消耗大量 RAM 我所说的 空闲 是指没有用户活动 键盘 鼠标等 时的状态 由于 F H 具有最
  • 有 JPasswordField 的替代方案吗?

    当输入如下密码时 yeast bulk seize is shows pain 每个人都可以听到敲击空格键的声音 因此在密码字段中显示空格似乎也是合乎逻辑的 所以我想要一些能够展示的东西 代替 这将使打字变得更容易 同时几乎不会降低安全性
  • Webpack + Babel 错误

    我正在尝试配置 webpack 并让一切正常运行 但现在遇到了同样的错误 我梳理了其他一些帖子 这些帖子似乎是通过纠正拼写 语法错误来解决的 但我似乎无法找出代码中的任何错误 是不是有更严重的事情发生了 ERROR in src compo
  • 带有错误模块“main:Main”的 stack ghci 在多个文件中定义:

    我有一个小的 haskell 程序 它可以使用堆栈构建和执行 当我开始时stack ghci我收到一条错误消息 我不明白并且无法继续 GHCi version 8 10 4 https www haskell org ghc for hel
  • 来自本地的 IAM SAML 联合失败

    我在本地虚拟机中设置了 openldap 和 shibboleth idp 并在 aws 中创建了身份提供商并上传了元数据 在元数据中 url 指向我的本地 IP 地址 例如 SingleSignOnService Binding urn
  • 推导 pytorch 网络的结构

    对于我的用例 我需要能够采用 pytorch 模块并解释模块中的层序列 以便我可以以某种文件格式在层之间创建 连接 现在假设我有一个简单的模块 如下所示 class mymodel nn Module def init self input
  • 无法解析符号 DrawerLayout

    我正在尝试实现导航抽屉 如下所示 http developer android com training implementing navigation nav drawer html top http developer android
  • 在 HTML 链接中使用 onClick 传递多个值

    您好 我正在尝试使用 HTML onclick 函数传递多个值 我使用 Javascript 创建表 var user element UserName var valuationId element ValuationId Valuati
  • 无法解析 com.facebook.react:react-native:0.32.0

    我在 android studio 的 React Native 项目中打开了 android 文件夹 做了所有可能的修改build gradle文件 但是我收到这个重复的错误 Error Failed to resolve com fac