AgoraIO-Extensions / AgoraIO-Extensions/Agora-Flutter-SDK

AGP 9: plugin compiles against android-31 (hard-coded safeExtGet fallback) — blocks AGP 9 migration

未关闭 适合新手
#2,700 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Dart
星标
795
派生
448
平均合并
12 小时 19 分钟
30 天内合并 PR
14

描述

### Version of the agora_rtc_engine

agora_rtc_engine: 6.6.4 (latest)

### Platforms affected

- [x] Android
- [ ] iOS
- [ ] macOS
- [ ] Windows
- [ ] Web

### Steps to reproduce

1. Create a Flutter app that depends on `agora_rtc_engine: 6.6.4`.
2. Use Android Gradle Plugin 9.x (tested: AGP 9.4.0, Gradle 9.6.0, Kotlin 2.4.10, Flutter 3.47.1).
3. Set `compileSdk = 37` in the **app** module (`android/app/build.gradle.kts`).
4. `flutter build apk --release`

### Expected results

The plugin module compiles against a modern `compileSdk` and the build succeeds.

### Actual results

The build fails during AAR metadata checking:

```
Dependency 'androidx.arch.core:core-runtime:2.2.0' requires libraries and applications that
depend on it to compile against version 33 or later of the Android APIs.

:agora_rtc_engine is currently compiled against android-31.

Recommended action: Update this project to use a newer compileSdk
of at least 33, for example 37.2.
```

(Also reported for `androidx.window.extensions.core:core:1.0.0`.)

### Root cause

`android/build.gradle` in the plugin hard-codes **31** as the fallback:

```gradle
compileSdkVersion safeExtGet('compileSdkVersion', 31)
```

`:agora_rtc_engine` is a separate Gradle module, so setting `compileSdk` in the **app** module has no effect on it. Unless the consuming project sets `rootProject.ext.compileSdkVersion`, the plugin silently compiles against **android-31**, which is below the level its own transitive AndroidX dependencies require.

Under AGP 8 this surfaced as a warning for some setups; under **AGP 9 it is a hard build failure**, so the plugin currently blocks any AGP 9 migration out of the box.

### Suggested fix

Raise the fallback in `android/build.gradle` from `31` to at least `34` (ideally 36):

```gradle
compileSdkVersion safeExtGet('compileSdkVersion', 36)
```

This is a build-time constant only — it does not change `minSdk` or `targetSdk`, so it has no runtime or device-compatibility impact for consumers.

### Workaround for other users

Add to the **root** `android/build.gradle[.kts]` of the consuming app:

```kotlin
extra["compileSdkVersion"] = 36
```

### Notes

- Related: #2646 (same symptom reported on 6.6.3, still open with no response). This report adds the root cause, the AGP 9 hard-failure behaviour, and a proposed fix.
- Everything else in 6.6.4 works well for us — thank you for fixing the `ffi` constraint, the SwiftPM product linking, and the `agora-special-full` → `full-sdk` namespace split (that last one resolved a separate AGP 9 manifest-merger blocker for us).

贡献指南

打开贡献指南

调研方向

Start with android/build.gradle and reproduce the AGP 9 failure using the Flutter build command and compileSdk 37 setup described in the issue. Update the hard-coded compileSdk fallback and verify that flutter build apk --release succeeds without the AAR metadata error.

由索引模型根据 Issue 内容生成。

评估

技术栈
android, dart, flutter
领域
build-system, mobile
Issue 类型
缺陷
难度
1/5
预计耗时
1 小时以内
活跃度
活跃
描述清晰度
描述清楚
新手友好度
85/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。