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

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

Aperta Adatta ai principianti
#2,700 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Dart
Stelle
795
Fork
448
Merge medio
12h 19m
PR unite (30g)
14

Descrizione

### 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).

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
android, dart, flutter
Ambito
build-system, mobile
Tipo di issue
Bug
Difficoltà
1/5
Tempo stimato
Meno di un'ora
Stato di attività
Attiva
Chiarezza
Specificata chiaramente
Idoneità per principianti
85/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.