Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter application won't run #147459

Open
Daeviz15 opened this issue Apr 27, 2024 · 5 comments
Open

Flutter application won't run #147459

Daeviz15 opened this issue Apr 27, 2024 · 5 comments
Labels
in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds

Comments

@Daeviz15
Copy link

Steps to reproduce

To reproduce the issue where Gradle fails to resolve the Flutter plugin dependency in a Flutter project, follow these steps:

  1. Ensure you have Flutter and Android Studio installed and properly configured on your system.

  2. Create a new Flutter project using the following command in your terminal or command prompt:

flutter create demoapp
  1. Navigate to the newly created project directory:
cd demoapp
  1. Open the settings.gradle file in the android directory of your Flutter project.

  2. Modify the buildscript block to include the Flutter plugin dependency without specifying a version, like so:

buildscript {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
        classpath 'dev.flutter:flutter-plugin' // Update the version to the latest if needed
    }
}
  1. Save the changes to settings.gradle.

  2. Attempt to run the Flutter project using the following command:

flutter run
  1. Observe the error message generated by Gradle, indicating that it couldn't resolve the Flutter plugin dependency.

The error message will indicate that Gradle failed to find any versions of the dev.flutter:flutter-plugin artifact, leading to a failed build process.

Actual results

C:\Users\AJTECH\Documents\demoapp>flutter run
Launching lib\main.dart on Android SDK built for x86 in debug mode...

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not resolve all artifacts for configuration 'classpath'.

Could not find any matches for dev.flutter:flutter-plugin' as no versions of dev.flutter:flutter-plugin are available.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/dev/flutter/flutter-plugin/maven-metadata.xml
- https://repo.maven.apache.org/maven2/dev/flutter/flutter-plugin/maven-metadata.xml
- https://plugins.gradle.org/m2/dev/flutter/flutter-plugin/maven-metadata.xml
Required by:
unspecified:unspecified:unspecified

  • Try:

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.

BUILD FAILED in 16s
Running Gradle task 'assembleDebug'... 18.7s
Error: Gradle task assembleDebug failed with exit code 1

Logs

Microsoft Windows [Version 10.0.19045.4291]
(c) Microsoft Corporation. All rights reserved.

C:\Users\AJTECH>flutter create demoapp
Creating project demoapp...
Resolving dependencies in demoapp... (11.1s)
Got dependencies in demoapp.
Wrote 129 files.

All done!
You can find general documentation for Flutter at: https://docs.flutter.dev/
Detailed API documentation is available at: https://api.flutter.dev/
If you prefer video documentation, consider: https://www.youtube.com/c/flutterdev

In order to run your application, type:

$ cd demoapp
$ flutter run

Your application code is in demoapp\lib\main.dart.

C:\Users\AJTECH>cd demoapp

C:\Users\AJTECH\demoapp>flutter run --verbose
[+1040 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ +36 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ +3 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ +3 ms] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ +3 ms] Artifact Instance of 'LegacyCanvasKitRemover' is not required, skipping update.
[ +76 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ +12 ms] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ +7 ms] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ +12 ms] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ +9 ms] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ +16 ms] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ +12 ms] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +597 ms] executing: C:\Users\AJTECH\AppData\Local\Android\sdk\platform-tools\adb.exe devices -l
[ +545 ms] List of devices attached
emulator-5554 offline transport_id:1
emulator-5556 device product:sdk_google_phone_x86 model:Android_SDK_built_for_x86
device:generic_x86 transport_id:2
[ +130 ms] C:\Users\AJTECH\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5556 shell getprop
[ +897 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ +7 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ +74 ms] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ +26 ms] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ +2 ms] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ +8 ms] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ +16 ms] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ +13 ms] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[+1448 ms] Skipping pub get: version match.
[+1214 ms] Generating
C:\Users\AJTECH\demoapp\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java
[ +431 ms] ro.hardware = ranchu
[ +863 ms] No packages with native assets. Skipping native assets compilation.
[ +64 ms] Initializing file store
[ +79 ms] Skipping target: gen_localizations
[ +76 ms] gen_dart_plugin_registrant: Starting due to {InvalidatedReasonKind.inputChanged: The following inputs have
updated contents: C:\Users\AJTECH\demoapp.dart_tool\package_config_subset}
[ +758 ms] gen_dart_plugin_registrant: Complete
[ +20 ms] _composite: Starting due to {}
[ +4 ms] _composite: Complete
[ +20 ms] complete
[ +81 ms] Launching lib\main.dart on Android SDK built for x86 in debug mode...
[ +34 ms] C:\Users\AJTECH\Documents\flutter\bin\cache\dart-sdk\bin\dartaotruntime.exe --disable-dart-dev
C:\Users\AJTECH\Documents\flutter\bin\cache\dart-sdk\bin\snapshots\frontend_server_aot.dart.snapshot --sdk-root
C:\Users\AJTECH\Documents\flutter\bin\cache\artifacts\engine\common\flutter_patched_sdk/ --incremental --target=flutter
--experimental-emit-debug-metadata -DFLUTTER_WEB_AUTO_DETECT=true
-DFLUTTER_WEB_CANVASKIT_URL=https://www.gstatic.com/flutter-canvaskit/c4cd48e186460b32d44585ce3c103271ab676355/
--output-dill C:\Users\AJTECH\AppData\Local\Temp\flutter_tools.c2a19511\flutter_tool.298831ec\app.dill --packages
C:\Users\AJTECH\demoapp.dart_tool\package_config.json -Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts
--track-widget-creation --filesystem-scheme org-dartlang-root --initialize-from-dill
build\2794971a5855e7decd7bb368de5d49d1.cache.dill.track.dill --verbosity=error
--enable-experiment=alternative-invalidation-strategy
[ +139 ms] executing: C:\Users\AJTECH\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5556 shell -x logcat
-v time -t 1
[+2827 ms] <- compile package:demoapp/main.dart
[ +370 ms] --------- beginning of main
04-27 10:32:49.328 D/hwcomposer( 1230): hw_composer sent 400 syncs in 60s
[ +66 ms] executing: C:\Users\AJTECH\AppData\Local\Android\sdk\platform-tools\adb.exe version
[ +302 ms] Android Debug Bridge version 1.0.41
Version 35.0.1-11580240
Installed as C:\Users\AJTECH\AppData\Local\Android\sdk\platform-tools\adb.exe
Running on Windows 10.0.19045
[ +37 ms] executing: C:\Users\AJTECH\AppData\Local\Android\sdk\platform-tools\adb.exe start-server
[ +368 ms] Building APK
[ +164 ms] executing: C:\Program Files\Android\Android Studio\jbr\bin\java -version
[ +801 ms] Exit code 0 from: C:\Program Files\Android\Android Studio\jbr\bin\java -version
[ +9 ms] openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+0--11185874)
OpenJDK 64-Bit Server VM (build 17.0.9+0--11185874, mixed mode)
[ +68 ms] executing: C:\Program Files\Android\Android Studio\jbr\bin\java --version
[ +820 ms] Exit code 0 from: C:\Program Files\Android\Android Studio\jbr\bin\java --version
[ +28 ms] openjdk 17.0.9 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+0--11185874)
OpenJDK 64-Bit Server VM (build 17.0.9+0--11185874, mixed mode)
[ +313 ms] Using gradle from C:\Users\AJTECH\demoapp\android\gradlew.bat.
[ +18 ms] Running Gradle task 'assembleDebug'...
[ +60 ms] executing: [C:\Users\AJTECH\demoapp\android/] C:\Users\AJTECH\demoapp\android\gradlew.bat --full-stacktrace
--info -Pverbose=true -Ptarget-platform=android-x86 -Ptarget=C:\Users\AJTECH\demoapp\lib\main.dart
-Pbase-application-name=android.app.Application
-Pdart-defines=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==,RkxVVFRFUl9XRUJfQ0FOVkFTS0lUX1VSTD1odHRwczovL3d3dy5nc3RhdGljLmNv
bS9mbHV0dGVyLWNhbnZhc2tpdC9jNGNkNDhlMTg2NDYwYjMyZDQ0NTg1Y2UzYzEwMzI3MWFiNjc2MzU1Lw== -Pdart-obfuscation=false
-Ptrack-widget-creation=true -Ptree-shake-icons=false -Pfilesystem-scheme=org-dartlang-root assembleDebug

Flutter Doctor output

Microsoft Windows [Version 10.0.19045.4291]
(c) Microsoft Corporation. All rights reserved.

C:\Users\AJTECH>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.19.6, on Microsoft Windows [Version 10.0.19045.4291], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
Error 1 retrieving device properties for Android SDK built for x86:
error: closed

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Enterprise 2022 17.10.0 Preview 3.0)
[√] Android Studio (version 2023.2)
[√] VS Code (version 1.88.1)
[√] Connected device (4 available)
! Device emulator-5556 is offline.
[√] Network resources

• No issues found!

C:\Users\AJTECH>flutter doctor -v
[√] Flutter (Channel stable, 3.19.6, on Microsoft Windows [Version 10.0.19045.4291], locale en-US)
• Flutter version 3.19.6 on channel stable at C:\Users\AJTECH\Documents\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 54e6646 (10 days ago), 2024-04-17 13:08:03 -0700
• Engine revision c4cd48e186
• Dart version 3.3.4
• DevTools version 2.31.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at C:\Users\AJTECH\AppData\Local\Android\sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)
• All Android licenses accepted.

[√] Chrome - develop for the web
• Chrome at C:\Users\AJTECH\AppData\Local\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Enterprise 2022 17.10.0 Preview 3.0)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Preview
• Visual Studio Enterprise 2022 version 17.10.34804.81
• The current Visual Studio installation is a pre-release version. It may not be supported by Flutter yet.
• Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2023.2)
• Android Studio at C:\Program Files\Android\Android Studio
• 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.9+0--11185874)

[√] VS Code (version 1.88.1)
• VS Code at C:\Users\AJTECH\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.86.0

[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.4291]
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.78
• Edge (web) • edge • web-javascript • Microsoft Edge 123.0.2420.97

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

• No issues found!

C:\Users\AJTECH>

@bartekpacia
Copy link
Member

Hey,

Why are you including classpath 'dev.flutter:flutter-plugin' in android/build.gradle right after flutter create? Does the app not build after flutter create?

Modify the buildscript block to include the Flutter plugin dependency without specifying a version, like so:

buildscript {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
        classpath 'dev.flutter:flutter-plugin' // Update the version to the latest if needed
    }
}

This is not how you do it. It's expected that it won't work.

There's also #135392 where you can find nice overview of what Gradle buildfiles should look like.

@danagbemava-nc danagbemava-nc added in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Apr 29, 2024
@Daeviz15
Copy link
Author

Daeviz15 commented Apr 29, 2024 via email

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 29, 2024
@bartekpacia
Copy link
Member

Was the original error solved?

If you encounter new problems, please create a new issue with reproducible steps.

@Daeviz15
Copy link
Author

Daeviz15 commented Apr 29, 2024 via email

@bartekpacia
Copy link
Member

bartekpacia commented Apr 29, 2024

Does the original error appear now? Or is it only the second one?

Please explain what problem you're facing more details, otherwise this issue might be closed as "non reproducible".

@danagbemava-nc danagbemava-nc added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds
Projects
None yet
Development

No branches or pull requests

3 participants