flutter error resolution

Error (Error)

First of all, you need to make sure that your Flutter environment is correct, you can flutter doctorcheck:
insert image description here

First of all, let me declare that my Flutter development environment is compiled and run in the AS tool under Window10, and the project is a demo . When creating and running a new project today, I suddenly reported an error:
insert image description here
the code is posted here, which is convenient for SEO spiders to retrieve and help more Flutter developers.

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 download kotlin-gradle-plugin.jar (org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50)
      > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.50/kotlin-gradle-plugin-1.3.50.jar'.
         > Could not GET 'https://d29vzk4ow07wi7.cloudfront.net/635d624afedac53fc9eae611c40825a1ea05dda3699f39aa49432ba57d871f26?response-content-disposition=attachment%3Bfilename%3D%22kotlin-gradle-plugin-1.3.50.jar%22&Policy=eyJTdGF0ZW1lbnQiOiBbeyJSZXNvdXJjZSI6Imh0dHAqOi8vZDI5dnprNG93MDd3aTcuY2xvdWRmcm9udC5uZXQvNjM1ZDYyNGFmZWRhYzUzZmM5ZWFlNjExYzQwODI1YTFlYTA1ZGRhMzY5OWYzOWFhNDk0MzJiYTU3ZDg3MWYyNj9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPWF0dGFjaG1lbnQlM0JmaWxlbmFtZSUzRCUyMmtvdGxpbi1ncmFkbGUtcGx1Z2luLTEuMy41MC5qYXIlMjIiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1Nzc0Mzk2MTZ9LCJJcEFkZHJlc3MiOnsiQVdTOlNvdXJjZUlwIjoiMC4wLjAuMC8wIn19fV19&Signature=iGadNAXiUAk8YmhdDzs6jOUY8OS3s1yyBvjPvrJvIZDMdlVD4Oo6q~Fu8mZfY4HiNSE6bSuxPnBfpEMZX8Vj9I5QJhV7916BUZtMkZ12KFNcDPLXskrFFMMuvSa8N8ySNmJDGdPDDJnYHT6~yWPx-xN-Q50V4AzjGYlqUAfma9KgOxnl-L4F8uzcXzbTMeWRPuNMP8c62x7EA~Ei0d5T2q1agsO51z3gy~4R6C0iNX80d~mzImM7mU4GUwktZjvn1SpXA5W6oWkiOlWRwMLBEmnHQ7KdcaV32XyPqjtWLORAoqUurfvWIFw7icoUTlcJl7lTb8tEVXNmd6Ibbyy43g__&Key-Pair-Id=APKAIFKFWOMXM2UMTSFA'.
            > d29vzk4ow07wi7.cloudfront.net
   > Could not download protobuf-java.jar (com.google.protobuf:protobuf-java:3.4.0)
      > Could not get resource 'https://jcenter.bintray.com/com/google/protobuf/protobuf-java/3.4.0/protobuf-java-3.4.0.jar'.
         > Could not GET 'https://d29vzk4ow07wi7.cloudfront.net/dce7e66b32456a1b1198da0caff3a8acb71548658391e798c79369241e6490a4?response-content-disposition=attachment%3Bfilename%3D%22protobuf-java-3.4.0.jar%22&Policy=eyJTdGF0ZW1lbnQiOiBbeyJSZXNvdXJjZSI6Imh0dHAqOi8vZDI5dnprNG93MDd3aTcuY2xvdWRmcm9udC5uZXQvZGNlN2U2NmIzMjQ1NmExYjExOThkYTBjYWZmM2E4YWNiNzE1NDg2NTgzOTFlNzk4Yzc5MzY5MjQxZTY0OTBhND9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPWF0dGFjaG1lbnQlM0JmaWxlbmFtZSUzRCUyMnByb3RvYnVmLWphdmEtMy40LjAuamFyJTIyIiwiQ29uZGl0aW9uIjp7IkRhdGVMZXNzVGhhbiI6eyJBV1M6RXBvY2hUaW1lIjoxNTc3NDM5Njg5fSwiSXBBZGRyZXNzIjp7IkFXUzpTb3VyY2VJcCI6IjAuMC4wLjAvMCJ9fX1dfQ__&Signature=nfXz1ICAESgVr2oNwTuWwFRmg5M7b0gztJEAz61sMot5JD~VN24PRH1mCRzcJ5XPms--be0ArrswT8UWPwtWdFGv3XMJ10JtOLKOfiiNo2Z0nOBklleMCKsXNtncHuuQeDzI-cEfKH4v42PFzF3E68TihzuTODgXTwUbQxJJBWzut~0EggasaBEBJDfFUesldL8vnyftT-iwpkpgl7A4fOpRVbQBAukT0kYgda60xK~x5ShpkLEgRb8k6NImnVt5yaH5kb3d9MohB2BFVTQW5ds6t86PvVDtOLp1jZwC3yNyNOVZcJaqbMR57Z4p-~TI-s4J5NUK7GybBBBjAbDGNw__&Key-Pair-Id=APKAIFKFWOMXM2UMTSFA'.
            > d29vzk4ow07wi7.cloudfront.net

If the first few lines of your error message are the same as mine, then you should apply the following solution.

solution

As can be seen from the error message, it is caused by the failure to load the file, so the mirror path in the gradle file needs to be replaced .

1. Expand the project directory in turn: [android] → [build.gradle] file

2. Open the build.gradle file for editing, please move directly to the place where I wrote the comment, so as to make changes according to your file.

buildscript {
    
    
    ext.kotlin_version = '1.3.50'
    repositories {
    
    

        // 这里导致报错,所以注释或删除掉即可。
        // google()
        // jcenter()

        // 用下面的路径:
        maven{
    
     url 'https://maven.aliyun.com/repository/google' }
        maven{
    
     url 'https://maven.aliyun.com/repository/jcenter' }
        maven{
    
    url 'http://maven.aliyun.com/nexus/content/groups/public'}

    }

    dependencies {
    
    
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    
    
    repositories {
    
    

        // 这里导致报错,所以注释或删除掉即可。
        // google()
        // jcenter()

        // 用下面的路径:
        maven{
    
     url 'https://maven.aliyun.com/repository/google' }
        maven{
    
     url 'https://maven.aliyun.com/repository/jcenter' }
        maven{
    
    url 'http://maven.aliyun.com/nexus/content/groups/public'}
        
    }
}

rootProject.buildDir = '../build'
subprojects {
    
    
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    
    
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    
    
    delete rootProject.buildDir
}

As you can see, I commented out google() / jcenter() and replaced them with three absolute addresses.

test

At this time, it is best to restart the editor or restart the computer, and then perform Debug (debugging), and it will never report an error again.


My blog will soon be synchronized to the Tencent Cloud developer community, and everyone is invited to join: https://cloud.tencent.com/developer/support-plan?invite_code=2h27kafz2y4gw

Guess you like

Origin blog.csdn.net/m0_68669764/article/details/128370211