I installed this plug-in yesterday and tried the getCurrentPosition and getLastKnownPosition features. It worked just as expected. Then I did other non-related changes in my project (updated an asset) and when I tried to build again I got this error.
Execution failed for task ':geolocator:compileDebugJavaWithJavac'.
Unable to find source java class: '/Users/lauraroige/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/geolocator-1.5.0/android/src/main/java/com/baseflow/flutter/plugin/geolocator/tasks/CurrentLocationTask.java' because it does not belong to any of the source dirs: '[/Users/lauraroige/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/geolocator-1.6.0/android/src/main/java, /Users/lauraroige/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/geolocator-1.6.0/android/src/debug/java, /Users/lauraroige/ecolocal_app/ecolocal_app/build/geolocator/generated/source/r/debug, /Users/lauraroige/ecolocal_app/ecolocal_app/build/geolocator/generated/source/buildConfig/debug, /Users/lauraroige/ecolocal_app/ecolocal_app/build/geolocator/generated/source/aidl/debug, /Users/lauraroige/ecolocal_app/ecolocal_app/build/geolocator/generated/source/rs/debug]'
I tried changing the version of the plug-in, but when I delete the directory and install it again it always installs the 1.6.0 version regardless of what I try to install (tried with version 1.4.0 as the error mentions versions 1.5.0 and 1.6.0).
The project builds correctly if I eliminate the geolocator import from the pubspec. The build fails as soon as I add the import (even if I don't use it in the project code).
Build correctly.
Add the plug-in to a project.
Version: 1.6.0
Platform:
Can you try to execute:
flutter clean
and then build your project?
@lroige, as @audkar mentioned running flutter clean should solve this problem. Here is what (most probably) happened:
pubspec.yaml you probably registered the dependency to the Geolocator plug-in as geolocator: '^1.5.0' (meaning all version bigger then 1.5.0 and smaller then 2.0.0);So when we released version 1.6.0, Flutter automatically updated the Geolocator package in your project. Unfortunately when updating the package the cache is not updated and still holds a reference to the 1.5.0 version causing the conflict you experienced. Running the flutter clean command will reset the cache and make sure the new version will be cached resolving your problem.
Most helpful comment
Can you try to execute:
and then build your project?