0

当我通常通过终端从 Android 虚拟设备(模拟器)中的可视代码运行我的 react-native 时npx react-native run android,突然我遇到了这个错误

 1. info Running jetifier to migrate libraries to AndroidX. You can
    disable it using "--no-jetifier" flag. Jetifier found 954 file(s) to
    forward-jetify. Using 8 workers... info Starting JS server... info
    Launching emulator... error Failed to launch emulator. Reason: Could
    not start emulator within 30 seconds.. warn Please launch an
    emulator manually or connect a device. Otherwise app may fail to
    launch. info Installing the app...
    
    > Configure project :react-native-firebase_app :react-native-firebase_app package.json found at
    C:\Users\admin\Desktop\TheOriginalsAgency\Stage-pre-emcauche\MilinusApp\node_modules\@react-native-firebase\app\package.json
    :react-native-firebase_app:firebase.bom using default value: 28.1.0
    :react-native-firebase_app:play.play-services-auth using default
    value: 19.0.0 :react-native-firebase_app package.json found at
    C:\Users\admin\Desktop\TheOriginalsAgency\Stage-pre-emcauche\MilinusApp\node_modules\@react-native-firebase\app\package.json
    :react-native-firebase_app:version set from package.json: 12.1.0
    (12,1,0 - 12001000) :react-native-firebase_app:android.compileSdk
    using custom value: 29 :react-native-firebase_app:android.targetSdk
    using custom value: 29 :react-native-firebase_app:android.minSdk
    using custom value: 21
    :react-native-firebase_app:reactNativeAndroidDir
    C:\Users\admin\Desktop\TheOriginalsAgency\Stage-pre-emcauche\MilinusApp\node_modules\react-native\android
    
    > Task :app:installDebug FAILED Skipping device 'emulator-5554' (emulator-5554): Device is OFFLINE. 64 actionable tasks: 2 executed,
    62 up-to-date
    
    FAILURE: Build failed with an exception.
    
    * What went wrong: Execution failed for task ':app:installDebug'.
    > com.android.builder.testing.api.DeviceException: No online devices found.
    
    * 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 16s
    
    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 ':app:installDebug'.
    > com.android.builder.testing.api.DeviceException: No online devices found.
    
    * 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 16s
    
        at makeError (C:\Users\admin\Desktop\TheOriginalsAgency\Stage-pre-emcauche\MilinusApp\node_modules\execa\index.js:174:9)
        at C:\Users\admin\Desktop\TheOriginalsAgency\Stage-pre-emcauche\MilinusApp\node_modules\execa\index.js:278:16
        at processTicksAndRejections (internal/process/task_queues.js:94:5)
        at async runOnAllDevices (C:\Users\admin\Desktop\TheOriginalsAgency\Stage-pre-emcauche\MilinusApp\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
        at async Command.handleAction (C:\Users\admin\Desktop\TheOriginalsAgency\Stage-pre-emcauche\MilinusApp\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:186:9)
    info Run CLI with --verbose flag for more details.
4

1 回答 1

0

我不知道你是否已经解决了这个问题,但我刚刚解决了!我为 Android 虚拟设备添加了更多空间。你必须:

  1. 编辑设备或创建新设备
  2. 在“验证配置”页面上,单击“显示高级设置”
  3. 向下滚动到“内存和存储”
  4. 更改内部存储 MB 数量

最初我创建的设备有 2048MB,所以我将其更改为 6000MB,但这还不够,所以我最终放入了 10000MB 的内部存储,并且有了这个数量,我再也没有收到这个错误了。

希望它有效,祝你好运!

于 2021-12-10T18:05:48.403 回答