Repository: flutter
Issue: Cannot build --profile APK for a plugin with a custom dependency added to 'debugImplementation' and 'releaseImplementation'
Labels: platform-android,tool,a: build,P2,team-android,triaged-android

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

1. Create a plugin project with Android as one of the target platforms.
2. Add a custom dependency to `debuIimplementation` and `releaseImplementation`, and make sure the APKs can be built.
3. Try to build `flutter build apk --profile` - this will fail with compilation error that it cannot find the types that come from the custom library.

Invoking `flutter build apk --release` and `--debug` works fine. I tried adding the dependency to `profileImplementation`, but such a thing doesn't even exist and Gradle fails.

How do I add a custom dependency to build for `--profile`?

### Expected results

A profile APK can be created.

### Actual results

The build fails with compilation errors saying types from the custom library cannot be resolved. This means that the 'profile' classpath isn't using the custom dependency.

### Code sample

<details><summary>Code sample</summary>

<plugin root>/android/build.gradle
```groovy
...
debugImplementation 'com.my:dep-debug:1.0.0'
releaseImplementation 'com.my:dep-release:1.0.0'
...
```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

<details><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
$ flutter doctor -v
[✓] Flutter (Channel stable, 3.10.6, on macOS 13.5.1 22G90 darwin-arm64, locale en-DE)
    • Flutter version 3.10.6 on channel stable at /Users/rswierzy/fvm/versions/3.10.6
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f468f3366c (7 weeks ago), 2023-07-12 15:19:05 -0700
    • Engine revision cdbeda788a
    • Dart version 3.0.6
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/rswierzy/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /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 17.0.6+0-17.0.6b829.9-10027231)

[✓] VS Code (version 1.81.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.70.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.5.1 22G90 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 116.0.5845.140

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>