title: Flutter how to build APK
body: <p>I'm created an empty flutter project. Flutter installed success. And I'm created an empty project, but I can't build an APK and start my application on Android device when I connect my phone through USB.</p>
  <p>And after building apk I'm getting an error:</p>
  <pre><code>Building with sound null safety
  
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  A problem occurred configuring root project 'android'.
  &gt; Could not resolve all artifacts for configuration ':classpath'.
     &gt; Could not download gradle-4.1.0.jar (com.android.tools.build:gradle:4.1.0)
        &gt; Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.0/gradle-4.1.0.jar'.
           &gt; Premature end of Content-Length delimited message body (expected: 6�041�440; received: 4�456�416)
     &gt; Could not download builder-4.1.0.jar (com.android.tools.build:builder:4.1.0)
        &gt; Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/builder/4.1.0/builder-4.1.0.jar'.
           &gt; Premature end of Content-Length delimited message body (expected: 9�546�513; received: 6�553�552)
     &gt; Could not download bundletool-0.14.0.jar (com.android.tools.build:bundletool:0.14.0)
        &gt; Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/0.14.0/bundletool-0.14.0.jar'.
           &gt; Premature end of Content-Length delimited message body (expected: 7�826�780; received: 4�456�416)
  
  * 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 1h 23m 34s
  Running Gradle task 'assembleRelease'...                         5015,6s
  [!] Gradle threw an error while downloading artifacts from the network. Retrying to download...
  Checking the license for package Android SDK Build-Tools 29.0.2 in C:\Users\User\AppData\Local\Android\sdk\licenses
  Warning: License for package Android SDK Build-Tools 29.0.2 not accepted.
  Checking the license for package Android SDK Platform 30 in C:\Users\User\AppData\Local\Android\sdk\licenses
  Warning: License for package Android SDK Platform 30 not accepted.
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  Could not determine the dependencies of task ':app:lintVitalRelease'.
  &gt; Could not resolve all dependencies for configuration ':app:lintClassPath'.
     &gt; Could not create task ':app:minifyReleaseWithR8'.
        &gt; Failed to install the following Android SDK packages as some licences have not been accepted.
             platforms;android-30 Android SDK Platform 30
             build-tools;29.0.2 Android SDK Build-Tools 29.0.2
          To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
          Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
  
          Using Android SDK: C:\Users\User\AppData\Local\Android\sdk
  
  * 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 6m 19s
  Running Gradle task 'assembleRelease'...                          380,2s
  Gradle task assembleRelease failed with exit code 1
  </code></pre>
  <p>I'm creating an Android application at first. And I'm haven't an experience.</p>
  <p>What's wrong?</p>
  <p>Thanks a lot.</p>
  <p>I'm fixed an error adding jcenter() to <em>build.gradle</em>. But now I'm getting an error:</p>
  <pre><code> FAILURE: Build failed with an exception.
  
  * What went wrong:
  Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac'.
  &gt; Failed to install the following Android SDK packages as some licences have not been accepted.
       platforms;android-30 Android SDK Platform 30
       build-tools;29.0.2 Android SDK Build-Tools 29.0.2
    To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
    Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
  
    Using Android SDK: C:\Users\User\AppData\Local\Android\sdk
  
  * 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 9s
  </code></pre>