close

[Solved] Execution failed for task ‘:geolocator_android:compileDebugJavaWithJavac’ in flutter

Hello Guys How are you all? Hope You all are fine. When I was trying to run my flutter app and suddenly I get the following error in my stack track. Execution failed for task ‘:geolocator_android:compileDebugJavaWithJavac’ in a flutter. So today Here I come with all possible solutions for this error.

We are providing you all possible solutions to solve this error. let’s start this article without wasting your time.

How Execution failed for task ‘:geolocator_android:compileDebugJavaWithJavac’ in flutter Error Occurs ?

I am trying to run my code and I am facing following error.

C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\geolocator_android-2.0.0\android\src\main\java\com\baseflow\geolocator\location\LocationMapper.java:29: error: cannot find symbol
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
                                                    ^
  symbol:   variable S
  location: class VERSION_CODES
C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\geolocator_android-2.0.0\android\src\main\java\com\baseflow\geolocator\location\LocationMapper.java:30: error: cannot find symbol
      position.put("is_mocked", location.isMock());
                                        ^
  symbol:   method isMock()
  location: variable location of type Location
2 errors

FAILURE: Build failed with an exception.

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

How to Solve Execution failed for task ‘:geolocator_android:compileDebugJavaWithJavac’ in flutter Error?

  1. Execution failed for task ':geolocator_android:compileDebugJavaWithJavac' in flutter

    to Solve Execution failed for task ':geolocator_android:compileDebugJavaWithJavac' in flutter Error This error occurs in latest version of geolocator 7.7.0. To solve this error you just need to Change compileSDKVersion from 29 to 31. Just like this. And then just make sure This both should be in your gradle.properties. Second solution is This error occurs only in new version of geolocator so just downgrade geolocator to 6.2.1 and your error will be solved.

  2. How to Solve Execution failed for task ':geolocator_android:compileDebugJavaWithJavac' in flutter Error?

    to Solve Execution failed for task ':geolocator_android:compileDebugJavaWithJavac' in flutter Error This error occurs in latest version of geolocator 7.7.0. To solve this error you just need to Change compileSDKVersion from 29 to 31. Just like this. And then just make sure This both should be in your gradle.properties. Second solution is This error occurs only in new version of geolocator so just downgrade geolocator to 6.2.1 and your error will be solved.

Solution 1: Change compileSDKVersion from 29 to 31

This error occurs in latest version of geolocator 7.7.0. To solve this error you just need to Change compileSDKVersion from 29 to 31. Just like this.

android {

    compileSdkVersion 31
    defaultConfig {
        minSdkVersion 21 
        targetSdkVersion 29
    }
}

And then just make sure This both should be in your gradle.properties.

android.useAndroidX=true
android.enableJetifier=true

Solution 2: Downgrade geolocator 6.2.1

This error occurs only in new version of geolocator so just downgrade geolocator to 6.2.1 and your error will be solved.

Summery

So, It’s All About This Error. I hope this tutorial helps you to Solve your error. Please Comment Below if You stucks anywhere with my code. And please comment below on which solution worked for you. Thank You.

Also Check Out Below Tutorials

Leave a Comment

%d bloggers like this: