Exception: Gradle task assembleDebug failed with exit code 1 in Flutter

105 Views Asked by At

I am running Flutter 2.2.2 in Terminal.app on macOS Big Sur. I have an Android phone, a Moto G5 Plus running Android 8.1.0. Developer options are on as is USB debugging, and I've connected the phone to my computer with a USB data cable. The device shows up when I run the command flutter devices:

% flutter devices
2 connected devices:

Moto G 5 Plus (mobile) • ZY224TM9NW • android-arm    • Android 8.1.0 (API 27)
Chrome (web)           • chrome     • web-javascript • Google Chrome 91.0.4472.114

However, when I run the command flutter run, it displays the following:

% flutter run
Launching lib/main.dart on Moto G 5 Plus in debug mode...
                                                                        
FAILURE: Build failed with an exception.                                
                                                                        
* What went wrong:                                                      
A problem occurred configuring root project 'android'.                  
> Could not resolve all artifacts for configuration ':classpath'.       
   > Could not resolve com.android.tools.build:gradle:4.1.0.            
     Required by:                                                       
         project :                                                      
      > Could not resolve com.android.tools.build:gradle:4.1.0.         
         > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.0/gradle-4.1.0.pom'.
            > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.0/gradle-4.1.0.pom'.
               > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
                                                                        
* 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 10s                                                     
Running Gradle task 'assembleDebug'...                                  
Running Gradle task 'assembleDebug'... Done                        11.8s
Exception: Gradle task assembleDebug failed with exit code 1

The app does not launch and the command fails.

Context:

  • I am on a MacBook Pro 2015 with macOS Big Sur 11.2
  • Flutter 2.2.2, stable release
  • Moto G5 Plus with Android 8.1.0, connected via USB
0

There are 0 best solutions below