Android Emulator sdcard push error: Read-only file system - android-emulator

I am developing under Android 1.6 (Android SDK 2.1).
I create a avd by using avd manager in Eclipse.
When I launch this avd, I found that the /sdcard directory's permisson is "d---------".
So I can't push file to the sdcard.
Does anyone know how to solve this problem?

I found this works
$./adb shell
$su
mount -o rw,remount rootfs /
chmod 777 /mnt/sdcard
exit
Source: http://www.coderanch.com/t/611842/Android/Mobile/Android-emulator-sdcard-writable

Once you started the Emulator from one shell, login to another shell & type
adb shell
You should see # prompt displayed, this is your device(emulator) shell. Now , type following command at adb shell.
mount -o remount rw /sdcard
This will now remount /sdcard with rw(read-write) permission & now you can push your files into /sdcard by using following command from your host shell.
`adb push filename.mp3 /sdcard,`
where filename.mp3 could be any file that you want to push into Android Emulator.
Hope this helps :)

Ensure two things in the AVD manager utility for the emulator:
SD Card size is mentioned e.g. 512.
From the Hardware tag, press New and select "SD Card Support" from the drop down menu.
Now, start the emulator. SD Card shall now support writing as well.

Android studio version 0.8.9 and above has a bug creating AVDs.
See Issue 78434.
Workaround
go to your ADV folder in .android folder and find your AVD config.ini
open it with a text editor that can handle unix newlines. (Notepad will run the lines together since they don't have CR-LFs.)
change hw.sdCard=no to hw.sdCard=yes
this should work for everyone in new builds

Maybe it sounds stupid but it worked for me when I had the same problem: delete the created avd and create one again through AVD Manager with a sd card of, for example, 512MB.
Check that both have the correct permissions and if not, try to change them with chmod.
And if everything still fails, repeat the process but creating both avd and sd card manually via terminal:
android create avd -n my_avd -t 7
mksdcard -l e 512M mysdcard.img
emulator -avd my_avd -sdcard mysdcard.img
Hope that helps!

I think the problem here is that you forgot to set SD card size
Follow these steps to make it work:
step1: close running emulator
step2: open Android Virtual Device Manager(eclipse menu bar)
step3: choose your emulator -> Edit -> then set SD card size
This works well in my emulator!

Make sure that you had given a value which is greater than zero for SD Card size in the Create AVD Window for that particular emulator.

mount -o remount, rw /sdcard
this is the correct way to remount your sdcard using your emulator.

I tried #user2002993 great help but it one place it need to be a little edit so I edited and here what worked for me on Android Studio, emulator android 5.
Go to your adb folder right click on blank area and select "open command window here" or if you installed adb by adb-installer open cmd and type these commands:
adb devices
It should show your emulator number and detail. Then followed command here:
adb shell
Now it should show you prompt #
su
mount -o rw,remount rootfs
chmod 777 /mnt/sdcard
exit
exit
Yeah double exit needed, now your prompt of adb shell is gone. Put a file in to your adb folder and give this command and see if it got fixed.
adb push "your file name like : 1.jpg" /sdcard/
or
adb push "your file name like : 1.jpg" /storage/sdcard/
Now in cmd it shoudl show you transfer time instead of creepy read-only thing 😊

I increased the virtual memory of sdcard up to 512 MB for the emulator and that was enough

I guess, you didn't insert memory size at the time of creating avd. you can do that by editing the avd.

make sure that you have the correct permissions.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Windows uses backward slashes, linux uses forward slashes.

sometimes this can cause of a very simple reason,
go to your list in eclipse and check whether you have set SDCard size

I had this problem on Android L developer preview, and, at least for this version, I solved it by creating an sdcard with a size that had square 2 size (e.g 128M, 256M etc)

In adb version 1.0.32 and Eclipse Luna (v 4.4.1).
I found a directory in the avd /mnt/media_rw/sdcard that you can write to using the adb command.
adb push {source} /mnt/media_rw/sdcard
There appears to be rw access to this directory.
Hope this helps :-)

Alternate way:
Dismount the drive (from settings/storage) and re-mount the sdcard
also fixes the problem. (verify by moving a file from internal storage to sdcard)
In any case, this simple method saved my butt this time :)

Give any size to Sdcard in Emulator
unchecked the read only option from c:\user...android\avd -> properties
push a file through file explorer
restart the Emulator
It will definitely works

With me in the end helped
In the emulator to run applications manager
and setting permissions for storage.

