react native 错误:Make sure you have an Android emulator running or a device connected and have set up

终于终于弄好了!!!

请注意这是在Windows版本下!!!

出现以下问题

react native 错误:Make sure you have an Android emulator running or a device connected and have set up_第1张图片

一开始我只是注意了红色部分的问题,然后疯狂百度、Google都没有找到合适解决办法

最后冷静下来,我们看看上面的提示信息呢?

react native 错误:Make sure you have an Android emulator running or a device connected and have set up_第2张图片

原来是没有找到Android的SDK文件!

配置Android SDK可以通过配置环境变量来进行或者在项目的android目录下的local.properties文件中写入,如果没有这个文件就自己创建一个。查看AndroidSDK的路径可以通过AndroidStudio来查看

react native 错误:Make sure you have an Android emulator running or a device connected and have set up_第3张图片

当然你也可以把以前Android项目的local.properties文件拷贝过来

不过,我还配置了这个project的build.gradle文件,这个是在其他地方查到的,我放出来大家看看

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }

        configurations.all {
            resolutionStrategy {
                eachDependency { DependencyResolveDetails details ->
                    if (details.requested.group == 'com.facebook.react' && details.requested.name == 'react-native') {
                        details.useVersion "0.57.3"//这儿是你自己的版本号,可以使用react-native -v来查看版本
                    }
                }
            }
        }
        google()
    }
}

之后,再次运行

react-native run-android

就可以看到

react native 错误:Make sure you have an Android emulator running or a device connected and have set up_第4张图片

你可能感兴趣的:(React-Native)