6

I have a project which running well yesterday, but today, I got this error

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 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 17s
Exception: Gradle task assembleDebug failed with exit code 1

I am not changed any Gradle or manifest today, just the same code from yesterday What I have been done is

  1. Flutter Clean
  2. Invalidate Caches / Restart Android Studio
  3. Update Flutter Version and any Plugin (Currently I am using 2.06 Stable Channel)
  4. Follow This GitHub issue (https://github.com/Baseflow/flutter-geolocator/issues/647) but I got another error while upgrade the Gradle version , something like manifest doesn't found
{{HOME}}\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\permission_handler-7.1.0\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:53: error: cannot find symbol
            status = Environment.isExternalStorageManager()
                                ^
  symbol:   method isExternalStorageManager()
  location: class Environment
{{HOME}}\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\permission_handler-7.1.0\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:222: error: cannot find symbol
                    if (permission == PermissionConstants.PERMISSION_GROUP_MANAGE_EXTERNAL_STORAGE && Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
                                                                                          ^
  symbol:   variable R
  location: class VERSION_CODES
{{HOME}}\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\permission_handler-7.1.0\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:236: error: cannot find symbol
            } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && permission == PermissionConstants.PERMISSION_GROUP_MANAGE_EXTERNAL_STORAGE) {
                                                                   ^
  symbol:   variable R
  location: class VERSION_CODES
{{HOME}}\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\permission_handler-7.1.0\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:238: error: cannot find symbol
                        Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION,
                                ^
  symbol:   variable ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION
  location: class Settings
{{HOME}}\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\permission_handler-7.1.0\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:300: error: cannot find symbol
                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
                                                               ^
  symbol:   variable R
  location: class VERSION_CODES
{{HOME}}\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\permission_handler-7.1.0\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:329: error: cannot find symbol
                    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
                                                                   ^
  symbol:   variable R
  location: class VERSION_CODES
{{HOME}}\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\permission_handler-7.1.0\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:333: error: cannot find symbol
                    return Environment.isExternalStorageManager()
                                      ^
  symbol:   method isExternalStorageManager()
  location: class Environment
{{HOME}}\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\permission_handler-7.1.0\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:64: error: cannot find symbol
            case Manifest.permission.MANAGE_EXTERNAL_STORAGE:
                                    ^
  symbol:   variable MANAGE_EXTERNAL_STORAGE
  location: class permission
{{HOME}}\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\permission_handler-7.1.0\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:225: error: cannot find symbol
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && hasPermissionInManifest(context, permissionNames, Manifest.permission.MANAGE_EXTERNAL_STORAGE ))
                                                                ^
  symbol:   variable R
  location: class VERSION_CODES
{{HOME}}\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\permission_handler-7.1.0\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:225: error: cannot find symbol
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && hasPermissionInManifest(context, permissionNames, Manifest.permission.MANAGE_EXTERNAL_STORAGE ))
                                                                                          ^
  symbol:   variable MANAGE_EXTERNAL_STORAGE
  location: class permission
{{HOME}}\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\permission_handler-7.1.0\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:226: error: cannot find symbol
                    permissionNames.add(Manifest.permission.MANAGE_EXTERNAL_STORAGE);
                                                           ^
  symbol:   variable MANAGE_EXTERNAL_STORAGE
  location: class permission
11 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':permission_handler:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* 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 1m 28s
Exception: Gradle task assembleDebug failed with exit code 1

Additional Information

Flutter Doctor -v

[√] Flutter (Channel stable, 2.0.6, on Microsoft Windows [Version 10.0.19042.746], locale en-US)
    • Flutter version 2.0.6 at D:\SDK\FlutterSDK\flutter
    • Framework revision 1d9032c7e1 (3 days ago), 2021-04-29 17:37:58 -0700
    • Engine revision 05e680e202
    • Dart version 2.12.3

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at D:\SDK\AndroidSDK
    • Platform android-30, build-tools 30.0.3
    • ANDROID_SDK_ROOT = D:\SDK\AndroidSDK
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[√] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] IntelliJ IDEA Ultimate Edition (version 2019.2)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2019.2
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart

[√] Connected device (2 available)
    • Android SDK built for x86 64 (mobile) • emulator-5554 • android-x64    • Android 8.0.0 (API 26) (emulator)
    • Edge (web)                            • edge          • web-javascript • Microsoft Edge 90.0.818.51

android/build.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

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

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
}

Gradle-Wrapper-Properties

#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip

I'm using this latest version package Geolocator

https://pub.dev/packages/geolocator

Update

Change the distribution URL into 
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0-all.zip
Fix my problem 
Don Key
  • 105
  • 1
  • 2
  • 6

3 Answers3

8

Try using the following distributionUrl in your gradle-wrapper.properties: distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip

And the following classpath in dependencies in your build.gradle file: classpath 'com.android.tools.build:gradle:4.1.0

Looking at the Flutter 2.0.5 Stable channel, these are the right settings. This fixed the problem for me.

Shahryar Rafique
  • 1,211
  • 15
  • 35
  • I did that before and got the other error (from this git link, https://github.com/Baseflow/flutter-geolocator/issues/647) Currently I am changing the distributionurl into ```https\://services.gradle.org/distributions/gradle-6.0-all.zip``` and it's work again, and I am using Flutter 2.0.6 Stable Channel – Don Key May 03 '21 at 08:19
  • @DonKey if your answer solves your issue, please post it as an answer and mark it as the solution. – Néstor May 12 '21 at 18:37
  • To get the latest version check this link, it helped me fix my bug to use the latest -all version! https://services.gradle.org/distributions/ – Daniel Silva May 05 '22 at 18:45
8

For me fix my problem by upgrading

compileSdkVersion from 29 to 30

targetSdkVersion from 29 to 30

gradle-wrapper.properties

and my distribution URL is

distributionUrl=https://services.gradle.org/distributions/gradle-6.5-bin.zip

Karzan Kamal
  • 1,074
  • 10
  • 9
0

I found another solution for this by updating the wrapper and plugin for gradle.

distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip

in gradle-wrapper.properties

also update the plugin in root level build.gradle file

classpath 'com.android.tools.build:gradle:4.1.0'
Dharman
  • 30,962
  • 25
  • 85
  • 135
Ishaq Hassan
  • 135
  • 3
  • 9