新建React-Native项目,遇到的问题以及查看日志

Windows电脑,命令:react-native init Demo新建RN项目,用AndroidStudio打开,报错:

Error:The module 'app' is an Android project without build variants, and cannot be built.
Please fix the module's configuration in the build.gradle file and sync the project again.

我的解决办法:react-native init Demo --version 0.51.0

重新新建一个,再次用AndroidStudio打开就没有问题了,正常编译通过

打开AndroidStudio,查看app下的build.gradle,找到 

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.demo"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

目标 compileSdkVersion 23,打开Android SDK Manager,安装API  Leven 为 23的SDK工具,再编译项目。

查看日志命令,在cmd下运行  react-native log-android 即可。

 

你可能感兴趣的:(新建React-Native项目,遇到的问题以及查看日志)