flutter_barcode_scanner
flutter_barcode_scanner copied to clipboard
jcenter dependency causing build issues
Describe the bug Build of a flutter project using flutter_barcode scanner fails with the following errors (and more follow-up errors):
FAILURE: Build failed with an exception.
- What went wrong: A problem occurred configuring project ':flutter_barcode_scanner'.
Could not resolve all artifacts for configuration ':flutter_barcode_scanner:classpath'. Could not resolve org.ow2.asm:asm:7.0. Required by: project :flutter_barcode_scanner > com.android.tools.build:gradle:4.1.3 project :flutter_barcode_scanner > com.android.tools.build:gradle:4.1.3 > com.android.tools.build:builder:4.1.3 project :flutter_barcode_scanner > com.android.tools.build:gradle:4.1.3 > org.ow2.asm:asm-commons:7.0 project :flutter_barcode_scanner > com.android.tools.build:gradle:4.1.3 > org.ow2.asm:asm-util:7.0 > Could not resolve org.ow2.asm:asm:7.0. > Could not get resource 'https://jcenter.bintray.com/org/ow2/asm/asm/7.0/asm-7.0.pom'. > Could not HEAD 'https://jcenter.bintray.com/org/ow2/asm/asm/7.0/asm-7.0.pom'. Received status code 502 from server: Bad Gateway
To Reproduce
To manually reproduce: try to download the respective file with wget:
wget https://jcenter.bintray.com/org/ow2/asm/asm/7.0/asm-7.0.pom
for me, the download works only in approximately 1 out of 4 trials, otherwise I receive code 502 from the server.
Expected behavior Building for Android should work.
Additional context See this stackoverflow thread about the issue: https://stackoverflow.com/questions/70687342/jcenter-bintray-com-is-down-error-502-bad-gateway The recommended solution is to replace jcenter() with mavenCentral() in the build.gradle file.
I had the same problem when introducing the flutter_barcode_scanner dependency in my pubspec.yaml.
FAILURE: Build failed with an exception.
- What went wrong: A problem occurred configuring project ':flutter_barcode_scanner'.
Could not resolve all artifacts for configuration ':flutter_barcode_scanner:classpath'. Could not resolve com.android.tools.build:gradle:4.1.3. Required by: project :flutter_barcode_scanner
I can't find much documentation about it, so if anyone knows something I would greatly appreciate an answer. The error is a direct consequence of adding the dependency to the pubspec, I have tried to use previous versions and the problem is still there.
I forgot to say that I am working on android, (where I am not supposed to have too many problems ...) both in an emulator and in a physical device and the problems are the same.
@Harbinguer You can look at the pull request I created (just above your post). Until it is integrated into a new release of the flutter_barcode_scanner package, you can either fork it yourself and apply the same change (you just need to replace jcenter() with mavenCentral() in the android/build.gradle file), or use my fork with this change built in: https://github.com/SIVA-Health/flutter_barcode_scanner
Thank you, but that does not solve the problem since the current version of the gradle already has mavenCentral() and not jcenter()... I will continue looking for a solution to this.
@Harbinguer - I don't think so: https://github.com/AmolGangadhare/flutter_barcode_scanner/blob/master/android/build.gradle (still has jcenter() - or am I missing something?)
This is the build.gradle file of my project, which already has mavenCentral by default... I have tried to change to jcenter but the gradle itself already says that it is not advisable to use it. I'm trying to check the pubspec.yaml and flutter_barcode_scanner.iml files of your code to see if I can fix anything.
buildscript { ext.kotlin_version = '1.6.10' repositories { google() mavenCentral() }
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects { repositories { google() mavenCentral() } }
rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') }
task clean(type: Delete) { delete rootProject.buildDir }
I'm going to start the project from scratch to see if my problem comes from somewhere else, I'll write you with the possible solution as soon as I have it. Thanks again ;)
@Harbinguer - your build.grade file is used for your own parts of the code. If you integrate a package, the package's build.gradle will be used for building the package code. That's why changing your own build.gradle does not help - and you should definitely keep it on mavenCentral().
To make also the package use mavenCentral() you need to modify the package, which is what I did in my fork.
If you want to try it, you can just put this in you pubspec.yaml instead of the regular entry for the package:
flutter_barcode_scanner:
git:
url: git://github.com/SIVA-Health/flutter_barcode_scanner.git