Repository: flutter
Issue: Basic auth properties for Gradle wrapper aren't applied
Labels: platform-android,tool,t: gradle,has reproducible steps,P2,found in release: 2.10,found in release: 2.11,team-android,triaged-android

## Steps to Reproduce

1. Create a new project with `flutter create my_app`
2. Set a custom `distributionUrl` in `/android/gradle/wrapper/gradle-wrapper.properties` that requires basic authentication.
3. Define the credentials in `/android/gradle.properties` as follows:
```
systemProp.gradle.wrapperUser=your-username
systemProp.gradle.wrapperPassword=your-password
```
4. Run a command with `./android/gradlew`

**Expected results:** The Gradle wrapper downloads the defined Gradle version and executes the command.
**Actual results:** The server throws a 401 HTTP exception.
**Workaround:** Swap `/android/gradle/wrapper/gradle-wrapper.jar` with the generated `gradle-wrapper.jar` from a (new) native Android project. The Gradle wrapper now downloads the defined Gradle version by correctly applying the basic auth credentials.

`flutter doctor -v` output:

```
[✓] Flutter (Channel stable, 2.10.2, on macOS 12.2.1 21D62 darwin-x64, locale
    en-GB)
    • Flutter version 2.10.2 at /Users/frederik.dumazy/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 097d3313d8 (11 days ago), 2022-02-18 19:33:08 -0600
    • Engine revision a83ed0e5e3
    • Dart version 2.16.1
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/frederik.dumazy/Library/Android/sdk
    • Platform android-31, build-tools 30.0.3
    • ANDROID_HOME = /Users/frederik.dumazy/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio
    • Android Studio at /Applications/Android Studio Preview.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 11.0.8+10-b944.6842174)

[✓] Android Studio (version 2021.1)
    • 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 11.0.11+0-b60-7590822)

[✓] IntelliJ IDEA Community Edition (version 2021.1.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • 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

[✓] VS Code (version 1.64.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.34.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 12.2.1 21D62 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 98.0.4758.109

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```

I could not specify the exact url and credentials since this is sensitive information, but the `distributionUrl` points to an [Artifactory](https://jfrog.com/artifactory/) instance.

Defining the basic auth within the `distributionUrl` directly like `https\://user:password@example.com/gradle-7.0.2-all.zip` also didn't work, as well as defining the `wrapperUser|wrapperPassword` properties in `$USER/.gradle/gradle.properties`.

I would assume that the `gradle-wrapper.jar` that is created with `flutter create` is outdated.
Swapping it out with one from a new native Android project seems to fix this issue and allows to use basic auth for the `distributionUrl`