gpt4 book ai didi

react-native - 启动 react-native 项目时出现错误

转载 作者:行者123 更新时间:2023-12-05 04:35:54 33 4
gpt4 key购买 nike

我是 react-native 的初学者。在为 Android 构建我的应用程序时,出现此错误

Task :react-native-community_toolbar-android:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
39 actionable tasks: 39 executed
Note: /home/kanhaiya/testapp/node_modules/@react-native-community/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/home/kanhaiya/testapp/node_modules/@react-native-community/toolbar-android/android/src/main/java/com/reactnativecommunity/toolbarandroid/ReactToolbar.java:107: error: IconImageInfo is not abstract and does not override abstract method getExtras() in HasImageMetadata
private static class IconImageInfo implements ImageInfo {
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

失败:构建失败,出现异常。

  • 出了什么问题:任务 ':react-native-community_toolbar-android:compileDebugJavaWithJavac' 执行失败。

Compilation failed; see the compiler error output for details.

  • 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。

  • https://help.gradle.org 获得更多帮助

构建在 25 秒内失败

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 app:installDebug -PreactNativeDevServerPort=8081
Note: /home/kanhaiya/testapp/node_modules/@react-native-community/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/home/kanhaiya/testapp/node_modules/@react-native-community/toolbar-android/android/src/main/java/com/reactnativecommunity/toolbarandroid/ReactToolbar.java:107: error: IconImageInfo is not abstract and does not override abstract method getExtras() in HasImageMetadata
private static class IconImageInfo implements ImageInfo {
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

失败:构建失败,出现异常。

  • 出了什么问题:任务 ':react-native-community_toolbar-android:compileDebugJavaWithJavac' 执行失败。

Compilation failed; see the compiler error output for details.

  • 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。

  • https://help.gradle.org 获得更多帮助

构建在 25 秒内失败

at makeError (/home/kanhaiya/testapp/node_modules/execa/index.js:174:9)
at /home/kanhaiya/testapp/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (/home/kanhaiya/testapp/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/home/kanhaiya/testapp/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:192:9)

我已经在我的项目中使用 react-native link @react-native-community/toolbar-android 链接了 react-native-community/toolbar-android。仍然报错。

最佳答案

步骤很少,您可以跟进,看看是否一切正常。

第一种方式:

cd Android && cd ./gradlew clean

请注意: ./gradlew <follow_by_script_command>适用于 MacOS。对于 Windows,只需执行 gradlew <follow_by_script_command> .

如果你想生成一个bundle , 然后在上面的命令之后执行此操作:

./gradlew :app:bundleRelease

第二种方式:

此错误的可能原因是您的 RN 版本可能不同于 Android 的 build.gradle 版本,即 android/app/build.gradle。当您创建 react-native应用程序可能会创建类似以下的 Android 应用程序:

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

尝试检查您的 node_modules文件夹,寻找 react-native文件夹并查找带有数字的文件夹,该数字是 native 版本。对我来说,它是 0.66.4 然后更新 android/app/build.gradle:

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

关于react-native - 启动 react-native 项目时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70935785/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com