Linux Grant Android Studio (AVD) permissions /dev/kvm (Permissions Denied) - android

I'm confused with how to give permissions to Android Studio to install Virtual Devices through AVD manager.
I tired to add permissions to the folder and relogged-in without success. I'm also confused with commands regarding group and username; am I suppose to substitute username with name of user.
Currently if I do theses commands I get
ls -al /dev/kvm
crw-rw---- 1 root root 10, 232 May 7 20:23 /dev/kvm
grep kvm /etc/group
I get nothing printed
So, I know there is no group. I don't want to give privilages to root just the user name for example "blade".
I also checked with the device supports KVM
egrep -c '(vmx|svm)' /proc/cpuinfo
8
kvm-ok
8
Thanks!

First, you'll need to install the qemu-kvm package. For Debian/Ubuntu:
sudo apt install qemu-kvm
Next, add your user to the kvm group:
sudo adduser <username_here> kvm
Finally, log out and log back in or reboot your computer for the changes to take effect.
See complete tutorial at https://www.linuxslaves.com/2018/10/fix-android-studio-devkvm-device-permission-denied-ubuntu.html

Update VT from Bios Setting
Power on the system and press[delete] key to enter BIOS [EZ Mode]
Press [F7] key to enter BIOS [Advance Mode] as below picture:
(If press [delete] key to enter [Advanced Mode] directly and then no need to press [F7] key any more)
Select [Advanced] page and click [CPU Configuration] item
Select [Intel(VMX) Virtualization Technology] item and set to [Enabled]
Press [F10] key and click [OK] ,the system will auto reboot

Related

"ADB Root access is disabled" Even with root access enabled

I'm trying to patch Tingle on my Xiaomi Redmi 4A running on LineageOS 17.1 via ADB for enabling system spoofing signature for microG. But I'm getting this error :ADB Root access is disabled by system setting - enable in Settings -> System -> Developer options everytime I type adb root in cmd (running as admin). My device is rooted with Magisk 20.4 and the 'Super Access' option is enabled as "Apps and ADB". I've also enabled "Android debugging" option under the 'Settings -> System -> Developer options'.
But I'm unable to find any option called 'ADB Root access' or 'Root Access' under 'Settings -> System -> Developer options'. I've also tried abdb Insecure by Chainfire.
But with no luck, the problem still persist. I just want to get root access in my adb interface to be able to use Tingle.
Note : I'm on Android 10. My SELinux status is enforcing (not permissive) and my ROM isn't stock nor official.
Thanks in advance! Any kind of help would be highly appreciated. <3
As #biAji pointed out, the 'Rooted debugging' option is not shown if ro.debuggable is set to 0 in the system props. The ADB as root option will be visible in developer options if you add the line ro.debuggable=1 anywhere in the /system/build.prop file.
If you cannot edit the file as root but su is working in the adb shell or any terminal app then SmartPack Kernel Manager might be able to help. Install the app and go to the Build prop Editor section from the menu. If you can find a key-value pair ro.debuggable then edit its value to 1. If it doesn't exist then create a new prop with that name as key and the value as 1.
Now reboot the device and check if an ADB as Root option appears in developer options. If it does, the build.prop file was successfully edited and now you can uninstall SmartPack.
After check the source code, this settings item will be available if the device is debuggable
#Override
public boolean isAvailable() {
return Build.IS_DEBUGGABLE;
}
And it's depend on the system props ro.debuggable which is set to 0 in my case.
I think I need a debuggable-boot image to patch the device.

kvm permission denied on Android Studio emulator

When I try to run an AVD, I get this erros:
/dev/kvm device permission denied
Yeah, I know, I don't have the permission to access /dev/kvm, I know that I can "solve" it by changing the /dev/kvm permission to my user, and set my user to kvm group, it is working but when I restart my user session, the /dev/kvm permission return to root user and root group, and I need to set the permission to my group again and again...
How to set this permission and prevent that when I reboot my computer my permission are not changed anymore?
SO: Ubuntu 18.04.01
This command should help you:
sudo setfacl -m u:$USER:rwx /dev/kvm
Using it you will grant to current user rwx permissions to /dev/kvm. Or just replace $USER to any user you need.
As mentioned in setfacl manpages "This utility sets Access Control Lists (ACLs) of files and directories." It's a little bit different from chmod and chown. Using it you can grant required permissions to specific user. It's a bit more powerful tool and much more fine-grained. If you want to dive deeper, read about Access Control Lists. For example, in ubuntu docs: https://help.ubuntu.com/community/FilePermissionsACLs
Had same problem, it worked when you restart the program.
sudo chmod 777 -R /dev/kvm
Permissions for kernel virtual machine can be updated with the command sudo chmod 777 -R /dev/kvm in ubuntu system.
Update system BIOS Setting Assus
Power on the system and press[delete] key to enter BIOS [EZ Mode]
Press [F7] key to enter BIOS [Advance Mode] as below picture:
(If press [delete] key to enter [Advanced Mode] directly and then no need to press [F7] key any more)
Select [Advanced] page and click [CPU Configuration] item
Select [Intel(VMX) Virtualization Technology] item and set to [Enabled]
Press [F10] key and click [OK] ,the system will auto reboot
The right permissions are:
sudo chmod 666 /dev/kvm

How do I enable kvm virtualization using command line in Android Studio

I am a newbee to Android Mobile Development.
I have installed Android Studio on my Linux Machine and tried running the Hello World App but the emulator(android virtual device) doesn't run. I added kvm virtualisation but can't see the emulator tab. Therefore, I tried using command line but am not able to go through it. I saw many forums but there was no clear direction.
It will be great if you could provide a clear direction.
Thanks!
Install the KVM
sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
You may ignore the Postfix Configuration prompt by selecting "No Configuration".
Add your local user account to the group kvm and libvirtd.
sudo adduser your_user_name kvm
sudo adduser your_user_name libvirtd
In Ubuntu 16.10, the group has been renamed to libvirt instead of libvirtd.
After the installation, you need to relogin so that your user account becomes an effective member of kvm and libvirtd user groups. The members of this group can run virtual machines.
Verify installation in Terminal:
sudo virsh -c qemu:///system list
If you see: Id Name State list.
Add the emulator command line options.
In Android Studio, go to Run > Edit Configurations.
To set as global default for all projects, select "Android Application" under "Defaults".
Go to the emulator tab, check "Additional command line options" and add:
-qemu -m 2047 -enable-kvm
You can check all prerequisite and installation step on below link also:
https://github.com/uw-it-aca/spacescout-android/wiki/1.-Setting-Up-Android-Studio-on-Ubuntu#install-intels-kvm-for-better-avd-performance

How do you connect a OnePlus Two Device to Ubuntu through MTP?

When I connect it to my ubuntu 14.04, I am only able to see the USB drivers for installing ADB.
There are a few solutions available for OnePlus One (See here) but I was not able to find one for OnePlus two.
After much tinkering, I found the solution -
You need the latest mtp drivers for OP2 -
$ sudo apt-get install libmtp-dev mtpfs
Now edit the following file -
$ sudo gedit /lib/udev/rules.d/69-libmtp.rules
adding this line
ATTR{idVendor}=="2a70", ATTR{idProduct}=="f003", SYMLINK+="libmtp-%k", MODE="660", GROUP="audio", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1", TAG+="uaccess"
(The vendor id and product id can be got by using the "sudo mtp-detect" command)
now restart the service
sudo service udev restart
Your OP2 should be able to transfer files to your ubuntu PC now!
P.S - You will need to change the {idProduct} to whatever is specified by mtp-detect if you are not on the stock ROM/Kernel!
OnePlus X connected to Ubuntu 15.04 via USB
Alex Joseph's answer above worked for me BUT I had to also install mtp-tools in order to have the mtp-detect command (otherwise I only got "command not found").
$ sudo apt-get install mtp-tools
After that I could see my OnePlus X, verify the vendor id and product id, and follow the rest of the steps. My Ubuntu system now sees both internal storage and SD card.
I made the following changes and One Plus two starts showing up in my adb devices list:
Go to your home directory and using any editor open the adb_usb.ini file. it is present under .android folder I used vim editor:
vim .android/adb_usb.ini
Add 0x2A70 text without any trailing spacees to the file as below:
**
# ANDROID 3RD PARTY USB VENDOR ID LIST -- DO NOT EDIT.
# USE 'android update adb' TO GENERATE.
# 1 USB VENDOR ID PER LINE.
0x2A70
**
Stop and start the server:
adb kill-server
adb start-server
Now check, device should show up:
adb devices
After install android adb, I can open OnePlus 3 folder on Ubuntu 16.04
sudo apt-get update
sudo apt-get install adb
I would suggest just enable developers tool in your settings,
I did the same thing. now I can transfer files easily.
If you can not find developer tools option in settings, just go to about phone and tap on build number 7 to 8 times continuously.
that's it your done.
Install Android Debug Bridge and Media Transfer Protocol (MTP) library tools by.
sudo apt-get install adb install mtp-tools
Connect your OnePlus device, you should see a new volume with drivers. Run adb script from there:
$ cd /media/$USER/20160907_1106261
$ bash adb_config_Linux_OSX.sh
android home is exist!
0x2a70
VID 0x2a70 is already configured..
adb should be OK!
Install android-file-transfer package:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0BB4A1B2FA1A38EB
sudo add-apt-repository "deb http://ppa.launchpad.net/samoilov-lex/aftl-stable/ubuntu artful main"
sudo apt install android-file-transfer
Check your device connectivity by running mtp-detect.
Run android-file-transfer.
See also: Device is already used by another process.
Troubleshooting
error returned by libusb_claim_interface() = -6LIBMTP PANIC: Unable to initialize device
Activate Developer Settings by tapping 7 times Build number in About phone.
Enable File transfer in USB configuration found in Developer options.
See: How can I access media on my OnePlus 5 with a Ubuntu OS?

Android adb show "Allow USB debugging?" window

I am using Mobogenie software to backup data on my smartphone. When I do it, program invokes "Allow USB debugging?" window on my device, obviously via ADB. The question is - how? In the screenshot below (it is in Russian language)
button which is in red ellipse says: "Show this popup window again" and when I press it, my device shows "Allow USB debugging?" window. But i couldn't find any useful information about how to do the same thing - with ADB (which command should I use) or any other way. Maybe sombody got an idea? Or is there any way to kind of trace commands or find out how this progrom does it?
ADB Secure device authorizations are stored in a whitelist located here: /data/misc/adb/adb_keys
There's no way to remove RSA keys from the whitelist without having root access.
Having said that... If you do not "Allow USB Debugging" when that window pops up (by pressing cancel) or if you do not check the box that says "Always allow from this computer", then the RSA key is not stored in the whitelist. By running adb kill-server and then adb start-server, it forces a new check of the connected computer's RSA key.
My guess is that the button that is circled is there basically just kills and restarts the ADB server to have the popup come back, in case the user did not "Always allow" or if they Cancelled the request.
EDIT: I see that Mobogenie also includes a "one click root" feature... As sketchy as that sounds, if your device is rooted, then Mobogenie could be deleting your computer's stored key from your whitelist. As for this theory, there are multiple methods - one being simply doing a pure delete:
adb start-server
adb shell
cd /data/misc/adb
rm abd_keys
exit
adb kill-server
adb start-server
I also got the same issue in my lenovo mobile. Initially I thought the issue is with my mobile.
But actually the issue is the adb don't have enough permission to read the rsa key to communicate with the device. When we run adb server it'll create a folder named .android(Linux - /home/--username--/.android, Windows - C:/Users/--username--/.android) in the home directory of the current user which contains the adb rsa key files used to communicate between the devices.
When I check the folder is assigned with root permission(I am using Ubuntu 16.04 and I don't know how its assigned). So when I try to run adb start-server it is trying to create .android folder. But the current folder with root access is not allowing this to create the adb keys. That's why its failed.
So I deleted the folder using below command. Use the particular method to delete the folder based on your operating system. Below I mentioned for linux.
sudo rm -rf .android
Then restarted the adb server using below command.
adb start-server
Now It created the .android folder with the current user permission. Once done this I got the Allow USB debugging dialog.
Hope it help someone.

Categories

Resources