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

RN应用仅Android 12随机崩溃,minCompileSdk版本不匹配求助

适配Android 12解决React Native崩溃问题

核心问题根源

你的项目依赖的AAR元数据要求minCompileSdk=31,但当前模块的compileSdkVersion=30,版本不匹配导致Android 12(API 31)环境下启动崩溃,其他低版本系统不受影响。

必须更新的配置项

1. 提升compileSdkVersion到31

在android/app/build.gradle中找到compileSdkVersion配置,修改为31:

android {
    compileSdkVersion 31
    // 其他配置...
}

2. 同步targetSdkVersion到31

同样在android/app/build.gradle的defaultConfig块中,将targetSdkVersion改为31:

defaultConfig {
    targetSdkVersion 31
    // 其他配置...
}

3. 更新Android Gradle插件版本

在android/build.gradle的buildscript块中,确保Gradle插件版本支持API 31,建议升级到7.0.0及以上:

buildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.4'
        // 其他依赖...
    }
}

4. 处理依赖冲突(若仍有问题)

部分第三方库可能未适配API 31,可通过两种方式解决:

  • 找到要求minCompileSdk=31的依赖库,直接升级到其适配API 31的版本
  • 若无法直接升级,在android/app/build.gradle的configurations.all中强制指定兼容版本:
configurations.all {
    resolutionStrategy {
        force 'com.example:problem-library:1.0.0' // 替换为实际兼容版本
    }
}

额外操作建议

  • 升级后同步项目,执行./gradlew clean清理构建缓存,再重新编译
  • 确保Android SDK Manager中已下载API 31的SDK平台及对应版本的构建工具

内容的提问来源于stack exchange,提问作者Suneel Sahu

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.12 02:25:53