5

I want to grant android.permission.CHANGE_CONFIGURATION to my apk file.

adb command i used:

adb shell pm grant myPackageName android.permission.CHANGE_CONFIGURATION

but there is always the same error again and again:

Operation not allowed: java.lang.SecurityException: myPackageName has not requested permission android.permission.CHANGE_CONFIGURATION

Manifest.xml

<uses-sdk 
    android:minSdkVersion="14" 
    android:targetSdkVersion="22"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" /> 

Permissions are already granted:

grantedPermissions:
  android.permission.READ_EXTERNAL_STORAGE
  android.permission.GET_TASKS
  android.permission.WRITE_EXTERNAL_STORAGE
  android.permission.ACCESS_WIFI_STATE
  android.permission.RECEIVE_SMS
  android.permission.READ_CONTACTS
  android.permission.GET_ACCOUNTS
  android.permission.CALL_PHONE
  android.permission.WRITE_CONTACTS
  android.permission.AUTHENTICATE_ACCOUNTS
  android.permission.READ_PHONE_STATE
  android.permission.READ_SMS
  android.permission.RECEIVE_BOOT_COMPLETED
  android.permission.CAMERA
  android.permission.ACCESS_FINE_LOCATION
  android.permission.MANAGE_ACCOUNTS
  android.permission.BROADCAST_STICKY
  android.permission.RECORD_AUDIO
  android.permission.WAKE_LOCK
  android.permission.ACCESS_NETWORK_STATE
  android.permission.USE_CREDENTIALS
  com.skype.android.app.permission.C2D_MESSAGE
  com.google.android.c2dm.permission.RECEIVE
  android.permission.MODIFY_AUDIO_SETTINGS
  android.permission.READ_SYNC_STATS
  android.permission.READ_PROFILE
  android.permission.DISABLE_KEYGUARD
  android.permission.WRITE_SYNC_SETTINGS
  android.permission.SYSTEM_ALERT_WINDOW
  android.permission.WRITE_SETTINGS
  android.permission.BLUETOOTH
  android.permission.INTERNET
  android.permission.CHANGE_WIFI_STATE
  com.skype.permission.ACCOUNT
  android.permission.READ_SYNC_SETTINGS
  android.permission.VIBRATE
  com.skype.android.app.permission.RECEIVE_ADM_MESSAGE

What is the solution for this? Posts on google does not help me. Thanks in advance.

Almett
  • 876
  • 2
  • 11
  • 34
  • http://stackoverflow.com/questions/21091022/listing-permissions-of-android-application-via-adb – IntelliJ Amiya Nov 11 '15 at 05:30
  • 1
    @IntelliJAmiya This link is not for granting permissions ,is display permissions. I mean i got this error when i grant permissions. – Almett Nov 11 '15 at 06:19
  • Which device and version of Android are you using? I've tested the `pm grant` command on a Nexus 6 using Android 6 (MRA58N), it worked. – cuihtlauac Nov 14 '15 at 09:48
  • @cuihtlauac I am using nexus 5 Android 4.4, it doesn't work. I don't know why?Do you have any idea? – Almett Nov 14 '15 at 16:44

2 Answers2

0

My phone is running android pie and it isn't rooted. An app that i installed required me to grant it permissions using adb. Initially I got the error

java.lang.SecurityException: grantRuntimePermission: Neither user 2000 nor current process has android.permission.GRANT_RUNTIME_PERMISSIONS.

After searching my developer options, one seemed interesting - Disable permission monitoring. It wasn't enabled. After enabling, ran the command

adb -d shell pm grant packageName android.permission.DUMP

It worked!

adiga
  • 34,372
  • 9
  • 61
  • 83
Yashas
  • 809
  • 8
  • 16
0

if you need grant in android 10+ ,plase try on usb debugging(safe mode) or usb install ,because my device is android 11 on Redmi 11

---- on off use grant ------

Exception occurred while executing 'grant':
java.lang.SecurityException: grantRuntimePermission: Neither user 2000 nor current process has android.permission.GRANT_RUNTIME_PERMISSIONS.
    
FelixYu
  • 1
  • 1