代码之家  ›  专栏  ›  技术社区  ›  Alen.Toma

无法从visual studio代码运行新创建的react本机项目

  •  0
  • Alen.Toma  · 技术社区  · 3 年前

    我是新来的本地反应,我总是与视觉工作室2019合作。我曾在Xamarin工作过。 如您所知,当您下载Visual studio并使用xamarin时,android SDK安装在

    C:\Program Files (x86)\Android\android-sdk\platform-tools
    

    adb位于哪个位置 C:\Program Files (x86)\Android\android-sdk\platform-tools

    所以我创造了一个 local.properties 并添加 sdk.dir=C:\Program Files (x86)\Android\android-sdk\platform-tools

    然后我在android上运行我的react原生项目。

    此外,除了下面我得到的错误之外 java.io.IOException: The filename, directory name, or volume label syntax is incorrect 我也没有找到模拟器,这很奇怪,因为我在上面的路径中安装了所有模拟器。 所以我插上了我的安卓设备。

    如果这与visual studio 2019开始安装的android SDK有关,请指导我

    调试输出

    [Warning] Target simulator is not supported for Android platform. 
     If you want to use particular device or simulator for launching Android app,
     please specify device id (as in 'adb devices' output) instead.
    
    [Info] Using Android SDK location defined in android/local.properties file: C:\Program Files (x86)\Android\android-sdk\platform-tools.
    
    [Info] Starting React Native Packager.
    
    [Info] Attaching to running React Native packager
    
    info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
    Jetifier found 1296 file(s) to forward-jetify. Using 8 workers...
    info Launching emulator...
    error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
    info Installing the app...
    warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
    
    > Configure project :app
    
    �[33mInstalling unimodules:�[0m
     �[32munimodules-core�[33m@�[31m6.0.0�[0m from �[35mD:\Projects\NovelLator\node_modules\@unimodules\core�[0m
     �[32munimodules-react-native-adapter�[33m@�[31m5.7.0�[0m from �[35mD:\Projects\NovelLator\node_modules\@unimodules\react-native-adapter�[0m
     �[32mexpo-application�[33m@�[31m2.4.1�[0m from �[35mD:\Projects\NovelLator\node_modules\expo-application�[0m
     �[32mexpo-constants�[33m@�[31m9.3.5�[0m from �[35mD:\Projects\NovelLator\node_modules\expo-constants�[0m
     �[32mexpo-error-recovery�[33m@�[31m1.4.0�[0m from �[35mD:\Projects\NovelLator\node_modules\expo-error-recovery�[0m
     �[32mexpo-file-system�[33m@�[31m9.3.0�[0m from �[35mD:\Projects\NovelLator\node_modules\expo-file-system�[0m
     �[32mexpo-font�[33m@�[31m8.4.0�[0m from �[35mD:\Projects\NovelLator\node_modules\expo-font�[0m
     �[32mexpo-image-loader�[33m@�[31m1.3.0�[0m from �[35mD:\Projects\NovelLator\node_modules\expo-image-loader�[0m
     �[32mexpo-keep-awake�[33m@�[31m8.4.0�[0m from �[35mD:\Projects\NovelLator\node_modules\expo-keep-awake�[0m
     �[32mexpo-linear-gradient�[33m@�[31m8.4.0�[0m from �[35mD:\Projects\NovelLator\node_modules\expo-linear-gradient�[0m
     �[32mexpo-location�[33m@�[31m10.0.0�[0m from �[35mD:\Projects\NovelLator\node_modules\expo-location�[0m
     �[32mexpo-permissions�[33m@�[31m10.0.0�[0m from �[35mD:\Projects\NovelLator\node_modules\expo-permissions�[0m
     �[32mexpo-secure-store�[33m@�[31m9.3.0�[0m from �[35mD:\Projects\NovelLator\node_modules\expo-secure-store�[0m
     �[32mexpo-splash-screen�[33m@�[31m0.8.1�[0m from �[35mD:\Projects\NovelLator\node_modules\expo-splash-screen�[0m
     �[32mexpo-sqlite�[33m@�[31m8.5.0�[0m from �[35mD:\Projects\NovelLator\node_modules\expo-sqlite�[0m
     �[32mexpo-updates�[33m@�[31m0.4.1�[0m from �[35mD:\Projects\NovelLator\node_modules\expo-updates�[0m
     �[32munimodules-app-loader�[33m@�[31m1.4.0�[0m from �[35mD:\Projects\NovelLator\node_modules\unimodules-app-loader�[0m
     �[32munimodules-barcode-scanner-interface�[33m@�[31m5.4.0�[0m from �[35mD:\Projects\NovelLator\node_modules\unimodules-barcode-scanner-interface�[0m
     �[32munimodules-camera-interface�[33m@�[31m5.4.0�[0m from �[35mD:\Projects\NovelLator\node_modules\unimodules-camera-interface�[0m
     �[32munimodules-constants-interface�[33m@�[31m5.4.0�[0m from �[35mD:\Projects\NovelLator\node_modules\unimodules-constants-interface�[0m
     �[32munimodules-face-detector-interface�[33m@�[31m5.4.0�[0m from �[35mD:\Projects\NovelLator\node_modules\unimodules-face-detector-interface�[0m
     �[32munimodules-file-system-interface�[33m@�[31m5.4.0�[0m from �[35mD:\Projects\NovelLator\node_modules\unimodules-file-system-interface�[0m
     �[32munimodules-font-interface�[33m@�[31m5.4.0�[0m from �[35mD:\Projects\NovelLator\node_modules\unimodules-font-interface�[0m
     �[32munimodules-image-loader-interface�[33m@�[31m5.4.0�[0m from �[35mD:\Projects\NovelLator\node_modules\unimodules-image-loader-interface�[0m
     �[32munimodules-permissions-interface�[33m@�[31m5.4.0�[0m from �[35mD:\Projects\NovelLator\node_modules\unimodules-permissions-interface�[0m
     �[32munimodules-sensors-interface�[33m@�[31m5.4.0�[0m from �[35mD:\Projects\NovelLator\node_modules\unimodules-sensors-interface�[0m
     �[32munimodules-task-manager-interface�[33m@�[31m5.4.0�[0m from �[35mD:\Projects\NovelLator\node_modules\unimodules-task-manager-interface�[0m
    
    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.3/userguide/command_line_interface.html#sec:command_line_warnings
    
    FAILURE: Build failed with an exception.
    
    * Where:
    Build file 'D:\Projects\NovelLator\node_modules\react-native-reanimated\android\build.gradle' line: 89
    
    * What went wrong:
    A problem occurred configuring project ':react-native-reanimated'.
    > java.io.IOException: The filename, directory name, or volume label syntax is incorrect
    
    * 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 18s
    
    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
    

    这是我的build.grade。

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        ext {
            buildToolsVersion = "29.0.2"
            minSdkVersion = 21
            compileSdkVersion = 29
            targetSdkVersion = 29
        }
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath("com.android.tools.build:gradle:3.5.3")
    
            // 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' }
        }
    }
    

    In C:\Program Files (x86)\Android\android-sdk\build-tools 我有29.0.2版本的地图。

    0 回复  |  直到 3 年前
        1
  •  0
  •   Ruchira Swarnapriya    3 年前

    如果你是windows用户,

    您已使用android studio或CMD手动打开模拟器。

    为什么?

    react native run android命令在windows中不会自动启动模拟器。