Daliya chacko
Daliya chacko

Reputation: 159

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.

Upvotes: 3

Views: 7907

Answers (2)

Bhabani P
Bhabani P

Reputation: 1361

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

this may help you.

Upvotes: 3

jcesarmobile
jcesarmobile

Reputation: 53301

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

Upvotes: 11

Related Questions