In this post, we are going to show you how to solve VERSION_CODES error in Android Flutter App. This error occurs, when compileSdekVersion is lower than the needed version:
C:\Users\Hari Pd. Chaudhary\Documents\flutter_sdk\flutter\.pub-cache\hosted\pub.dartlang.org\geolocator_android-3.0.0+4\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:\Users\Hari Pd. Chaudhary\Documents\flutter_sdk\flutter\.pub-cache\hosted\pub.dartlang.org\geolocator_android-3.0.0+4\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.
* 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 30s
Running Gradle task 'assembleDebug'... 31.5s
Exception: Gradle task assembleDebug failed with exit code 1
Open the file android/app/src/build.gradle and increase compileSdkVersion:
android {
compileSdkVersion 31
In our case, it was 30
when the error was occurring, we increase it to compileSdkVersion 31
, the error is solved. You can increase it but 1 each time until your error is not solved.
Or, identify the package or plugin which is creating the problem, and know which compileSdkVersion is needed for and Change the version value according to it.
Now Hit, the command in terminal to clear build cache:
flutter clean
In this way, you can solve version code errors in Flutter Android App.
Please Wait...
No any Comments on this Article