【问题标题】:react native Could not find com.android.volley:volley:1.1.1反应原生找不到 com.android.volley:volley:1.1.1
【发布时间】:2021-12-31 21:15:20
【问题描述】:

我在运行 yarn android 时使用 react native 66 得到错误

yarn run v1.22.17 $ react-native run-android info 运行 jetifier 将库迁移到 AndroidX。您可以使用“--no-jetifier”标志禁用它。 Jetifier 找到 1428 个文件来转发-jetify。使用 4 名工人... info JS 服务器已经在运行。 信息 正在安装应用程序... 配置项目:react-native-firebase react-native-firebase:使用来自 /Users/ha3an/Documents/Bahrami/phone/homeserviceuser/node_modules/react-native/android 的 React Native 预构建二进制文件 警告:: 指定的 Android SDK 构建工具版本 (28.0.3) 被忽略,因为它低于 Android Gradle 插件 4.2.2 的最低支持版本 (30.0.2)。 将使用 Android SDK 构建工具 30.0.2。 要禁止显示此警告,请从您的 build.gradle 文件中删除“buildToolsVersion '28.0.3'”,因为每个版本的 Android Gradle 插件现在都有一个默认版本的构建工具。 任务:app:checkDebugAarMetadata 失败 此版本中使用了已弃用的 Gradle 功能,使其与 Gradle 7.0 不兼容。 使用“--warning-mode all”显示各个弃用警告。 见https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings 39 个可操作的任务:2 个已执行,37 个最新 FAILURE:构建失败并出现异常。 什么地方出了错: 任务“:app:checkDebugAarMetadata”执行失败。 无法解析配置“:app:debugRuntimeClasspath”的所有文件。 找不到 com.android.volley:volley:1.1.1。 在以下位置搜索: - https://repo.maven.apache.org/maven2/com/android/volley/volley/1.1.1/volley-1.1.1.pom - 文件:/Users/ha3an/.m2/repository/com/android/volley/volley/1.1.1/volley-1.1.1.pom - 文件:/Users/ha3an/Documents/Bahrami/phone/homeserviceuser/node_modules/react-native/android/com/android/volley/volley/1.1.1/volley-1.1.1.pom - 文件:/Users/ha3an/Documents/Bahrami/phone/homeserviceuser/node_modules/jsc-android/dist/com/android/volley/volley/1.1.1/volley-1.1.1.pom - https://dl.google.com/dl/android/maven2/com/android/volley/volley/1.1.1/volley-1.1.1.pom - https://www.jitpack.io/com/android/volley/volley/1.1.1/volley-1.1.1.pom 要求: 项目:app > 项目:react-native-google-places > com.google.android.libraries.places:places:1.1.0 尝试: 使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。运行 --scan 以获得完整的见解。 在https://help.gradle.org 获得更多帮助 25 秒内构建失败

build.qradle 文件是

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 30
        targetSdkVersion = 30
        ndkVersion = "21.4.7075529"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.2.2")
        classpath("com.google.gms:google-services:4.3.10")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenCentral()
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        maven { url 'https://www.jitpack.io' }
    }
}

我尝试在我的 build.gradle 文件上使用 jcenter,它构建成功但出现错误

Error: ENOENT: no such file or directory, open '/.../phone/homeserviceuser/http:/localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.aloosalamati.homeserviceuser&modulesOnly=false&runModule=true'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at getCodeFrame (/.../phone/homeserviceuser/node_modules/metro/src/Server.js:919:18)
    at Server._symbolicate (/.../phone/homeserviceuser/node_modules/metro/src/Server.js:992:22)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Server._processRequest (/.../phone/homeserviceuser/node_modules/metro/src/Server.js:403:7) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/.../phone/homeserviceuser/http:/localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.aloosalamati.homeserviceuser&modulesOnly=false&runModule=true'
}

我用谷歌搜索但找不到任何解决方案

【问题讨论】:

    标签: android react-native gradle android-volley


    【解决方案1】:

    我使用jcenter,它工作正常

    【讨论】:

    • 这个答案不完整,需要更多细节。
    【解决方案2】:

    你可以在你的gradel.build文件上添加jcenter,我认为这是可行的

    【讨论】:

    • 我用它就行了
    【解决方案3】:

    这对我有用。

    在项目 gradle 所有项目部分中添加了这些行

            jcenter() //by adding this
            google() 
            maven { url 'https://www.jitpack.io' }
            maven {
             url "https://maven.google.com" // by adding this
         }
    

    完整代码

    allprojects {
        repositories {
            maven {
                // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
                url("$rootDir/../node_modules/react-native/android")
            }
            maven {
                // Android JSC is installed from npm
                url("$rootDir/../node_modules/jsc-android/dist")
            }
            mavenCentral {
                // We don't want to fetch react-native from Maven Central as there are
                // older versions over there.
                content {
                    excludeGroup "com.facebook.react"
                }
            }
            jcenter()
            google()
            maven { url 'https://www.jitpack.io' }
            maven {
             url "https://maven.google.com" // specifically this worked 
         }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-10
      • 1970-01-01
      • 2021-08-25
      • 2020-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多