Flutter build apk: Could not resolve all artifacts for configuration ':classpath' - flutter

I installed flutter a few moments ago but I get this error when I want to run the flutter project:
Building with sound null safety
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 find com.android.tools.build:gradle:4.1.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.0/gradle-4.1.0.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/4.1.0/gradle-4.1.0.pom
Required by:
project :
* 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 5s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 6.9s
Gradle task assembleRelease failed with exit code 1
ScreenShot

Post your build gradle file. Most likely you added classpath 'com.android.tools.build:gradle:4.1.0 in the wrong place. it should be added to android/build.gradle and not to android/app/build.gradle
Should look like this:
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
.
.
.
}

Related

Getting this error in flutter after import flutter_pdfview package

FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find com.github.barteksc:android-pdf-viewer:3.2.0-beta.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/github/barteksc/android-pdf-viewer/3.2.0-beta.1/android-pdf-viewer-3.2.0-beta.1.pom
- https://repo.maven.apache.org/maven2/com/github/barteksc/android-pdf-viewer/3.2.0-beta.1/android-pdf-viewer-3.2.0-beta.1.pom
- https://storage.googleapis.com/download.flutter.io/com/github/barteksc/android-pdf-viewer/3.2.0-beta.1/android-pdf-viewer-3.2.0-beta.1.pom
Required by:
project :app > project :flutter_pdfview
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 26s
Exception: Gradle task assembleDebug failed with exit code 1
I had the same problem until I added jcenter() in my project-level build.gradle file, you do the same, and voila!! it will work
Same problem here, it seems like they changed some files in the API but they didn't solve it in the package.
I tried to visit the next URL for example, and I've reached the following path
https://repo.maven.apache.org/maven2/com/github/barteksc
where I noticed that the files have changed.

Unable to build an apk in flutter

I am trying to build an api from my flutter project, last month it was fine when I was doing flutter build apk, but not for now... I am not able to do that and here is the error log
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:releaseCompileClasspath'.
> Could not resolve com.google.android.gms:play-services-location:16.+.
Required by:
project :app > project :location
> Failed to list versions for com.google.android.gms:play-services-location.
> Unable to load Maven meta-data from https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml.
> Could not get resource 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml'.
> Could not GET 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml'. Received status code 403 from server: Forbidden
* 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 33s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 34.3s
Gradle task assembleRelease failed with exit code 1
here is my android/build.gradle: https://gist.github.com/wahyu-handayani/959de3306aa1410c1b9b78ad927cc35c
Try to update your gradle wrapper to:
distributionUrl=https://services.gradle.org/distributions/gradle-6.7.1-all.zip

FAILURE: Build failed with an exception. * What went wrong: Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'

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 find com.google.firebase:firebase-analytics:.
Required by:
project :app
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 45s
Exception: Gradle task assembleDebug failed with exit code 1
I am not really sure but try to :
Set your java SDK location in project settings
upgrade your buildToolsVersion in your build.gradle file. See which version is the latest and set it to that.
If neither of these methods work , save your project in a repository and re-download android studio if it comes to that.
You can even visit this thread and see if any of the methods solve your problem : Execution failed for task ':app:compileDebugJavaWithJavac' Android Studio 3.1 Update

Could not resolve all task dependencies for configuration ':google_sign_in:debugCompileClasspath'

App was working completely fine but suddenly it is invoking the following issue.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':google_sign_in:compileDebugAidl'.
> Could not resolve all task dependencies for configuration ':google_sign_in:debugCompileClasspath'.
> Could not resolve project :google_sign_in_web.
Required by:
project :google_sign_in
> Unable to find a matching configuration of project :google_sign_in_web:
- None of the consumable configurations have attributes.
* 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 2s
Finished with error: Gradle task assembleDebug failed with exit code 1
I have imported the latest google_sign_in package in pubspec.yaml but still facing the same build failed error. Any help please!
Solved it by running following command in flutter terminal:
flutter pub cache repair
All of the packages were downloaded and re-installed again.

Running Gradle task 'assembleDebug'... [Fatal Error] aapt2-3.5.0-5435860.pom:2:1: Content is not allowed in prolog

No errors when flutter doctor command was executed. I tried with updating Gradle with the latest version 6.4 and setting at env variable path as well, in the dist folder as well it is showing correctly.
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-bin.zip
android/app/build.gradle
- compileSdkVersion 28
- targetSdkVersion 28
android/build.gradle
google() is added to allprojects and buildscript.repositories
I tried all approaches mentioned in similar kind of queries in StackOverflow and other platforms but of no use, I am totally stuck here.
how to resolve this error?
On flutter run command following ERROR is what I get:
Running Gradle task 'assembleDebug'...
[Fatal Error] aapt2-3.5.0-5435860.pom:2:1: Content is not allowed in prolog.**
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
> Could not resolve com.android.tools.build:aapt2:3.5.0-5435860.
Required by:
project :app
> Could not resolve com.android.tools.build:aapt2:3.5.0-5435860.
> Could not parse POM https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.5.0-5435860/aapt2-3.5.0-5435860.pom
> Content is not allowed in prolog.
* 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 22s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 401.6s (!)
Exception: Gradle task assembleDebug failed with exit code 1