简体   繁体   中英

cannot run ADB: the operation requires elevation

I recently started learning React-Native and was trying to run a project on Android emulator.However, this was succeeded at the first attempt, but now It doesn't, throwing the following error.

Execution failed for task ':app:installDebug'.

java.io.IOException: Cannot run program "C:\\Users\\Pavindu\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe": CreateProcess error=740, The requested operation requires elevation

Since this is a well known error message,I could find lot of answers regarding this error.The following were the actions I took according to those answers.But none of those helped me.

  1. Running both android studio and cmd as administrator
  2. Running cmd /c react-native run-android
  3. Deleting node_modules and npm install

It is a great favor done,if anyone can help me in this case.Thanks in advance.

It appears to be an Android emulator problem.

Change the AVD setting to use "Use Host GPU."

That'll solve the problem.

gpu图像

Select 'Hardware GLES 2.0' to enable host GPU

After struggling a lot, here is what I did to overcome the problem.

  • Copied /Sdk folder and pasted it in a different location while keeping the old SDK folder there.
  • Deleted platform-tools folder in copied SDK folder
  • downloaded platform-tools from android site and added it to new SDK folder.
  • set new SDK location to ANDROID_HOME (I use windows)

and android/build.properties file in my react-native project.

sdk.dir="C:\\\\path\\\\to\\\\new\\\\sdk"

When I run react-native run-android after these steps,all started working fine.

Note: I know that this seems hacky, but as a help for someone, I decided to write this .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM