Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have upgraded OS from Android 10 to Android 11, when I try to run adb push test.txt /mnt/sdcard/, I am getting an error adb: error: stat failed when trying to push to /mnt/sdcard/test.txt: Permission denied.

In AndroidManisfest.xml I have given all below permissions:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:requestLegacyExternalStorage="true">

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.6k views
Welcome To Ask or Share your Answers For Others

1 Answer

According to android doc.

Apps that run on Android 11 but target Android 10 (API level 29) can still request the requestLegacyExternalStorage attribute.

So try to change your target API level. Recommended way would be to use ContentResolver or can say Scoped storage instead of Legacy deprecated storage APIs.

Check out this for more details. Scoped storage enforcement


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...