-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Deprecated API Usage in Vibration Plugin for Android #111
Comments
Any updates? Issue persists and we can see deprecation messages on app build if we use java compiler option |
I'm still not sure if it's a good idea to remove the methods, since they're usage is already conditional and Flutter itself supports Android versions below 8. |
Oh I see, maybe suppressing deprecation will work? Just looked for this problem on google and it seems that java compiler can't recognize that api is conditional unless there's an explicit annotation on it... One more point, there's one warning that is not connected to vibrate method: Found solution on stack overflow: |
I'll try using @TargetApi annotation tomorrow. Will see how it works. Suppression didn't help - it was there in the previous version of the plugin. |
Sorry for the long wait. The recent release 3.1.0 have fixed a lot of previous issues. Here is the full changelog:
Let me know if the issue persists. Thank you! |
The VibrationPlugin.java file in the vibration plugin (version 2.0.1) is using or overriding deprecated APIs in Android, which triggers warnings during build. The plugin needs to be updated to use modern APIs, specifically handling Android API levels that have deprecated the older vibration methods (e.g., Vibrator.vibrate(long)).
The proposed fix is to replace the deprecated methods with newer equivalents, such as VibrationEffect.createOneShot() introduced in API level 26 (Android 8.0), while maintaining backward compatibility with older Android versions.
What to fix:
The text was updated successfully, but these errors were encountered: