嗨,我最近安装了 react-navigation 和相关的依赖项,例如 react-native-screens 和 react-native-gesture-hander 等,但是 之后我的应用程序没有构建,我总是收到以下错误,表明构建失败,有些人说这是一个代理问题,我尝试关闭代理并使用来自不同提供商的 diffenret 代理,但这没有帮助要么:
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1001 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
* daemon not running; starting now at tcp:5037
* daemon started successfully
info Launching emulator...
info Successfully launched emulator.
info Installing the app...
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :react-native-community_masked-view:generateDebugRFile FAILED
37 actionable tasks: 2 executed, 35 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-community_masked-view:generateDebugRFile'.
> Could not resolve all files for configuration ':react-native-community_masked-view:debugCompileClasspath'.
> Could not resolve androidx.appcompat:appcompat:1.0.2.
Required by:
project :react-native-community_masked-view > com.facebook.react:react-native:0.64.0
> Could not resolve androidx.appcompat:appcompat:1.0.2.
> Could not get resource 'https://jcenter.bintray.com/androidx/appcompat/appcompat/1.0.2/appcompat-1.0.2.pom'.
> Could not GET 'https://jcenter.bintray.com/androidx/appcompat/appcompat/1.0.2/appcompat-1.0.2.pom'. Received status code 403 from server: Forbidden
> Could not resolve androidx.appcompat:appcompat:1.0.2.
> Could not get resource 'https://jcenter.bintray.com/androidx/appcompat/appcompat/1.0.2/appcompat-1.0.2.pom'.
> Could not GET 'https://jcenter.bintray.com/androidx/appcompat/appcompat/1.0.2/appcompat-1.0.2.pom'. Received status code 403 from server: Forbidden
> Could not resolve androidx.versionedparcelable:versionedparcelable:1.0.0.
Required by:
project :react-native-community_masked-view > androidx.core:core:1.0.0
> Could not resolve androidx.versionedparcelable:versionedparcelable:1.0.0.
> Could not get resource 'https://jcenter.bintray.com/androidx/versionedparcelable/versionedparcelable/1.0.0/versionedparcelable-1.0.0.pom'.
> Could not GET 'https://jcenter.bintray.com/androidx/versionedparcelable/versionedparcelable/1.0.0/versionedparcelable-1.0.0.pom'. Received status code 403 from server: Forbidden
> Could not resolve androidx.versionedparcelable:versionedparcelable:1.0.0.
> Could not get resource 'https://jcenter.bintray.com/androidx/versionedparcelable/versionedparcelable/1.0.0/versionedparcelable-1.0.0.pom'.
> Could not GET 'https://jcenter.bintray.com/androidx/versionedparcelable/versionedparcelable/1.0.0/versionedparcelable-1.0.0.pom'. Received status code 403 from server: Forbidden
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 30s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-community_masked-view:generateDebugRFile'.
> Could not resolve all files for configuration ':react-native-community_masked-view:debugCompileClasspath'.
> Could not resolve androidx.appcompat:appcompat:1.0.2.
Required by:
project :react-native-community_masked-view > com.facebook.react:react-native:0.64.0
> Could not resolve androidx.appcompat:appcompat:1.0.2.
> Could not get resource 'https://jcenter.bintray.com/androidx/appcompat/appcompat/1.0.2/appcompat-1.0.2.pom'.
> Could not GET 'https://jcenter.bintray.com/androidx/appcompat/appcompat/1.0.2/appcompat-1.0.2.pom'. Received status code 403 from server: Forbidden
> Could not resolve androidx.appcompat:appcompat:1.0.2.
> Could not get resource 'https://jcenter.bintray.com/androidx/appcompat/appcompat/1.0.2/appcompat-1.0.2.pom'.
> Could not GET 'https://jcenter.bintray.com/androidx/appcompat/appcompat/1.0.2/appcompat-1.0.2.pom'. Received status code 403 from server: Forbidden
> Could not resolve androidx.versionedparcelable:versionedparcelable:1.0.0.
Required by:
project :react-native-community_masked-view > androidx.core:core:1.0.0
> Could not resolve androidx.versionedparcelable:versionedparcelable:1.0.0.
> Could not get resource 'https://jcenter.bintray.com/androidx/versionedparcelable/versionedparcelable/1.0.0/versionedparcelable-1.0.0.pom'.
> Could not GET 'https://jcenter.bintray.com/androidx/versionedparcelable/versionedparcelable/1.0.0/versionedparcelable-1.0.0.pom'. Received status code 403 from server: Forbidden
> Could not resolve androidx.versionedparcelable:versionedparcelable:1.0.0.
> Could not get resource 'https://jcenter.bintray.com/androidx/versionedparcelable/versionedparcelable/1.0.0/versionedparcelable-1.0.0.pom'.
> Could not GET 'https://jcenter.bintray.com/androidx/versionedparcelable/versionedparcelable/1.0.0/versionedparcelable-1.0.0.pom'. Received status code 403 from server: Forbidden
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 30s
at makeError (C:\Users\MMD\Desktop\Projects\awesomeproject\node_modules\@react-native-community\cli-platform-android\node_modules\execa\index.js:174:9)
at C:\Users\MMD\Desktop\Projects\awesomeproject\node_modules\@react-native-community\cli-platform-android\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at async runOnAllDevices (C:\Users\MMD\Desktop\Projects\awesomeproject\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
at async Command.handleAction (C:\Users\MMD\Desktop\Projects\AwesomeProject\node_modules\@react-native-community\cli\build\index.js:186:9)
info Run CLI with --verbose flag for more details.
这是我的应用程序的 package.json 文件:
{
"name": "awesomeproject",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/bottom-tabs": "^5.11.8",
"@react-navigation/drawer": "^5.12.4",
"@react-navigation/native": "^5.9.3",
"@react-navigation/stack": "^5.14.3",
"react": "17.0.1",
"react-native": "0.64.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "^2.0.1",
"react-native-safe-area-context": "^3.2.0"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/runtime": "^7.12.5",
"@react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "7.14.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.64.0",
"react-test-renderer": "17.0.1"
},
"jest": {
"preset": "react-native"
}
}
答案 0 :(得分:0)
在您的 jetifier
package.json
中添加 devDependencies
并运行 npm install
或 yarn install
安装完成后,在 scripts
的 package.json
对象中添加 "postinstall": "jetify"
并运行 npm install
/yarn install
。
postinstall
上的 package.json
在 npm install
或 yarn install
之后运行您想要的任何命令,在本例中它运行 jetify
并为 Android X 准备项目。