Repository: flutter
Issue: Cannot add Flutter to existing Android app, Gradle fails to resolve dependencies ("module source code" option)
Labels: t: gradle,a: existing-apps,in triage

### Steps to reproduce

I'm experimenting with Flutter's add-to-app feature. I have [an existing Jetpack Compose app ](https://github.com/kacaleksandra/notes) and I want to add a new FlutterActivity to it. I follow [this guide](https://docs.flutter.dev/add-to-app/android/project-setup), [here is the PR](https://github.com/kacaleksandra/notes/pull/25).

To reproduce:
1. Clone the repository, switch to the `embed_flutter` branch
2. `cd mobile`
3. `./gradlew :app:assembleDebug`

### Expected results

I expect the app to be built.

### Actual results

I get a dependency resolution failure (see logs).

### Code sample

Available in a separate repo on a branch: https://github.com/kacaleksandra/notes/pull/25

### Screenshots or Video

n/a

### Logs

<details open><summary>Logs</summary>

```console
$ ./gradlew :app:assembleDebug

> Configure project :flutter
Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by plugin 'dev.flutter.flutter-gradle-plugin'
Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by plugin 'dev.flutter.flutter-gradle-plugin'
Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by plugin 'dev.flutter.flutter-gradle-plugin'

> Task :app:checkDebugAarMetadata FAILED

[Incubating] Problems report is available at: file:///Users/bartek/projects/notes/mobile/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
      > Could not find io.flutter:flutter_embedding_debug:1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b.
        Searched in the following locations:
          - https://dl.google.com/dl/android/maven2/io/flutter/flutter_embedding_debug/1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b/flutter_embedding_debug-1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b.pom
          - https://repo.maven.apache.org/maven2/io/flutter/flutter_embedding_debug/1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b/flutter_embedding_debug-1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b.pom
        Required by:
            project :app > project :flutter
   > Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
      > Could not find io.flutter:armeabi_v7a_debug:1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b.
        Searched in the following locations:
          - https://dl.google.com/dl/android/maven2/io/flutter/armeabi_v7a_debug/1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b/armeabi_v7a_debug-1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b.pom
          - https://repo.maven.apache.org/maven2/io/flutter/armeabi_v7a_debug/1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b/armeabi_v7a_debug-1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b.pom
        Required by:
            project :app > project :flutter
   > Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
      > Could not find io.flutter:arm64_v8a_debug:1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b.
        Searched in the following locations:
          - https://dl.google.com/dl/android/maven2/io/flutter/arm64_v8a_debug/1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b/arm64_v8a_debug-1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b.pom
          - https://repo.maven.apache.org/maven2/io/flutter/arm64_v8a_debug/1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b/arm64_v8a_debug-1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b.pom
        Required by:
            project :app > project :flutter
   > Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
      > Could not find io.flutter:x86_64_debug:1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b.
        Searched in the following locations:
          - https://dl.google.com/dl/android/maven2/io/flutter/x86_64_debug/1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b/x86_64_debug-1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b.pom
          - https://repo.maven.apache.org/maven2/io/flutter/x86_64_debug/1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b/x86_64_debug-1.0.0-e672b006cb34c921db85b8e2f482ed3144a4574b.pom
        Required by:
            project :app > project :flutter

* Try:
> The project declares repositories, effectively ignoring the repositories you have declared in the settings.
   To determine how project repositories are declared, configure your build to fail on project repositories.
   For more information, please refer to https://docs.gradle.org/8.12/userguide/declaring_repositories.html#sub:fail_build_on_project_repositories in the Gradle documentation.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.12/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD FAILED in 10s
8 actionable tasks: 4 executed, 4 up-to-dat
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.27.3, on macOS 15.2 24C101 darwin-arm64, locale en-US)
    • Flutter version 3.27.3 on channel stable at /Users/bartek/.cache/fvm/versions/3.27.3
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c519ee916e (4 days ago), 2025-01-21 10:32:23 -0800
    • Engine revision e672b006cb
    • Dart version 3.6.1
    • DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/bartek/androidsdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = /Users/bartek/androidsdk
    • Java binary at: /Library/Java/JavaVirtualMachines/openjdk.jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment Homebrew (build 23.0.2)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
    • Xcode at /Applications/Xcode-16.0.0.app/Contents/Developer
    • Build 16A242d
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2)
    • Android Studio at /Users/bartek/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.4+-12422083-b607.1)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.3.2.1)
    • IntelliJ at /Users/bartek/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 83.0.4
    • Dart plugin version 243.23654.44

[✓] VS Code (version 1.96.4)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.102.0

[✓] Connected device (5 available)
    • sdk gphone64 arm64 (mobile)     • emulator-5554             • android-arm64  • Android 14 (API 34) (emulator)
    • Barteks-iPhone (mobile)         • 00008120-001E352E22B8201E • ios            • iOS 18.2.1 22C161
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 15.2 24C101 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 15.2 24C101 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 131.0.6778.265

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>