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

Expo 49升级后React Native Android构建失败:react-native-google-mobile-ads报错

Expo 49升级后构建开发版本失败,react-native-google-mobile-ads报错

问题描述

把Expo升级到49版本后,构建开发版本时触发了以下错误,试了各种方法都没解决,不确定是版本频繁更新导致的问题,还是SDK和广告库之间存在兼容性冲突。

报错日志

> Configure project :react-native-google-mobile-ads
:react-native-google-mobile-ads package.json found at /home/expo/workingdir/build/node_modules/react-native-google-mobile-ads/package.json
[stderr] 
FAILURE: Build completed with 2 failures.
[stderr] 
1:
[stderr] 
Task failed with an exception.
[stderr] 
-----------
[stderr] 
* Where:
[stderr] 
Build file '/home/expo/workingdir/build/node_modules/react-native-google-mobile-ads/android/build.gradle' line: 120
[stderr] 
* What went wrong:
[stderr] 
A problem occurred evaluating project ':react-native-google-mobile-ads'.
[stderr] 
> Cannot set the value of read-only property 'force' for DefaultExternalModuleDependency{group='com.google.android.gms', name='play-services-ads', version='21.4.0', configuration='default'} of type org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency.
[stderr] 
* Try:
[stderr] 
> Run with --stacktrace option to get the stack trace.
[stderr] 
Run with
[stderr] 
--info
[stderr] 
or --debug option to get more log output.
[stderr] 
> Run with --scan to get full insights.
[stderr] 
==============================================================================
[stderr] 
2: Task failed with an exception.
[stderr] 
-----------
[stderr] 
* What went wrong:
[stderr] 
A problem occurred configuring project ':react-native-google-mobile-ads'.
[stderr] 
> compileSdkVersion is not specified. Please add it to build.gradle
[stderr] 
* Try:
[stderr] 
> Run with --stacktrace option to get the stack trace.
[stderr] 
> Run with --info or --debug option to get more log output.
[stderr] 
> Run with --scan to get full insights.
[stderr] 
==============================================================================
[stderr] 
* Get more help at https://help.gradle.org
[stderr] 
BUILD FAILED in 3m 23s
15 actionable tasks: 15 executed

package.json配置

{
  "name": "zikirmatik",
  "version": "1.0.0",
  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@expo/config-plugins": "~7.2.2",
    "@expo/metro-config": "~0.10.0",
    "@expo/prebuild-config": "~6.2.4",
    "@react-native-async-storage/async-storage": "1.18.2",
    "@react-native-masked-view/masked-view": "0.2.9",
    "@react-native-picker/picker": "2.4.10",
    "@react-navigation/bottom-tabs": "^6.5.5",
    "@react-navigation/native": "^6.1.4",
    "@react-navigation/stack": "^6.3.14",
    "@reduxjs/toolkit": "^1.9.2",
    "expo": "^49.0.0",
    "expo-app-loading": "^2.1.1",
    "expo-av": "~13.4.1",
    "expo-build-properties": "~0.8.3",
    "expo-dev-client": "~2.4.10",
    "expo-device": "~5.4.0",
    "expo-font": "~11.4.0",
    "expo-linking": "~5.0.2",
    "expo-notifications": "~0.20.1",
    "expo-splash-screen": "~0.20.5",
    "expo-status-bar": "~1.6.0",
    "expo-store-review": "~6.4.0",
    "expo-updates": "~0.18.13",
    "firebase": "^9.17.2",
    "immer": "^9.0.19",
    "moment": "^2.29.4",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "0.72.4",
    "react-native-element-dropdown": "^1.8.2",
    "react-native-event-listeners": "^1.0.7",
    "react-native-gesture-handler": "~2.12.0",
    "react-native-google-mobile-ads": "^12.1.2",
    "react-native-paper": "^4.11.2",
    "react-native-responsive-screen": "^1.4.2",
    "react-native-safe-area-context": "4.6.3",
    "react-native-svg": "13.9.0",
    "react-native-web": "~0.19.6",
    "react-redux": "^8.0.5",
    "redux": "^4.2.1",
    "styled-components": "^5.3.3",
    "styled-system": "^5.1.5"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },
  "resolutions": {
    "@expo/config-plugins": "^5.0.0"
  },
  "private": true
}

内容的提问来源于stack exchange,提问作者İbrahim Bilgic

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 10:15:55