Capacitor TargetSdk 31 with isFromMockProvider always return false

I have been using capacitor v2.4.2 with target SDK 31, and want to use isFromMockProvider() to detect if a user enables mock location or not. but the result always returns false.

  1. I’m trying to use IsMock() but when I build the project, the build is failed with the following error
  if (location.isMock() == true) {
  symbol:   method isMock()
  location: variable location of type Location
  1. then I tried another way , I try to change compileSdkVersion to 31, and I got error like this
An exception has occurred in the compiler (1.8.0_202). Please file a bug against the Java compiler via the Java bug reporting page ( after checking the Bug Database ( for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class$NameImpl)

is there any other way to detect if a user enables mock location or not on their devices with target SDK 31?