Try this in a Terminal Emulator as root:
restorecon -v -R /data/media

Related

Flutter error Unable to start the daemon process

My flutter project is run smoothly in my old laptop. But when I use my new laptop, my flutter project can't run in debug mode.
This error
FAILURE: Build failed with an exception.
* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/5.6.2/userguide/gradle_daemon.html
Process command line: C:\Program Files (x86)\Java\jre1.8.0_221\bin\java.exe -Xmx1536M -Dfile.encoding=windows-1252 -Duser.country=US -Duser.language=en -Duser.variant -cp C:\Users\ajoris\.gradle\wrapper\dists\gradle-5.6.2-all\9st6wgf78h16so49nn74lgtbb\gradle-5.6.2\lib\gradle-launcher-5.6.2.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 5.6.2
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 1572864KB object heap
Picked up JAVA_TOOL_OPTIONS: -Djava.vendor="Sun Microsystems Inc."
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Is there something missing in the settings on my new laptop? I tried to clean project, upgrade flutter but always fail. Sorry for new
What actually worked for me is, In windows 10 just turn off your mobile hotspot and run the app again. I think it's a glitch/bug in windows 10.
The solution to this problem is deactivating windows hotspot before running build or app compilation.
Don't delete anything or file, just build the app with mobile hotspot turned off.'
its a windows 10 bug that start without any reason. i refreshed my windows and this started
Flutter or Android Applications
The general steps I would use are:
run flutter doctor in terminal
if you are using an emulator make sure it has enough space (often it needs a restart to clear junk files created upon consecutive deploys)
if the gradle files have been modified it is recommended to open them with Android Studio (Android folder of the application). If anything is missing the IDE will prompt you to install the missing dependencies.
Hope it helps
I tried all the above methods but sadly none of them worked. What eventually worked for me was too simple.
first try all the suggested solutions here and if it doesn't work
try to disable mobile firewall, actually I discovered that it's a windows 10 bug because disabling mobile hotspot just until you build or compile your project then you can reenable it without any problem .
Step 1: Open the Registry Editor on your Windows 10 computer. To do this, just press the Windows + R keys on your keyboard. In the Run dialog box, type “Regedit” and hit enter. This will open the Registry Editor window.
Step 2: In the Registry Editor, navigate to the following location:
HKEY_LOCAL_MACHINE SOFTWARE Policies Microsoft WindowsNetwork Connections
Step 3: In the Network Connections key, on the right-side pane, right-click anywhere in the empty area and select New > DWORD (32-bit) Value.
Step 4: Name the newly created registry “NC_ShowSharedAccessUI” and keep its value as “0” to disable the Mobile Hotspot feature on your laptop.
Step 5: To enable the feature, just change the value of the NC_ShowSharedAccessUI registry from 0 to 1 and the feature will be enabled again.
When the functionality has been disabled, the feature will still appear in the Network & Internet settings but it cannot be enabled or configured. To use the feature, the registry needs to be edited again and enable the functionality.
It looks like a memory problem.
In your project folder, Go to android/gradle.properties.
Change the line
From:
org.gradle.jvmargs=-Xmx1536M
To:
org.gradle.jvmargs=-Xmx1024M
Save the gradle.properties file and try to run debugging again.
That Worked for me :)
Usually it Is bcoz of the .gradle file in C:drive.
1.Locate to the .gradle folder (usually in C:\users\your_username)
2.Delete the .gradle folder once located.
2.Locate to your flutter project folder
2.Locate to android
3.Run gradlew clean
4.Run gradlew build
5.now run your app...It worked for me
I tried all the above methods but sadly none of them worked. What eventually worked for me was simple.
There has been a lot of problem with emulator configuration and sometimes it crashes for a lot of reasons. For the above problem what I recommend is, delete the current emulator but remember the settings like API version and all and make a new emulator.
This worked for me fine!
I'll post what solved for me.
flutter clean
flutter run
Close Android studio
Delete your ".gradle" folder
Open android studio as administrator and allow project to build.
For my case i had --no-sound-null-safety in the Dart: Flutter Additional Args ( go to vscode settings under extensions dart ). I deleted it, deleted the web folder in the project ( i was working on the app only ) then reloaded vscode. the error was gone afterwards
go to C:\Program Files\nodejs
Open npm, npm.cmd, npx, npx.cmd
then change the prefix -g to prefix --location=global
still if this did not work,
go to android studio click on build, then click clear project.
I also faced this issue and this step resolved problem. Still if this did not work out let me know.
Non of the solution in here worked for me. running my vscode or android studio as an administrator solved the problem.
Go to file/setting/build,execution,deployment/gradle, and there where Gradle user home: pass static address.
For example, my address is C:/Users/Admin/.gradle.
After applying if runs OK.
There is a simple solution.
Uninstall the app from your device .
Then restart the PC .
First of all Uninstall the application from emulator.
then wipe all data from the emulator.
Sometimes turning off mobile hotspot will do the work.
After turning off if not work then restart the pc or a laptop. Don't turn on mobile hotspot and run flutter run.

Capture screenshot in GenyMotion

I am using Genymotion for running android application.
Could any one tell me how to capture screen shot in Genymotion ?
If you are using Android Studio or Eclipse, you can just click the button "Screen Capture" in the Android DDMS:
You can use adb to get the screenshot from command line:
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png
This article has the details:
http://blog.shvetsov.com/2013/02/grab-android-screenshot-to-computer-via.html
To make my life easier, I made an alias in .bash_profile:
alias screenshot="adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > ~/Downloads/android_screenshot.png"
Now I can type screenshot in Terminal and get a screenshot of currently running emulator in my Downloads directory.
Disclaimer : I'm part of the same company as the Genymotion team.
This feature is included in the product. It is one of the paid feature of the screencast widget. Look at the pricing page here.
Two ways to access it:
pay for the pro or indie licence
use the trial version, it offers you the indie features. Be careful, there is only one trial day left :-/
Once your VM is started, open the screencast widget
Then take a picture with the dedicated button
UPDATE: You have bellow another ways to take a screenshot using Android Device Monitor or the command line
Use this commands:
Windows:
C:\"Program Files"\Genymobile\Genymotion\tools\adb shell screencap -p "/mnt/sdcard/output.png" && C:\"Program Files"\Genymobile\Genymotion\tools\adb pull "/mnt/sdcard/output.png" "C:\output.png" && C:\"Program Files"\Genymobile\Genymotion\tools\adb shell rm "/mnt/sdcard/output.png"
Note: Make sure you have permission to write to C:\output.png; otherwise, change it to whatever path you like.
OS X:
/Applications/Genymotion.app/Contents/MacOS/tools/adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > ~/Desktop/Android_Screenshot_$(date +%Y-%m-%d-%H-%M-%S).png
Select genymotion simulator
Hit shortcut key describe below
Windows : Ctrl+Shift+S
Mac : Cmd+Shift+S
You can find your screenshots at desktop
I think you can also take videos for free. Genymotion uses VirtualBox to do almost all the heavy lifting, so you should open VirtualBox and look at what you can do in it.
You will find options in Virtualbox to capture video!
adb shell screencap -p /sdcard/screen.png
If your Mac is slow and you hate running Eclipse and the emulator together here is a quicker way.
Export your apk.
Start Genymotion.
Drag the apk to the emulator, in order to install it.
Go to 'android-sdk-macosx>tools>ddms'.
Run that file.
A new instance of ddms will be started. Unlike Eclipse, it doesn't slow down your system.
Use the 'Menu>Device>Screenshot' option to take screenshot.
This is a good option for those using slow computers.
If you are using Eclipse, then follow the steps for any type of emulator:
1. Select DDMS
2. In Devices window of DDMS select Genymotion device
3. Click on Camera icon then save it to specific location.
For Linux and Windows (I used gitbash on windows)
adb shell screencap -p | sed 's/\r$//' > screen.png
For Mac
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png
#Reck says there's a bug in the Genymotion implementation so we can't take screenshots on 2.3.7. This means that Android Studio / DDMS can't get the proper pixels. adb shell screencap says there's no screencap command.
Assuming you have access to the code you can simply call this method:
public static void screenshot(View view) {
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
view.draw(new Canvas(bitmap));
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
try {
File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
storageDir.mkdirs();
File file = File.createTempFile(timeStamp, ".png", storageDir);
bitmap.compress(Bitmap.CompressFormat.PNG, 0, new FileOutputStream(file));
Log.i("SCREENSHOT", "adb pull " + file);
} catch (IOException e) {
Log.e("SCREENSHOT", "Cannot save screenshot of " + view, e);
}
}
In Activity:
screenshot(getWindow().getDecorView());
In Fragment:
screenshot(getActivity().getWindow().getDecorView());
The only limitation I know is that it won't include the status bar.
if you use Mac, sometimes CMD + Shift + 4 (screenshot of a selected portion in OSX ) and then selecting the simulator region is enough :)
Take a screenshot
On many Android devices, you can capture a screenshot with a key-combination: Simultaneously press-and-hold Power and Volume-down. You can also capture a screenshot with Android Studio as follows:
Run your app on a connected device or emulator. If using a connected device, be sure you have enabled USB debugging.
In Android Studio, select View > Tool Windows > Logcat to open Logcat.
Select the device and a process from the drop-down at the top of the window.
Click Screen Capture on the left side of the window.
The screenshot appears in a Screenshot Editor window
It Works for even Genymotion Emulator
Check here for further information

Mac Terminal - How to start Android Virtual Device Manager on CLI?

I am currently developing a mobile web application and I don't have a test device yet so I'm using the android-emulator to check the site. On my mac, I have installed the stand-alone Android SDK. Every time I want to use the AVD Manager, I have to execute the following on my terminal:
monitor
This command (being executed on the installed android sdk path) will open the Android Device Monitor and from here, I go to its menu bar and select Window Virtual Device Manager just to open the AVD Manager. So, is there a shortcut for that? I mean, i want to directly open the AVD manager via cli.
I was able to open it from terminal with:
android avd
You may need to navigate to your SDK tools/ first. Here is reference I used:
AVD Manager
Go to tools directory inside your android sdk like:
cd ~/Android/Sdk/tools
and enter run your avd as
./emulator -avd <your-avd>
You can find your avd name by running:
./emulator -list-avds
You can start emulator use terminal shell
emulator -avd <avd_name> [<options>]
options can be special -http-proxy, -dns-server setting. Get more options here
And to list all avd you can use:
emulator -list-avds
result like following:
4.7_WXGA_API_23
Nexus_5X_Edited_API_23
Example when I start Nexus_5X_Edited_API_23 emulator in OS X 10.11 with proxy setting
~/Library/Android/sdk/tools/emulator -netdelay none -netspeed full -avd Nexus_5X_Edited_API_23 -http-proxy http://username:password#local_server:8080
this is just a small addon to previous solutions presented. What is probably handy to do is to just jam this as a alias into your bash_profile like so:
Open your bash_profile:
nano ~/.bash_profile
Add this:
alias avd='cd /path-to-sdk/tools; ./android avd'
Source it again:
source ~/.bash_profile
In the CLI type:
avd
Now you can open up the AVD by just using avd in the command line. The only thing i haven't figured out how to make it stay alive after closing the terminal. Maybe somebody has tips on that.
Use the Android SDK Tools:
avdmanager
Or you can also start it by using the command below but it's deprecated though on newer version. Before executing it, make sure to export your Android SDK's tools directory in your ~/.bash_profile (i.e. export PATH="/Users/user/Software/android-sdk-macosx/tools:$PATH")
android avd
Old answer:
In order to open the avd manager on terminal, execute the following:
/usr/bin/java -Xmx256M -XstartOnFirstThread \
-Dcom.android.sdkmanager.toolsdir=/path/of/android-sdk-macosx/tools \
-classpath /path/of/android-sdk-macosx/tools/lib/sdkmanager.jar:/path/of/android-sdk-macosx/tools/lib/swtmenubar.jar:/path/of/android-sdk-macosx/tools/lib/x86_64/swt.jar \
com.android.sdkmanager.Main avd
emulator -avd <nameOfYourAvdEmulator>
Find the names of your emulators using avdmanager list avd:
avdmanager list avd
Name: Nexus_5X_API_23_Android_6.0
Device: Nexus 5X (Google)
Path: /Users/edward3/.android/avd/Nexus_5X_API_23_Android_6.0.avd
Target: Google APIs (Google Inc.)
Based on: Android 6.0 (Marshmallow) Tag/ABI: google_apis/x86
Skin: nexus_5x
Sdcard: 512M
Add to your ~/.profile if missing:
# Add to your ~/.profile PATH to easily run emulator and avdmanager commands
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
# Create alias to run your favorite Android emulator
alias avd-run='emulator -avd Nexus_5X_API_23_Android_6.0 &'
Open a new terminal or use source ~/.profile to reload changes made to your ~/.profile
Start your favorite emulator using the alias you created:
avd-run

Android Emulator can't start, 'cause of wrong folder

