Flutter 运行Android采坑

使用Flutter运行Android模拟器的时候报错:

FAILURE: Build failed with an exception.                                
                                                                        
* What went wrong:                                                      
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not resolve io.flutter:flutter_embedding_debug:1.0.0-540786dd51f112885a89792d678296b95e6622e5.
     Required by:                                                       
         project :app                                                   
      > Skipped due to earlier error                                    
      > Skipped due to earlier error                                    
      > Skipped due to earlier error                                    
      > Skipped due to earlier error                                    
   > Could not resolve io.flutter:x86_debug:1.0.0-540786dd51f112885a89792d678296b95e6622e5.
     Required by:                                                       
         project :app                                                   
      > Skipped due to earlier error                                    
      > Skipped due to earlier error                                    
      > Skipped due to earlier error                                    
      > Skipped due to earlier error                                    
   > Could not resolve io.flutter:x86_64_debug:1.0.0-540786dd51f112885a89792d678296b95e6622e5.
     Required by:                                                       
         project :app                                                   
      > Skipped due to earlier error                                    
      > Skipped due to earlier error                                    
      > Skipped due to earlier error                                    
      > Skipped due to earlier error                                    
                                                                        
* 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 1m 48s 

问题原因:证书错误无法通过https访问。

The Flutter Maven repository (download.flutter.io) can't be accessed via HTTPS because of a certificate error (wrong host). In my opinion you should be able to download the artifacts via HTTPS for security reasons. Is the repository available via another URL or can the certificate error be fixed?

解决方法:

  • 修改文件:flutter/packages/flutter_tools/gradle/resolve_dependencies.gradle
url "http://download.flutter.io" 
  • 修改文件:flutter/packages/flutter_tools/gradle/flutter.gradle
 private static final String MAVEN_REPO = "http://download.flutter.io";
  • 参考文档:
    Flutter Maven repository should support HTTPS #47452

你可能感兴趣的:(Flutter 运行Android采坑)