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

升级compileSdkVersion与targetSdkVersion至33后React Native编译失败

问题描述

将compileSdkVersion与targetSdkVersion升级至33后,运行React Native应用时出现任务执行失败,具体为:react-native-reanimated:downloadBoost任务执行到96%时中断。

错误截图

相关配置文件

android/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "29.0.2"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 33
        googlePlayServicesAuthVersion = "16.0.1"
        kotlinVersion = '1.8.0' // Set the Kotlin version here
    }
    repositories {
       google()
       jcenter()
       mavenCentral()
       maven { url 'https://repo.maven.apache.org/maven2' }

    }
    dependencies {
                  
        classpath("com.android.tools.build:gradle:7.3.1")
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        classpath 'com.google.gms:google-services:4.3.4'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        mavenCentral()
        google()
        jcenter()
        
        maven { url 'https://jitpack.io' }
    }
}

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
解决方案

针对:react-native-reanimated:downloadBoost任务失败的问题,可尝试以下步骤:

  • 清理Gradle缓存:执行命令./gradlew clean,然后删除项目根目录下的.gradle文件夹以及android/.gradle文件夹,重新执行构建。
  • 检查网络连接:Boost依赖包需要从外网下载,确保网络稳定,可尝试切换网络环境。
  • 升级react-native-reanimated版本:部分旧版本的reanimated与compileSdk 33存在兼容问题,执行npm install react-native-reanimated@latest --save升级到最新稳定版,之后按照官方文档重新完成配置(如添加babel插件等)。
  • 手动下载Boost依赖:
    1. 打开node_modules/react-native-reanimated/android/build.gradle文件,查看其中定义的boostVersion。
    2. 手动下载对应版本的Boost压缩包,放置到~/.gradle/caches/modules-2/files-2.1/com.facebook.react/boost/${version}/目录下(目录不存在则自行创建)。
    3. 重新执行构建命令。
  • 适配Gradle与AGP版本:当前AGP版本7.3.1与Gradle 7.4兼容,但可尝试将AGP升级到7.4.x版本,Gradle对应升级到7.5+,提升与compileSdk 33的适配性。

内容的提问来源于stack exchange,提问作者Muhammad Saqib Noor

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.12 01:12:16