I'm just starting to use Eclipse and ADT and I have some issues, the Android Emulator don't start :
[2011-07-10 15:32:25 - Android_FirstApp] ------------------------------
[2011-07-10 15:32:25 - Android_FirstApp] Android Launch!
[2011-07-10 15:32:25 - Android_FirstApp] adb is running normally.
[2011-07-10 15:32:25 - Android_FirstApp] Performing samr1.Android_FirstApp.Android_FirstAppActivity activity launch
[2011-07-10 15:32:25 - Android_FirstApp] Automatic Target Mode: launching new emulator with compatible AVD 'Android2.1'
[2011-07-10 15:32:25 - Android_FirstApp] Launching a new emulator with Virtual Device 'Android2.1'
[2011-07-10 15:32:26 - Emulator] PANIC: Could not open: C:\Users\Sam\.android/avd/Android2.1.ini
The path isn't correct, though the path in Android2.1.ini is correct. The User folder is located in an another disk.
How can I modify the start path of Android Emulator ? I can't find where.
Thanks
EDIT :
I found that graphical AVD Manager creates AVD directory inside C:\Users\.android\ on Windows 7 :
Default location of AVD files
But using Command Line doesn't work.
So i moved my AVD files in C:\Users\Sam\ and now it works.
This is a bug in the ADT Plugin. For a workaround until it is fixed use a NTFS symbolic link.
I have a C: drive for windows 7 and a D: drive for all my work and data. After installing windows 7 I relocate all my special folders from C:\Users\John Doe to D:\John Doe. The ADT Plugin is trying to load the emulator from C: when it and the configure files are on D: (PANIC: Could not open etc.). NTFS can get the ADT Plugin to read from D: using a NTFS symbolic link. Open a command prompt in C:\Users\John Doe (obviously use your user name), use the mklink command.
mklink /J "C:\Users\John Doe\.android" "D:\John Doe\.android"
Now when the ADT plugin is trying to reference .android on C:, NTFS sends the request to D: and the emulator starts correctly.
Create a environment variable called: ANDROID_SDK_HOME and set it to C:\Users\Administrator
Open Eclipse > Window > Preferences and click in Run/Debug and String Substitution
Add a new variable called: user.home and set it to C:\Users\Administrator
Create an AVD and run it.
It should work now.
The configuration files for your emulator might have been saved by AndroidSDK and AVD Manager some where else in your hard drive.
Do the following:
First search for the .android folder on you harddisk.
After you find that, move the .android folder to your user root directory - which may be "C:\Users\hallo\" in your case.
These type of project creation errors(with cause and solution) is described here.
The configuration files for your emulator might have been saved by AndroidSDK and AVD Manager some where else in your hard drive.
Do the following:
First search for the .android folder on you harddisk.
After you find that, move the .android folder to your user root directory - which may be "C:\Users\something\" in your case.
Other Method
Check the location of old folder you can open eclipse Navigate to Windows--> Preferences-->Android-->Expand it and Select Build
Find the Value of Default Debug keystore and you will know your .android folder location.
Then mklink /J "old folder location" "C:\Users\Something\"
if anyone is interested on the same problem in Linux (Ubuntu 11.10) the solution is NOT run Android SDK Manager as root. Aparently, SDK expects to be runned by a regular user, and it tries to work with the main user folder, that's why the error. This is what I suspect.
This worked for me by running eclipse as root ( in Ubuntu ), my be run as administrator will work

Android emulator reports unknown virtual device

i am having the same problem described in the following post "Android emulator reports unknown virtual device" Why does the Android emulator report "unknown virtual device", when the device is in my user directory? and have followed all of the instructions in an attempt to resolve but still i cannot run my AVD.
I only have one drive on my Windows 7 machine (C:) and the AVD is being created in the correct location -> C:\Users\MyUser\.android
Ive also tried to setup an environment variable "ANDROID_SDK_HOME"
The actual error is:
emulator: ERROR: unknown virtual device name: 'my_AVD'
emulator: could not find virtual device named 'my_AVD'
Can someone please help me?
For another reason i had to re-format my pc. After a quick rebuild its working fine now. I think the problem happened because in the previous installation of windows, i was playing around with HDD's. Somehow this had caused problems..
Solution: you should have a copy od .android in C:\<your user name>\.
Please try the below steps to solve the above issue -
in task manager kill adb in process
in android sdk folder .. /tools/ run adb kill-server in command line
Check the avd folder name in " ../.adroid/avd/" - say it is "avd1"
run command "emulator -avd avd1 " under android folder "../tool/" in command line
it will start the avd1 device
Now start the eclipse and run your project with setting the "manula" option in configuration.
It will ask for choosing the avd between "avd1" and the existing list of avd's in eclipse if any. You choose "avd1" as it is already running.