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.
Running both android studio and cmd as administrator
Running cmd /c react-native run-android
Deleting node_modules and npm install
It appears to be an Android emulator problem.
Change the AVD setting to use "Use Host GPU."
That'll solve the problem.
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 .
Related
I've been looking and googling for a while and couldn't find a fitting answer, I've tried different commands through the terminal, as was suggested in some forums but nothing really helped.
I have this issue for some reason only with a specific project, other flutter projects that I have are running with no issues at all
For Example, I've tried to run this in the terminal and this is what I got:
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project
Any help, suggestions, and recommendations would be much appreciated
This problem is due to the fact that you are running the flutter run command from a different directory. Usually, when you try this command, you are in the parent directory instead of the root directory.
Try running the flutter run command from the project directory using the cd YOUR_ROOT_DIRECTORY command you can enter to that directory.
decided to reinstall android studio and make sure that everything is correct with the PATH of the SDK, and reinstalled the SDK tools.
pretty much worked for some reason
So while installing flutter and Android Studio. I did encounter several problems. First is the "Exception: Gradle task assembleDebug failed with exit code -1" when i run the program. this thing always appears in my runs no matter which folder/emulator I do. So I tried to go and check several videos. including uploaded by BD Technic(youtube) how to fix this kinds of problem. I also went to SDK Manager and check if the SDK Command-line tools are check. I check and the problem is still there. i tried to recheck and the problem is still there. Then I uncheck the Hide Obselete Package and see if the Android SDK tools(obselete) was check(according to BD Technic) and the problem IS still there.
So I decided to go use the Flutter Doctor --android-licenses and shows that the problem(screenshot) is this.
I went to the folder and see if maybe it was bugged/corrupted then I realized...I don't have the SDKmanager folder...
normally when you run this android-license it should run differently and show "Accept [y/n]" base on youtube videos I watched.
So my question is 2: How to fix "Exception:Gradle Task..."?knowing my license isn't working. I tried several guide and it has a similar problem. I'm not sure if having missing SDK Manager is the solution or maybe after you install the license it should be created instead. I have literally different problem compare to other people posting AndroidStudio errors when it comes to exception:gradle task
do I just need to reinstall the entire android studio? as well as the flutter.
you should check the following things:
Java JDK setup and add it (JAVA_HOME) to environment variables ( Windows operating system).
Install a Gradle and add it to the environment variables (GRADLE_HOME).
Install the SDK Android and to add it to the environment variables (ANDROID_HOME).
Then The command is executed in Flutter cmd
flutter doctor --android-licenses
I hope I helped you
source !
I'm configuring my build pipeline for an Android project. So far, all of my steps are working perfectly on Hosted VS2017 agent, including fetching the code, building with gradlew, publishing the artifact and deploying it to AppCenter.
However, on Hosted Ubuntu 1604, there are a few problems with gradlew step.
On VS2017 agent, this works with just: .\gradlew assembleDebug
On Ubuntu 1604, this is what I'm having right now:
chmod 775 gradlew
chmod 775 /usr/local/lib/android/sdk --> The fix I'm working on
./gradlew assembleDebug
Running the build without the 2nd line, agent will throw this exception:
What went wrong: A problem occurred configuring project ':app'.
Failed to install the following SDK components: build-tools;28.0.3 Android SDK Build-Tools 28.0.3
The SDK directory is not writable (/usr/local/lib/android/sdk)
I'm a beginner with Ubuntu... why is it not writable? I tried to chmod but I got the exception while doing so: chmod: changing permissions of '/usr/local/lib/android/sdk': Operation not permitted.
Which direction should I look at to solve this problem now... ? Thank you all in advance!
Change the ownership of Android SDK:
sudo chown -R $(whoami) $ANDROID_HOME
I had the same problem on a standard Ubuntu install.
The solution: install the Android SDK in your home directory.
The problem is, building a project with Gradle fails to work with a read-only SDK. Installing the Android SDK with apt leaves it read-only.
More precisely, everything in /usr/ is supposed to be read-only data, so it's owned by root with permissions set to 755. Your user doesn't have write access to it, only the owner does. Installing the SDK in your home directory (and making sure your user owns it) should solve the issue.
Installing the SDK
I haven't seen a good way to install just the SDK. There's another SO question addressing this; one of the ways listed there ought to work.
However, you may find it easier to just install Android Studio, and pick a custom location for the SDK.
Hope it helps!
there is no need to reinstall something at all...
giving the write privilege to the currently logged in user solves the problem.
I have just downloaded the Android SDK Command Line tools for Windows (26.0.2). I am attempting to download selected SDK components using \tools\bin\sdkmanager.bat, as well as updating \tools. The installation fails with the following message:
Warning: An error occurred during installation: Failed to move away or delete existing target file: C:\testinstall\sdk\tools
Move it away manually and try again..
I don't see how I can remove \tools manually because it contains \bin\sdkmanager.bat.
Screenshot of the sdkmanager command:
All other components appear to install without error. See below for the components specified in my package file:
Yeah that's quite funny. A way to do that is to copy the tools folder to another place (let's say C:\temp\). Then direct into the C:\temp\tools\bin\, open the cmd prompt there and run your update commands as such:
sdkmanager.bat --sdk_root=sdkRootPath --command
Where sdkRootPath is path to your original SDK folder (C:\testinstall\sdk\). Once that is done, delete the C:\temp\tools\ copied folder.
You could temporarily rename to tools.old, run it to install new version in tools and then remove the old one.
cd YOUR-ANDROID-SDK-LOCATION
ren tools tools.old
tools.old\bin\sdkmanager.bat "tools"
dir tools*
del tools.old /q /s
tools\bin\sdkmanager.bat --list
it might be permission issue.Can you try doing sudo or if you on windows try to run terminal as administrator.
I have seen issues where the program is not able to delete the folder either due to lock or some weird reason.
Run cmd in root c:.
c:\>testinstall\sdk\tools\bin\sdkmanager --package_file=c:\testinstall\packx.txt
I've had the same issue on windows, I couldn't even rename the directory that is causing the issue.
I found out that adb was still running and ended the process and update/install worked fine without workarounds.
The below command helped me to extract the SDK
sdkmanager "platform-tools" "platforms;android-28" --sdk_root=C:\AndroidSDK_RootLocation
It may not be the answer to your question but now, i can't exactly remeber the version, you can't update SDK tools directly or using Eclipse, sdk Manager, sdk.bat or android.bat, only way is to update them using Android Studio. It's Google's new policy, i read it somewhere, if i find the link i will share it
My solution was as following:
Delete the Android SDK Tools via Android Studio (although it might complain it failed).
Close Android Studio
Manually delete tools folder from C:\Users\<MyUsername>\AppData\Local\Android\sdk folder
Start Android Studio and then do the install of the Android SDK Tools via Android Studio.
Android Studio (v2.2 Preview 3) suddenly failed to update the tools. It keeps giving the error pasted below:
To install:
- LLDB 2.2 (lldb;2.2)
Preparing "Install LLDB 2.2".
Failed to read or create install properties file.
Failed packages:
- LLDB 2.2 (lldb;2.2)
I gave the folder full permissions. Ran android studio on administrator mode. End-tasked adb from task manager. Disabled antivirus. Deleted the folder and then ran the update again. But nothing works.
I also tried to create a new sdk location on my drive. But then that failed to, it gave the same error as above. -> Failed to read or create install properties file.
Any ideas?
I also encountered the same error when trying to update build tools after upgrading Android Studio. Unfortunately, in my case, removing .AndroidStudio2.x folder and re-opened studio with no config imported didn't work.
But then inspired by this answer, I go to Android Studio folder, then to bin folder, right-clicked on studio64.exe, choose Run as administrator. Then when I tried to update the build tools, it worked.
I'll just leave it here as an alternative way in case someone encountered the same problem.
For some reasons, this happens when you import the settings when upgrading Android Studio.
The fix is to delete the .AndroidStudio2.1 or .AndroidStudio2.2 folder in your profile directory. Open android studio and don't import any config.
This will however will ask to download the supporting libraries again.
In Windows 10, I pinned the application to my taskbar, and right-clicked on the icon and chose the option to run as administrator. Then I went through the steps to download my SDKs. Everything worked as it should.
Using Windows7: I unzipped the SDK under C:\Program Files\... but eventually discovered that security permissions in the "Program Files" area prevented sdkmanager.bat from creating folders and files.
It looks like you can give sdkmanager.bat permissions, but there are many complications, especially in cmd.
So I moved the SDK to C:\Users\[admin_name]\.android (or any folder) where it's easy for the sdkmanger to create folders and files and it finally worked !!
Hope this helps someone. Thank-you to all those who have helped me.
When using the sdkmanager command in Linux, you have to run it as root:
sudo sdkmanager --install emulator
On Linux, It's a permission issue. You can resolve the problem quickly by launching Android Studio as root :
gksudo <path_to_file_studio.sh>
If you want to fix this problem on long term and in more secure and better way you should find the right files / folder to alter and change their permissions. I didn't point it for now.
This solution was tested on Debian, but I guess it works on Unbuntu, Mint ...etc.
You cannot edit local.properties it is a generated file, right click your project and select 'Open Module Settings' under SDK Location put your location for your SDK.
paste in /Users/gururaj/Library/Android/sdk
Clean and rebuild your project
Update
Try to delete your local.properties file and create a new one, but do not check it into version control.
Right click top level of project and Create new file 'local.properties' then add: sdk.dir=/Users/gururaj/Library/Android/sdk
Clean and build
It worked for me to uninstall everything, delete the directories created in Program Files and Program Files (x86) and reinstall in another directory.