我在运行时使用React Native 66
yarn android
得到了错误
纱线运行v1.22.17 $ 反应本机运行 Android 信息 运行 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 项为最新 失败:构建失败并出现异常。 什么地方出了错: 任务“: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 要求者: 项目:应用程序 > 项目: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'
}
我用谷歌搜索但找不到任何解决方案
这对我有用。
在项目 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
}
}
}
我使用
jcenter
,效果很好
在 node_modules 中 eact-native-google-places ndroid build.gradle 文件
替换下面
*> implementation "com.google.android.libraries.places:places:1.1.0*
通过这个:-
implementation('com.google.android.libraries.places:places:1.1.0') {
exclude group: 'com.android.volley'
}
implementation 'com.android.volley:volley:1.2.0'
来源:https://github.com/tolu360/react-native-google-places/issues/301