Android Studio AVD Manager Creating AVDs in root directory - android

I am using Android Studio with Ubuntu and it won't create AVDs. Nothing gets created in my ~/.android/avd directory. Instead things are getting created in my /root directory. Which I guess I wouldn't care about, except of course it can't run the emulator for these AVDs if the AVDs are in my root folder. I think it's because for the Android SDK manager to be accessed in Linux, Android Studio has to be run with sudo...but then it puts the AVDs in root instead of home...
I have a few pics outlining this problem very clearly, but stackoverflow won't let me even link to them without 10 rep, what a nuisance of a restriction.
EDIT: Here is the error I get in my terminal when I try to execute the android bash script located in /opt/android-studio/sdk/tools/. It's the same error whether or not Android Studio is open or not.
ss108 tools$ bash android
java.lang.NullPointerException
at java.io.File.<init>(File.java:277)
at com.android.sdklib.internal.avd.AvdManager.parseAvdInfo(AvdManager.java:1516)
at com.android.sdklib.internal.avd.AvdManager.buildAvdList(AvdManager.java:1492)
at com.android.sdklib.internal.avd.AvdManager.<init>(AvdManager.java:346)
at com.android.sdklib.internal.avd.AvdManager.getInstance(AvdManager.java:369)
at com.android.sdklib.internal.repository.updater.UpdaterData.initSdk(UpdaterData.java:252)
at com.android.sdklib.internal.repository.updater.UpdaterData.<init>(UpdaterData.java:120)
at com.android.sdkuilib.internal.repository.SwtUpdaterData.<init>(SwtUpdaterData.java:61)
at com.android.sdkuilib.internal.repository.ui.SdkUpdaterWindowImpl2.<init>(SdkUpdaterWindowImpl2.java:104)
at com.android.sdkuilib.repository.SdkUpdaterWindow.<init>(SdkUpdaterWindow.java:88)
at com.android.sdkmanager.Main.showSdkManagerWindow(Main.java:407)
at com.android.sdkmanager.Main.doAction(Main.java:390)
at com.android.sdkmanager.Main.run(Main.java:150)
at com.android.sdkmanager.Main.main(Main.java:116)

The AVDs are created under /root because you are starting Android Studio with sudo. You need to configure the permissions so that this isn't required. The simplest solution that I have found is to install Android Studio and the Android SDK as my regular user. I install these into $HOME/bin so that I don't have to bother with permission issues at all. When everything is installed, my regular user account has execute permission for all the files I need.
Alternatively, you can use chmod (either manually or with find) to set the permissions on Android Studio and Android SDK files.

Related

No uiautomatorviewer in android sdk

I am using ubuntu 19.04. I want to automate some actions of an android app, I download the android studio, edit PATH, run studio.sh file, it asks to download sdk, I go with 'standard' installation. It downloads and installs, evrything fine and I successfully run avd manager and virtual device, install the app and use it. No problem with appium as well. But here comes the problem, no matter which tutorial I follow, uiautomatorviewer is all over internet as the tool to find id of the elements on active screen. But, there is NO EXECUTABLE file of uiautomatorviewer in android-sdk/tools. I search in platform-tools/, it's not there and not in bin/ as well. So I recursively searched whole directory of android studio and android sdk but there is not executable name 'uiautomaor' or 'uiautomatorviewer'. There is a uiautomatorviewer.jar file but I am unable to run it with jave -jar command. I have searched through android studio docs for some recent update but an article update on 3 march 2020 mentions uiautomatorviewer. Please help!
I've spent over 4 days trying to find uiautomatorviewer in android sdk, have reinstalled and android sdk over 4 times, have trying downloading it from official site and extracting it, tried with snap, but just couldn't find a way around.
I managed to get UiAutomatorViewer by deleting android SDK, downloading Android Studio and installing SDK using Android Studio. It installed SDK manager and some packages among which was UiAutomator.

Android emulator on Ubuntu

I want to launch the React Native application on Android emulator using Ubuntu 16.04. Following the react native docs it should be dove by running
react-native run-android
OR
npm run android
Both these commands are not working without sudo for some reason, but that's not an issue. The issue is when I run them every time I get the same error:
Error running adb: No Android device found. Please connect a device
and follow the instructions here to enable USB debugging:
https://developer.android.com/studio/run/device.html#developer-device-options.
If you are using Genymotion go to Settings -> ADB, select "Use custom
Android SDK tools", and point it at your Android SDK directory.
I don't want to connect device via USB and I don't use Genymotion, I just want an emulator. I tried to run the project via Android Studio, but faced with another issue :
Error: please select Android SDK
I tried syncing the files, removing the project, restart the studio - nothing. (However I can see the Nexus 5X in the devices list and even start it)
Please someone help me, I've tried everything I could find - nothing helps
Both these commands are not working without sudo for some reason, but
that's not an issue.
Probably, this is the root cause.
Because, if you have ever installed your Android SDK / Tools using "sudo" or you installed it into the directories of root user, then those files may not be accessible or executable by a normal account. So, try below steps:
Delete the hidden dirs ~/.gradle ~/.idea ~/.m2 and ~/.android using command
sudo rm -rf ~/.gradle ~/.idea ~/.m2 ~/.android.
This step is to clear up your previously installed files with root previlige. If you don't have those folders, ignore this step.
Re-install your Android Studio into your normal user home directory, e.g. ~/android
Create your AVDs using the newly installed Android Studio.
Don't use any "sudo" for your newly configured environment. Because anything installed with root privilege will go to root directory, i.e. /, but not your normal user home dir, i.e. ~/. If you start your Android Studio with a normal user, usually, it will only be able to refer to your setups under ~/. This is probable the reason for not being able to find your "installed" Android SDK.

Android SDK component failed to install

while installing Android studio SDK in ubuntu 14.04, 64 bit using the wizard; I encountered this error
The following SDK components were not installed: sys-img-x86-addon-google_apis-google-21 and tools
It occurred during "Downloading Google APIs Intel x86 Atom System Image, API 21, revision3"
Can someone please help me where the possible error is.
This solution helped me on Ubuntu 20.04 when I already installed the AS, but couldnt install packages in AVD Manager when I wanted to create a virtual device for the emulator, getting a very similar error. Maybe this will help in your case:
Delete the .downloadIntermediates/ directory from your SDK location /.../Android/Sdk/ (usually the path starts in your home folder).
From what I understood, this folder contains logs for your downloads,
and if something goes wrong, this can stop AS from
resuming/downloading new things properly. Don't worry about deleting,
this folder will recreate itself automatically and it doesnt affect
the program
How to delete it via the console:
Open your terminal, go to your sdk folder, if it's a default location in home folder the command is as follows:
cd Android/Sdk
Then check if the folder ".downloadIntermediates/" exists. Run this command and look for it in the list:
ls -la
If it's there, then proceed with removing it:
rm -r .downloadIntermediates
Now you can run the "ls -la" again to see if it is removed successfully.
Launch Android Studio again. Now try installing all the packages you need, they should install with no errors. Hope this helps in your case! :) And in any case, if nothing else works, an uninstall and clean install can be a good idea.

Android SDK and AVDmanager giving errors

I have 64bit system and have downloaded SDK and the manager to learn Android development.
As you can see I am neewbie and I am having few hiccups.
I have downloaded and succesfully installed the plugin for Eclipse.
But when it comes to manager when I am downloading basic packages, I get the error in the screenshot.
I have made sure to fetch the url using http.
the error seems the installer is not able to access its own folder, which is quite surprising.
Are there any permission which I have to change?
I have also included a screenshot for the convenience:
Screen shot http://img842.imageshack.us/img842/1108/capturempk.png
Just two quick things to check:
Make sure you are not running this from within your "Program Files" folder. Run it in Documents or somewhere as Vista & Win7 try to protect any Program Files and folders.
Right click the application and look for the option to always run it as administrator. Even in Linux based operating systems you need to run this updater as administrator some times.
These are just two quick solutions, just in case.

Remove Phone application from Android emulator?

How do I (forcibly) remove the stock android Phone application from the emulator instance?
I would especially like answers from people who have actually successfully removed the Phone application.
Removing the Phone application probably also necessitates removing the Contacts application, as they are tightly integrated, that is fine.
Solution
After much research it seems the only solution is to rebuild the Android SDK from source, as Maciej Pigulski answered.
After fetching the android source, remove Phone and Contacts from the Android makefile build/target/product/core.mk. And build the SDK as usual, i.e.:
. build/envsetup.sh
lunch generic-eng
make sdk
And in out/host/linux-x86/sdk you will have a zip file containg a fresh new sdk ready for use in e.g. Eclipse.
I successfully remove Phone apps WITHOUT rebuilding the SDK (very long op...)
You can edit you system.img in your SDK (located for ex : ~/android-sdk-linux_x86/platforms/android-10/images/system.img) corresponding to the system part of your emulator ( Phone apos is located at /system/apps/Phone.apk)
I launched the emulator, connect with adb to the emulator shell. I removed the packaged /system/apps/Phone.pak after remounting the system partition with read/write option ( mount -o rw,remount /system /system )
I push into my emulator the mkfs.yaffs2 tools compiled for arm found here (http://code.google.com/p/android-group-korea/downloads/detail?name=mkfs.yaffs2.arm)
use this tools to recreate my system.img in my emulator shell:
mkfs.yaffs2 /system /sdcard/system.img
pull the /sdcard/system.img into my PC. Replace the system.img of the emulator (~/android-sdk-linux_x86/platforms/android-10/images/system.img) and restart the emulator.
The Phone app is Gone!
I have an idea how this could be done but this is not an easy way.
It requires source code of the Android OS you need an emulator for. Then in the make files you can disable including of the Phone application to the output image and build the OS with 'make sdk' task. This will produce an SDK (like ones available from the Google site) with the binaries that has Phone application excluded. Then when you will create an emulator with this SDK it wont have the Phone.apk.
Painful but if you really need it, give it a try.
If you have root acces you can remove the .apk file that provides this app. You would have to look around in the folders on the device where it is installed.
It may be necessary to re-compile the Android OS that is running on the emulator. During the compile the default apps are rolled up into the build so it would be a matter of getting the egg before the chicken... or killing the chicken before it lays the egg...

Categories

Resources