flutter_sms icon indicating copy to clipboard operation
flutter_sms copied to clipboard

PlatformException(device_not_capable, The current device is not .......

Open makis73 opened this issue 4 years ago • 11 comments

Hello and congrats for your work ! 2.3.1 works on Android 6 - 11 but not on Android 5 ! PlatformException(device_not_capable, The current device is not ....... ! Your example also. Why can this happens ? Something about permissions ?

makis73 avatar Apr 11 '21 20:04 makis73

It does not work on Andriod 11 for me.

tilakdewangan avatar Jun 21 '21 17:06 tilakdewangan

@tilakdewangan @makis73

You need to update your Manifest file with

<uses-permission android:name="android.permission.SEND_SMS" />
<queries>
    <intent>
        <action android:name="android.intent.action.SENDTO" />
        <data android:scheme="smsto"/>
    </intent>
</queries>

And request SMS permission at runtime.

vizhan-lanars avatar Jul 06 '21 08:07 vizhan-lanars

@vizhan-lanars Thanks for your answer. I tested and found out that we only need the <queries> tag, not the runtime SEND_SMS permission itself.

<!-- SEND_SMS runtime permission not needed -->
<queries>
    <intent>
        <action android:name="android.intent.action.SENDTO" />
        <data android:scheme="smsto"/>
    </intent>
</queries>

rohan20 avatar Nov 10 '21 17:11 rohan20

@vizhan-lanars Thanks for your answer. I tested and found out that we only need the <queries> tag, not the runtime SEND_SMS permission itself.

<!-- SEND_SMS runtime permission not needed -->
<queries>
    <intent>
        <action android:name="android.intent.action.SENDTO" />
        <data android:scheme="smsto"/>
    </intent>
</queries>

Thanks for this, it worked.

albrewot avatar Jul 12 '22 18:07 albrewot

WHERE TO PASTE THIS IN WHICH SECTION?

Arjun2002tiwari avatar Nov 06 '22 18:11 Arjun2002tiwari

WHERE TO PASTE THIS IN WHICH SECTION?

In android/app/src/main and it's AndroidManifest.xml

savalet avatar Jan 11 '23 17:01 savalet

WHERE TO PASTE THIS IN WHICH SECTION?

In android/app/src/main and it's AndroidManifest.xml

Directly after or insite application tag ?

baimamboukar avatar Mar 30 '23 02:03 baimamboukar

The queries tag in the Android manifest.xml file should be placed outside the application tag.

Here's an example of the correct placement of the queries tag in the Android manifest.xml file:

<manifest ... > <application ... >

<queries>
     <intent>
         <action android:name="android.intent.action.SENDTO" />
         <data android:scheme="smsto"/>
     </intent>
</queries>

Placing the queries tag inside the application tag will result in a compilation error.

damolator avatar Apr 04 '23 16:04 damolator

This Worked for me on Pixel 6 Android 13. Thx

Terrence-Beckham avatar Jul 09 '23 09:07 Terrence-Beckham

Thanks @vizhan-lanars , my app was working perfectly fine before adding your suggested extra code but a week ago it stopped sending sms with the platform exception and I tried your solution and it worked :)

Also would appreciate any possible explanations to my query that : app was working perfectly fine before , with only single line config of :- <uses-permission android:name="android.permission.SEND_SMS" /> but stopped working a week ago and now today after adding these lines :-

<queries>
     <intent>
         <action android:name="android.intent.action.SENDTO" />
         <data android:scheme="smsto"/>
     </intent>
</queries>

to above-old configuration , the app started working fine again..!!!! what could be the reason for the same?

jineshpatel2002 avatar Jul 28 '23 18:07 jineshpatel2002

In addition to the lines provided by @vizhan-lanars (thank you!!!!!!) I had to manually give the app permissions on my phone (by going to Settings -> Permission Manager -> SMS -> allow <APP NAME>) to actually send the message without opening the app (using the sendDirect parameter of _sendSMS). Otherwise, it works! (by opening the messaging app of my phone).

EDIT: Upon further read of the code here: https://github.com/fluttercommunity/flutter_sms/issues/67#issue-1275608493 I was able to add a runtime permission request using permission_handler and it solved my issue. Hope this helps!

thefirebanks avatar Aug 17 '23 06:08 thefirebanks