For questions or help we recommend checking:
Note: \AppData\Local\Pub\Cache\hosted\pub.dartlang.org\permission_handler-4..android\src\main\javacombaseflow\permissionhandler\PermissionHandlerPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
same issue here
This should be fixed in version 4.3.0
permission_handler-4.3.0\android\src\main\java\com\baseflow\permissionhandler\PermissionHandlerPlugin.java uses or overrides a deprecated API.
I'm pretty sure it's not
@vanyasem this is not an issue and is actually not used on API versions where this is deprecated. The code block that causes this warning (or NOTE:) is as follows:
private boolean isLocationServiceEnabled(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
final LocationManager locationManager = context.getSystemService(LocationManager.class);
if (locationManager == null) {
return false;
}
return locationManager.isLocationEnabled();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
final int locationMode;
try {
locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE);
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
return false;
}
return locationMode != Settings.Secure.LOCATION_MODE_OFF;
} else {
final String locationProviders = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
return !TextUtils.isEmpty(locationProviders);
}
}
The deprecation warning is given on the lines:
locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE);
and
final String locationProviders = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
As you can see this code is only executed on Android devices running anything lower then Android P (which is where it got deprecated).
This code is just to support backwards compatibility.
In case you would like to verify the above you could simply add the following lines to your android/build.gradle:
allprojects {
...
// Add this block to output details regarding the deprecation warnings.
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}
}
Of course I am open for feedback on how to resolve this warning without giving up on being backwards compatible.
Sorry, wasn't focused enough to actually check the code. You're right
No problem, glad to help
Thank you for pointing me to this ticket, it explains it nicely.
Question, do you know if I can ignore these particular warnings on a package by package basis?
You are welcome, glad the ticket helps to explain the situation.
Regarding your question if you can ignore these warnings on a package by package basis. I would not just trust blindly on it, since it is basically warns that these methods are no longer supported and most likely will be removed from future versions of the platform. So it is a good thing you question it with the library creators.
However if you use the plugin and it works there is no harm in using the plugin. Just make sure you keep on testing the functionality of your App with each new version of the platform (be it Android, iOS or Flutter it self). Which would anyway be something you should do, since you never know if something gets broken.
Most helpful comment
@vanyasem this is not an issue and is actually not used on API versions where this is deprecated. The code block that causes this warning (or NOTE:) is as follows:
The deprecation warning is given on the lines:
and
As you can see this code is only executed on Android devices running anything lower then Android P (which is where it got deprecated).
This code is just to support backwards compatibility.