You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android14(Target SDK34)下RN0.71.8项目遇ClassNotFoundException求助

解决React Native 0.71.8 + Android SDK34下BridgeDevSupportManager类找不到的问题

下面是针对该ClassNotFoundException的具体解决步骤:

  • 检查DevSupport依赖配置
    BridgeDevSupportManager属于React Native的开发支持模块,仅在debug构建中需要。打开app/build.gradle,确认debugImplementation依赖中没有排除devsupport模块:

    // 确保没有类似这样的排除配置
    // debugImplementation('com.facebook.react:react-native:0.71.8') {
    //     exclude group: 'com.facebook.react', module: 'devsupport'
    // }
    

    保持debug构建默认包含devsupport依赖,release构建会自动移除该模块。

  • 配置Multidex并清理构建缓存
    Android 14的Dex规则调整可能导致类加载异常,尤其是当应用方法数超过65536时。开启Multidex:
    在app/build.gradle中添加:

    android {
        defaultConfig {
            multiDexEnabled true
        }
    }
    
    dependencies {
        implementation 'androidx.multidex:multidex:2.0.1'
    }
    

    然后执行清理命令重置构建缓存:

    ./gradlew clean
    

    重新构建并运行debug版本。

  • 更新React Native补丁版本
    React Native 0.71.8存在部分Android 14适配问题,建议升级到0.71系列的最新补丁版本(如0.71.14),该版本修复了SDK34相关的类加载问题。执行升级命令:

    npx react-native upgrade 0.71.14
    

    升级后同步gradle并重新构建。

  • 排查混淆与构建变体
    如果误运行release构建,devsupport模块会被移除,导致该类找不到。确认当前运行的是debug变体。若需在release构建中保留开发支持(不推荐),在proguard-rules.pro中添加:

    -keep class com.facebook.react.devsupport.** { *; }
    

内容的提问来源于stack exchange,提问作者Creni Patel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 17:27:29