react native错误记录

文章讲述了在安卓环境下初次运行ReactNative应用时遇到的问题,涉及到`ReactRootProjectPlugin`找不到、Gradle配置调整、Flipper调试弃用以及expo中字体加载问题的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

第一次运行到安卓失败

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 = 21
        compileSdkVersion = 34
        targetSdkVersion = 34
        ndkVersion = "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-native

npm install babel-preset-react-native@2.1.0 —save

yarn remove babel-preset-react-native

yarn add babel-preset-react-native@2.1.0

bug调试打开空白

使用 Flipper 调试 React Native 应用程序在 React Native 0.73 中已弃用。我们最终将删除对通过 Flipper 进行 JS 调试的开箱即用支持

使用

npx react-devtools

expo中加载字体在安卓上没有效果

因为使用了:fontWeight: "800",

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值