guys, when I tried to run my application on real device but I found that error after upgrading to 1.22.2:
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://jcenter.bintray.com/com/google/android/gms/play-services-location/maven-metadata.xml. > Could not get resource 'https://jcenter.bintray.com/com/google/android/gms/play-services-location/maven-metadata.xml'. > Could not GET 'https://jcenter.bintray.com/com/google/android/gms/play-services-location/maven-metadata.xml'. > Read timed out
- 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.
my android\app\build.gradle:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "io.bujupah.hestia"
minSdkVersion 17
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation 'com.google.android.gms:play-services-auth:16.0.1'
testImplementation'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.17.0'
implementation 'com.android.support:multidex:1.0.3'
}
my android\build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and when I run flutter --version:
Flutter 1.22.4 • channel stable • https://github.com/flutter/flutter.git Framework • revision 1aafb3a8b9 (4 months ago) • 2020-11-13 09:59:28 -0800 Engine • revision 2c956a31c0 Tools • Dart 2.10.4
my location plugin:
# flutter_map_marker_cluster: any
flutter_polyline_points: ^0.2.4
geolocator: ^6.1.1
geocoding: ^1.0.5
location: ^3.0.2
The solution is update
dependencies {
com.android.tools.build:gradle:3.6.2
}
to
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
then update distributionUrl to be
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
The Website is down for maintenance, look for jcenter() alternative or wait until they fix the issue.
replacing Jcenter()
with mavenCentral()
works for me.
repositories {
google()
mavenCentral() // Add this
jcenter() // remove this
}
for those of you who haven't solved the problem with AzizDev's solution, try this solution:
maybe some of your dependencies are outdated.. so, run this command in terminal to upgrade them and then run the project
flutter pub upgrade --major-versions
I tried all the solutions but nothing worked for me. The only way to pass this issue is turning off the WIFI and run the project.
this below changes work for me
//Project level build.gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.+'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
}
}
//App level build.gradle
configurations.all {
resolutionStrategy {
force 'com.google.android.gms:play-services-location:16.0.0'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics:17.2.2'
implementation 'com.google.android.gms:play-services-location:16.0.0'//add this line
}
Just check gradle versions in your flutter project, like this:
/android/build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
...
}
/android/gradle/wrapper/gradle-wrapper.properties:
...
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
I have the same problem. Please help me to solve it. I already try using all above methods, but it not
have the same problem. I tried with many solution that Developers say. But, it still had problem. Now, I removed location: ^3.0.2. It work fine now.
Go to your.pub-cache/hosted/pub.dartlang.org/ go to your plugin and then go to android folder/ change version of your com.google.android.gms:play-services-location:16.+ to specific version . And then it will work perfect
NOTE: Your.pub/cache folder path should be different in windows, Also you will need to unhide.pub-cache folder if it is hidden
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.