Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RN 运行一直下载编译依赖...卡着不动了..还没入门就放弃了 #755

Closed
Joonson-lau opened this issue Sep 24, 2023 · 3 comments

Comments

@Joonson-lau
Copy link

请按以下格式提供问题的相关信息。

问题的具体描述

编译并运行 React Native 应用
确保你先运行了模拟器或者连接了真机,然后在你的项目目录中运行yarn android或者yarn react-native run-android:

cd AwesomeProject
yarn android

或者

yarn react-native run-android

此命令会对项目的原生部分进行编译,同时在另外一个命令行中启动Metro服务对 js 代码进行实时打包处理(类似 webpack)。Metro服务也可以使用yarn start命令单独启动。

如果配置没有问题,你应该可以看到应用自动安装到设备上并开始运行。注意第一次运行时需要下载大量编译依赖,耗时可能数十分钟。此过程严重依赖稳定的代理软件,否则将频繁遭遇链接超时和断开,导致无法运行。

也可以尝试阿里云提供的maven 镜像,将android/build.gradle中的mavenCentral()和google()分别替换为maven { url 'https://maven.aliyun.com/repository/central' }和maven { url 'https://maven.aliyun.com/repository/google' }(注意可能有多处需要替换)。

npx react-native run-android只是运行应用的方式之一。你也可以在 Android Studio 中直接运行应用。

译注:建议在run-android成功后再尝试使用 Android Studio 启动。请不要轻易点击 Android Studio 中可能弹出的建议更新项目中某依赖项的建议,否则可能导致无法运行。

如果你无法正常运行,遇到奇奇怪怪的红屏错误,先回头仔细对照文档检查,然后可以看看问题讨论区。不同时期不同版本可能会碰到不同的问题,我们会在论坛中及时解答更新。但请注意千万不要执行 bundle 命令,那样会导致代码完全无法刷新。

  • 请尽量配上相关代码截图

更改了国内源之后,还是如此....一直都下载,或者下载中断,. 部署到模拟器失败....求解..科学上网也试过.

@sunnylqm
Copy link

放弃了就不要来水问题

@MourinhoLove
Copy link

同样的问题。。。
卡在:app:checkDebugAarMetadata > Resolve files of :app:debugRuntimeClasspath > react-android-0.72.6-debug.aar

@web-mobli
Copy link

请按以下格式提供问题的相关信息。

问题的具体描述

编译并运行 React Native 应用 确保你先运行了模拟器或者连接了真机,然后在你的项目目录中运行yarn android或者yarn react-native run-android:

cd AwesomeProject yarn android

或者

yarn react-native run-android

此命令会对项目的原生部分进行编译,同时在另外一个命令行中启动Metro服务对 js 代码进行实时打包处理(类似 webpack)。Metro服务也可以使用yarn start命令单独启动。

如果配置没有问题,你应该可以看到应用自动安装到设备上并开始运行。注意第一次运行时需要下载大量编译依赖,耗时可能数十分钟。此过程严重依赖稳定的代理软件,否则将频繁遭遇链接超时和断开,导致无法运行。

也可以尝试阿里云提供的maven 镜像,将android/build.gradle中的mavenCentral()和google()分别替换为maven { url 'https://maven.aliyun.com/repository/central' }和maven { url 'https://maven.aliyun.com/repository/google' }(注意可能有多处需要替换)。

npx react-native run-android只是运行应用的方式之一。你也可以在 Android Studio 中直接运行应用。

译注:建议在run-android成功后再尝试使用 Android Studio 启动。请不要轻易点击 Android Studio 中可能弹出的建议更新项目中某依赖项的建议,否则可能导致无法运行。

如果你无法正常运行,遇到奇奇怪怪的红屏错误,先回头仔细对照文档检查,然后可以看看问题讨论区。不同时期不同版本可能会碰到不同的问题,我们会在论坛中及时解答更新。但请注意千万不要执行 bundle 命令,那样会导致代码完全无法刷新。

  • 请尽量配上相关代码截图

更改了国内源之后,还是如此....一直都下载,或者下载中断,. 部署到模拟器失败....求解..科学上网也试过.

换了之后报错

$ npx react-native build-android --mode=release
info Building the app...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'AwesomeProject'.
> Could not determine the dependencies of null.
   > Could not resolve all task dependencies for configuration ':classpath'.
      > Could not find com.android.tools.build:gradle:8.1.1.
        Searched in the following locations:
          - https://maven.aliyun.com/repository/google/com/android/tools/build/gradle/8.1.1/gradle-8.1.1.pom
          - https://maven.aliyun.com/repository/central/com/android/tools/build/gradle/8.1.1/gradle-8.1.1.pom
        Required by:
            project :
      > Could not find com.android.tools.build:gradle:8.1.1.
        Searched in the following locations:
          - https://maven.aliyun.com/repository/google/com/android/tools/build/gradle/8.1.1/gradle-8.1.1.pom
          - https://maven.aliyun.com/repository/central/com/android/tools/build/gradle/8.1.1/gradle-8.1.1.pom
        Required by:
            project : > project :gradle-plugin

* 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 4s

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor 

error Failed to build the app.
Error: Command failed with exit code 1: gradlew.bat app:bundleRelease
    at makeError (D:\Users\lenovo\Desktop\android-test\AwesomeProject\node_modules\execa\lib\error.js:60:11)
    at module.exports.sync (D:\Users\lenovo\Desktop\android-test\AwesomeProject\node_modules\execa\index.js:194:17)
    at build (D:\Users\lenovo\Desktop\android-test\AwesomeProject\node_modules\@react-native-community\cli-platform-android\build\commands\buildAndroid\index.js:68:22)
    at Object.buildAndroid [as func] (D:\Users\lenovo\Desktop\android-test\AwesomeProject\node_modules\@react-native-community\cli-platform-android\build\commands\buildAndroid\index.js:60:10)
    at Command.handleAction (D:\Users\lenovo\Desktop\android-test\AwesomeProject\node_modules\@react-native-community\cli\build\index.js:118:23)
    at Command.listener [as _actionHandler] (D:\Users\lenovo\Desktop\android-test\AwesomeProject\node_modules\commander\lib\command.js:482:17)
    at D:\Users\lenovo\Desktop\android-test\AwesomeProject\node_modules\commander\lib\command.js:1283:65
    at Command._chainOrCall (D:\Users\lenovo\Desktop\android-test\AwesomeProject\node_modules\commander\lib\command.js:1177:12)
    at Command._parseCommand (D:\Users\lenovo\Desktop\android-test\AwesomeProject\node_modules\commander\lib\command.js:1283:27)
    at D:\Users\lenovo\Desktop\android-test\AwesomeProject\node_modules\commander\lib\command.js:1081:27
info Run CLI with --verbose flag for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants