Android device emulator fails due to bad permissions Linux - android

I am trying to install flutter without android-studio, currently the flutter doctor gives all ticks except for android studio and connected devices as per this guide. I created an emulator through avdmanager, and if I run it with flutter emulators --launch pixel it gets stuck on the loading screen and then becomes unresponsive. To get some more information I can run it with ${ANDROID_HOME}/emulator/emulator -avd pixel, this does the same thing but returns the following debug information:
emulator: WARNING: IniFile.cpp:235: Failed to open .ini file /home/cameron/.android/avd/pixel.avd/hardware-qemu.ini for writing.
qemu-system-x86_64: -drive if=none,index=1,id=cache,if=none,file=/home/cameron/.android/avd/pixel.avd/cache.img.qcow2,overlap-check=none,cache=unsafe,l2-cache-size=1048576: Could not open '/home/cameron/.android/avd/pixel.avd/cache.img.qcow2': Permission denied
Killed
Now since it seems to be a permissions issue, I can run the same command with sudo and it is able to start up the emulator but when I use the virtual power button to start the phone os it crashes with:
host doesn't support requested feature: CPUID.80000001H:ECX.abm [bit 5]
host doesn't support requested feature: CPUID.80000001H:ECX.abm [bit 5]
E0619 23:22:33.309764951 29720 socket_utils_common_posix.cc:201] check for SO_REUSEPORT: {"created":"#1592572953.309674506","description":"SO_REUSEPORT unavailable on compiling system","file":"/mnt/tmpfs/src/android/emu-master-dev/external/grpc/src/core/lib/iomgr/socket_utils_common_posix.cc","file_line":169}
emulator: ERROR: AdbHostServer.cpp:102: Unable to connect to adb daemon on port: 5037
Your emulator is out of date, please update by launching Android Studio:
- Start Android Studio
- Select menu "Tools > Android > SDK Manager"
- Click "SDK Tools" tab
- Check "Android Emulator" checkbox
- Click "OK"
[29707:29707:0619/232311.505803:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
I've tried to common response I found on the internet which is to use adduser on kvm but this didn't change anything. Some windows users have suggested marking certain files as writable but since I don't know which I'm very apprehensive. PS I'm on Ubuntu 18.04. Any help would be very appreciated!

Try
flutter clean
and then restart your flutter

Related

Error when running the emulator on Flutter in Android Studio

When running the emulator on Flutter in Android Studio adb.exe exists in AppData\Local\Android\Sdk\platform-tools, but I get an error saying "Unable to locate adb."
Also, pressing the "Open Android Emulator: ~" button causes the following error:
Error Opening Emulator
emulator: ERROR: Running multiple emulators with the same AVD is an experimental feature. Please use -read-only flag to enable this feature. .
What should I do?enter image description here
That alert comes up very often but the emulator starts up nevertheless. If the emulator doesn't start, click the down button(next to the play button for your emulator in the AVD manager) and select stop/disable to stop the process and try again.
I ran into this while running Cygwin on Windows with a repo I'd cloned using the Cygwin git. It looks as if Flutter launches things differently from regular Android Studio.
I was able to solve this with:
cd \users\(me)\AppData\Local\Android\Sdk\platform-tools
chmod -R u+x *
(That's the Cygwin /usr/bin/chmod on my path.) After that, adb started in a Flutter project.

Error Starting Android Emulators on Ubuntu 18

I'm attempting to start an Android emulator on Jenkins CI, but the startup never completes. On CI the command is running in a Docker image based on ubuntu:18.04. I'm using the following command to start the emulator:
/opt/android-sdk-linux/emulator/emulator -no-audio -no-window -delay-adb \
#Pixel_C_API_25 &
Then I wait for the emulator to complete with:
adb wait-for-device
On my developer machine (macOS 10.14.6), the emulator finishes starting and adb wait-for-device returns, but on CI the emulator never finishes launching. The relevant portions of the log output are here:
Starting emulator
Waiting for emulator
* daemon not running; starting now at tcp:5037
statvfs('/home/ec2-user/.android/avd/Pixel_C_API_25.avd/snapshots/default_boot/ram.img') failed: No such file or directory
### WARNING: could not find /usr/share/zoneinfo/ directory. unable to determine host timezone
emulator: WARNING: encryption is off
Your emulator is out of date, please update by launching Android Studio:
- Start Android Studio
- Select menu "Tools > Android > SDK Manager"
- Click "SDK Tools" tab
- Check "Android Emulator" checkbox
- Click "OK"
* daemon started successfully
### WARNING: could not find /usr/share/zoneinfo/ directory. unable to determine host timezone
Sending interrupt signal to process
Terminated
script returned exit code 143
I think the "emulator is out of date" warning is a red herring, as it doesn't cause problems for me locally. I think the more likely problem is:
statvfs('/home/ec2-user/.android/avd/Pixel_C_API_25.avd/snapshots/default_boot/ram.img') failed: No such file or directory
But I haven't been able to find info on what would cause this problem or fix it. Locally the ram.img file is present.
I've tried with AVDs based on the following system images. Previously there seemed to be an error with x86 not being supported on the x86-related images, but I'm no longer getting that error. Instead, all of them give the above ram.img error:
system-images;android-25;google_apis;arm64-v8a
system-images;android-25;google_apis;armeabi-v7a
system-images;android-28;google_apis;x86_64
system-images;android-28;google_apis;x86
system-images;android-28;default;x86_64
In each case I create the AVD with commands analogous to the following:
sdkmanager --install "system-images;android-25;google_apis;armeabi-v7a"
avdmanager create avd --force --name Pixel_C_API_25 --abi google_apis/armeabi-v7a --package "system-images;android-25;google_apis;armeabi-v7a" --device "pixel_c"
Has anyone successfully gotten an Android emulator to start on Ubuntu 18, and if so, which system image did you use?

Android emulator not working(black screen and offline) for open source project

I followed instructions here to build an open source android project(aosp-2.3.x).
After I finish building the project with:
. build/envsetup.sh
lunch aosp_arm-eng
make -j16
emulator
I can see a black screen emulator and two warning messages:
Could not automatically detect an ADB binary.
Some emulator functionality will not work until a custom path to ADB
is added in the extended settings page.
Running an x86 based Android Virtual Device (AVD) is 10x faster.
We strongly recommend creating a new AVD.
and in my terminal it shows:
emulator: WARNING: system partition size adjusted to match image file (2050 MB > 200 MB)
emulator: WARNING: encryption is off
when I run adb devices, it shows:
List of devices attached
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
emulator-5554 offline
The emulator works in Anroid Studio, but not from the terminal when I tried to build the open source android project, is there any suggestions on how to fix this issue?
I got the same problem like this, try to uninstall android phone driver (check on remove driver and restart pc) then go on search "universal adb driver", download and setup it, it works for me, hope for you too!
PS C:\Users\Nguyen\AppData\Local\Android\sdk\platform-tools> adb devices
List of devices attached
xxxxxxxxxxxxxxxxxx device

adb socket not working and daemon

I am getting this type of error
error: could not install smartsocket listener: cannot bind to
127.0.0.1:5037: Only one usage of each socket address (protocol/network address/port) is normally permitted. (10048) 1:34:26
PM could not read ok from ADB Server 1:34:26 PM * failed to start
daemon * 1:34:26 PM error: cannot connect to daemon 1:34:26 PM
'C:\Users\MITESH
SUTHAR\AppData\Local\Android\Sdk\platform-tools\adb.exe,start-server'
failed -- run manually if necessary 1:38:14 PM Unable to obtain result
of 'adb version'
my genymotion device is running but it shows me that no device
I came across the same error. I provided the below command and the issue got solved.
COMMAND :- taskkill /f /im adb.exe
Close Eclipse or Android Studio if either is running (Optional).
Open Command Prompt.
Go to the Android SDK platform-tools directory.
Type adb kill-server.
Type adb start-server.
If no error message is thrown while starting ADB server, then adb is started successfully.
OR
Go to Task Manager, open the Processes tab, and end the adb.exe process.
Then restart Android Studio.
This may work if there is any problem with adb.
In my case, none of the above solution worked. I solved it strangely maybe it can be a bug.
Do not run Genymotion emulator before Android Studio. Firstly, I opened android studio then I clicked run project and select deployment target windows appeared. Then I run genymotion emulator and now the emulator is shown in the select deployment target windows in Android Studio. Then deployed to the emulator without errors. Done!
As another way, you can try to set Genymotion sdk to the same as Android studio sdk. To do this, first find your sdk location. You can find it by right clicking the Android Studio project -> Open Module Settings-> Select SDK location -> under Android SDK location, it is shown. Then open Genymotion -> Settings -> ADB tab -> Click Use custom Android SDK tools radio button -> navigate to SDK folder used by Android studio -> Restart Genymotion virtual device
If none of the above worked for you, just make sure that you have closed Genymotion emulator as it caused this issue with me.
Easiest Way! I just ran into this issue trying to connect a React-Native App to an Android Studio emulator. If you read the error message it tells you that "Only one usage of each socket address (protocol/network address/port) is normally permitted." So you can assume that something other than React-Native is also attempting to connect to the emulator.
Terminate The Connections:
Leave the emulator running.
Close out of and uninstall any Android Studio/Eclipse Apps you have on the emulator. This terminates apps trying to connect.
Close Eclipse or Android Studio if either are running. Android Studio doesn't have to be open in order for the emulator to work (This is important). This terminates software trying to connect.
After doing so I went back into my React-Native App and connected to Expo no problem.
All you have to do is terminate all connections. However you so choose.
I came across the same error, it worked simply after restarting the AS on windows, of course, it asked for SDK update.
Android Studio 4.1.3 with API 30 installation has this error
01-04-2021
09:56 'C:\Users\ranja\Android\Sdk\platform-tools\adb.exe start-server' failed -- run manually if necessary
Tried C:\Users\ranja>adb start-server
daemon not running; starting now at tcp:5037
**could not read ok from ADB Server
failed to start daemon
error: cannot connect to daemon**
Note: I have added 'C:\Users\ranja\Android\Sdk\platform-tools' in %PATH% environment variable on Windows 10
i've encountered same error in my ionic 2. i just uninstall and reinstall ionic. and it works fine again..
npm uninstall -g ionic
npm install -g ionic

Error: Could not access the Package Manager. Is the system running? - At Android Studio

I installed android studio and tried to run easy projects.
But I caught strange error message:
Waiting for device.
/usr/local/idea/android-studio/sdk/tools/emulator -avd Nexus-4-18-xhdpi -netspeed full -netdelay none
emulator: emulator window was out of view and was recentered
Device connected: emulator-5554
Device is online: emulator-5554
Target device: Nexus-4-18-xhdpi [emulator-5554]
Uploading file
local path: /home/nazar/Documents/coursera-android/Examples/HelloAndroid/out/production/HelloAndroid/HelloAndroid.apk
remote path: /data/local/tmp/course.examples.HelloWorld.HelloWorld
Installing course.examples.HelloWorld.HelloWorld
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/course.examples.HelloWorld.HelloWorld"
Error: Could not access the Package Manager. Is the system running?
I couldn't figure out why this happen?
I installed sdk version and configured emulator. Any suggestions?
Here is emulator confiuration:
Update:
I tried to install Genymotion device and use few virtual devices, but caught:
Waiting for device.
Target device: genymotion-nexus_4___4_4_2___api_19___768x1280-192.168.56.101:5555
Uploading file
local path: /home/nazar/Documents/coursera-android/Examples/HelloAndroid/out/production/HelloAndroid/HelloAndroid.apk
remote path: /data/local/tmp/course.examples.HelloWorld.HelloWorld
Installing course.examples.HelloWorld.HelloWorld
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/course.examples.HelloWorld.HelloWorld"
WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix.
Error: Could not access the Package Manager. Is the system running?
How to solve this error?
First make sure you are running Android Studio version above 0.3.2 because there was some issue reported regarding the same in AS 0.3.2 . If it is not you can update it from Help >Check for update.
If you are already running AS above 0.3.2 :
Seems like issue is with your emulator not with Android Studio. It may happen that you are trying to install application before even the emulator started properly.
Wait till the home screen appears in the emulator before trying to install any application.
Also try to install any apk in Emulator from command line
Steps to install
Go to $Android_SDK_DIR\platform-tools, right click there keeping
shift key pressed and Chose "Open Command Window here".
Run command adb devices to make sure yout emulator is running
properly. It will show all your running emulators.
Now if emulators are showing properly, type the command adb install
YOUR_FULL_APK_PATH , YOUR_FULL_APK_PATH is of any .apk file path in
your system.
Please update if this works fine.
The most common cause of this error is simple: You have to manually unlock your Android Virtual Device by swiping the “lock” icon on the screen. Security measures prevent the emulator from letting you connect the debugger before doing this.
The problem is resolved:
In Android Studio
Start run/debug
if you see the message
Do not closed the AVD, just click on run/debug again, the Application will be running when you unlock the application.
The same problem but different solution, I modified my Virtual Device, I changed Memory option and Internal Storage, and it works fine.
RAM:512 , VM HEap: 192, Internal Storage=200, SD Card Size: 200 for Device Nexus 4 android 4.2.2.
In my case this error was caused by SELinux. I got to set SELinux to permissive.
adb shell su 0 setenforce 0
I had this issue, but I found that simply killing the emulator and restarting it worked. There seems to be some sort of race condition where the emulator has not initialized before Android Studio tries to launch the apk and so you get the package error.
I had this too, and using this config worked for me :
Device: Nexus One
Target: Android 4.2.2 -api level 17
CPU/ABI: ARM (armeabi-v7a)
Keyboard: Hardware keyboard present
Memory Options:
RAM: 512
VM Heap: 192
Iternal Storage: 200
SD Card:
Size:200
This Is Worked for me
1)Close Solution.
2)Close Emulator.
3)Run Emulator and Wait till it launch completely and shows Home Screen.
4)After that only Open Solution And Clean,Rebuild and Try to deploy Application.
The same happened to me right now. I don't know if there is another but for me the following worked:
Opened AVD (Android Virtual Device) Manager
Started virtual device
Hit the Run button again (that one at status bar)
Explanation: The problem happened because of timeout. Once device had started, the Android Studio could comunicate with him. (v 0.5.3)
Remove this emulator (in the AVD)
Install this emulator (in the AVD) :)

Categories

Resources