首页 > 解决方案 > android模拟器不适用于反应本机cli

问题描述

我在react native expo中制作了一个应用程序,现在我将其弹出以响应 native cli。但它显示以下错误。我该如何解决这个问题或在 android 上运行 react native cli?

以下是我的终端错误:

Jetifier found 1306 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
warn Invalid application's package name "com.adityasonawane.abcdKids" in 'AndroidManifest.xml'. Read guidelines for setting the package name here: https://developer.android.com/studio/build/application-id
'adb' is not recognized as an internal or external command,
operable program or batch file.
info Launching emulator...
'adb' is not recognized as an internal or external command,
operable program or batch file.
'adb' is not recognized as an internal or external command,
operable program or batch file.
'adb' is not recognized as an internal or external command,
operable program or batch file.
'adb' is not recognized as an internal or external command,
operable program or batch file.
'adb' is not recognized as an internal or external command,
operable program or batch file.
'adb' is not recognized as an internal or external command,
operable program or batch file.
'adb' is not recognized as an internal or external command,
operable program or batch file.
'adb' is not recognized as an internal or external command,
operable program or batch file.
'adb' is not recognized as an internal or external command,
operable program or batch file.
error Failed to launch emulator. Reason: Emulator exited before boot..
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...

> Configure project :app

Installing unimodules:
 unimodules-core@7.1.0 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\@unimodules\core
 unimodules-react-native-adapter@6.2.2 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\@unimodules\react-native-adapter
 expo-application@3.1.2 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\expo-application
 expo-av@9.1.2 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\expo-av
 expo-constants@10.1.3 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\expo-constants
 expo-error-recovery@2.1.0 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\expo-error-recovery
 expo-file-system@11.0.2 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\expo-file-system
 expo-font@9.1.0 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\expo-font
 expo-image-loader@2.1.1 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\expo-image-loader
 expo-keep-awake@9.1.2 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\expo-keep-awake
 expo-permissions@12.0.1 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\expo-permissions
 expo-splash-screen@0.10.2 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\expo-splash-screen
 expo-structured-headers@1.0.1 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\expo-structured-headers
 expo-updates@0.5.5 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\expo-updates
 unimodules-app-loader@2.1.0 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\unimodules-app-loader
 unimodules-barcode-scanner-interface@6.1.0 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\unimodules-barcode-scanner-interface
 unimodules-camera-interface@6.1.0 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\unimodules-camera-interface
 unimodules-constants-interface@6.1.0 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\unimodules-constants-interface        
 unimodules-face-detector-interface@6.1.0 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\unimodules-face-detector-interface
 unimodules-file-system-interface@6.1.0 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\unimodules-file-system-interface
 unimodules-font-interface@6.1.0 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\unimodules-font-interface
 unimodules-image-loader-interface@6.1.0 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\unimodules-image-loader-interface
 unimodules-permissions-interface@6.1.0 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\unimodules-permissions-interface
 unimodules-sensors-interface@6.1.0 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\unimodules-sensors-interface
 unimodules-task-manager-interface@6.1.0 from C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\unimodules-task-manager-interface

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.1/userguide/command_line_interface.html#sec:command_line_warnings

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file 'C:\Users\HP\Desktop\New folder (2)\abcdKids\node_modules\expo-application\android\build.gradle' line: 2

* What went wrong:
A problem occurred evaluating project ':expo-application'.
> Plugin with id 'maven' not 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
A problem occurred configuring project ':expo-application'.
> compileSdkVersion is not specified. Please add it to build.gradle

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

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.



下面是我的 buld.gradle 代码:

我试图更改包名称,还更新了路径变量和gradel,但它仍然给我错误..

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "29.0.3"
        minSdkVersion = 30
        compileSdkVersion = 30
        targetSdkVersion = 30
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.1.0")

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        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()
        jcenter()
        maven { url 'https://www.jitpack.io' }
    }
}

标签: node.jsreact-native

解决方案


根据错误,尝试以下解决方案。

  1. 降级您的 gradle 版本并重新运行该应用程序。在 gradle-wrapper.properties 中降级到 gradle-6.8.1-all.zip

  2. 如果上述解决方案不起作用。原因可能是您编译的 sdk 版本与您的依赖项不匹配。尝试降级,看看它是否有效。


推荐阅读