'Error : package android.support.annotation does not exist in ionic 5 by using sms-retriever

I am using sms-retriver for getting app hash string and I'm getting an error

package android.support.annotation does not exist

And I resolved this error by changing

import android.support.annotation.NonNull;

above code to the below code

import androidx.annotation.NonNull;

The change is happening in the file path

android\capacitor-cordova-android-plugins\src\main\java\com\codingsans\ionic\smsRetriever\AndroidSmsRetriever.java

This file is not able to push into repository and getting the same error in the ionic hub.



Solution 1:[1]

That happens when a cordova plugin uses the old android support libraries instead of the new AndroidX support libraries. Capacitor uses AndroidX and you can't use non AndroidX libraries. You can use jettifier to patch the plugins

npm install jetifier
npx jetify
npx cap sync android

https://capacitorjs.com/docs/v3/android/troubleshooting#error-package-androidsupport-does-not-exist

Solution 2:[2]

ionic cordova plugin add cordova-plugin-androidx
ionic cordova plugin add cordova-plugin-androidx-adapter

this may help you.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jcesarmobile
Solution 2 Bhabani P