第一次运行到安卓失败
Could not find implementation class 'com.facebook.react.ReactRootProjectPlugin' for plugin 'com.facebook.react.rootproject' specified in jar:file:/D:/Android_Studio_Data/.gradle/caches/jars-9/o_3a1fd35320f05989063e7069031b710f/react-native-gradle-plugin.jar!/META-INF/gradle-plugins/com.facebook.react.rootproject.properties.
修改android下的build.gradle
buildscript {ext {buildToolsVersion = "34.0.0"minSdkVersion = 21compileSdkVersion = 34targetSdkVersion = 34ndkVersion = "25.1.8937393"kotlinVersion = "1.8.0"}repositories {maven{ url 'https://maven.aliyun.com/repository/google'}google()mavenCentral()}dependencies {classpath("com.android.tools.build:gradle")classpath("com.facebook.react:react-native-gradle-plugin")classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")}
}
allprojects {repositories {maven{ url 'https://maven.aliyun.com/repository/google'}google()jcenter()}
}apply plugin: "com.facebook.react.rootproject"
打开app,满屏红色,状态500
关闭这个,重新运行
如果还不行
npm uninstall babel-preset-react-nativenpm install babel-preset-react-native@2.1.0 —save
或
yarn remove babel-preset-react-nativeyarn add babel-preset-react-native@2.1.0
bug调试打开空白
使用 Flipper 调试 React Native 应用程序在 React Native 0.73 中已弃用。我们最终将删除对通过 Flipper 进行 JS 调试的开箱即用支持
使用
npx react-devtools