I am testing a HarmonyOS application and want to add an image to the emulator's gallery.
In Android Studio, we can send any file into the android emulator via drag-n-drop action,
but drag-n-drop isn't working here.
What is the alternative for this in HarmonyOS?
Welcome to the community!
You can transfer files in HarmonyOS Simulators from your computer via the following command, images will appear in Gallery once pushed -
Steps:
Make sure the device (Simulator / Phone) is running.
Run DevEcoStudio -> Open Terminal.
Make sure the Device is connected to DevEcoStudio.
Make sure you have HMOS_Home set in environment variables in your computer.
Run hdc file send command with arguments. The terminal will show messages with success or failure after execution.
hdc file send [LOCAL file path of computer] [REMOTE location in device]
Example -
Currently, drag-and-drop is not supported. You can run the following HDC command to transfer files:
hdc file send D:/a.jpg /sdcard
Related
We have an android app which is composed of two different apps.
Launcher activity is present in 1 project which has a package name
in.foo.android.main.MainActivity
while app package which is shown in uiautomator view is something like
com.abc.android.debug
in desired capabilites I am setting following :
capabilities.setCapability(MobileCapabilityType.APP_PACKAGE ,"com.abc.android.debug");
capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY,"in.foo.android.main.MainActivity");
So getting below error
com.abc.android.debug/in.foo.android.main.MainActivity is not a launchable activity
Here appium is adding package name by default before the main activity.
can someone provide some help here.
First
Go to CMD as admin type adb devices
Make sure that your device already opened the apps that you want
go to cmd and type adb shell dumpsys window | find "mCurrentFocus"
this the exp
Thats command will showing the current activity
Second
Install the APK Info from playstore (idk if you try on the appstore)
https://play.google.com/store/apps/details?id=com.wt.apkinfo&hl=in&gl=US
Open the APK Info
Search your apps s name and click it
You will see this screen
appdetail
Scroll down and check the activities
activities
You will see all of the activity on the apps
existingactivity
i try to open the camera with th opencv library using android studio but it is not opened and the message appeared was " it seems that your device does not support camera( or it is locked) application will be closed" on the emulator screen
this is my logcat
09-09 19:39:17.436 11223-11223/? E/libprocessgroup: failed to make and chown /acct/uid_10058: Read-only file system
Unfortunately, if you are using emulator, it will not allow writing a file to its file system, unless you use API ver 21 or below. (That's what I tried once and it works probably.)
AVD does support camera, try edit AVD -> Advanced parameters.
I have an android project that demonstrates how to write android test cases which can be executed on an emulator or a device. As a result of those test cases, data is populated in the device and the resultant SQLite *.db file can be downloaded from Android Studio's DDMS screen.
NOTE: I have already tried as a root user in adb shell. Problem I am facing in accessing *.db file is consistent from adb and DDMS in emulator with API 26.
Code is accessible here.
I have created 2 emulators (API 23 and API 26) in AVD Manager.
AVD Manager
When I run the androidTest on both the emulators, all the test cases pass successfully.
Using Android Studio's DDMS ...
On the emulator with API 23, I am able to view the SQLite *.db file under /data/data/<package-name>/databases/weather.db and download it to my desktop and view it through http://inloop.github.io/sqlite-viewer/
DDMS
ADB Shell
On the emulator with API 26, the /data folder is empty?? I do not see the same hierarchy for accessing the SQLite *.db file as on device with API 23.
The android app and androidTest both run successfully on emulator with API 26 which means data is saved somewhere in android emulator but what is the new location?
DDMS
ADB Shell
Is it new behavior after API 25/26 and do I need special permissions to access data in DDMS or adb shell?
If this is new behavior then where is the SQLite *.db file located after API 25/26?
I have googled about it on stack overflow and android documentation but didn't find anything concrete, let me know if I have missed anything.
Make sure:
1) You are running adb as root user.
2) Your emulator should have root access.
Link: How to get root access on Android emulator?
#jrg I have been testing to see how to write to the SD CARD and how to find the path to the INTERNAL location of a sqlite db and how to view it with Api 26 or greater. I am not sure this will help and I am curious about rooting an Emulator once rooted can you remove the rooting by deleting the device from the AVD manager
here is some code that might help
String state = Environment.getExternalStorageState();
if (state.equals(Environment.MEDIA_MOUNTED) && (!state.equals(Environment.MEDIA_MOUNTED_READ_ONLY))) {
File removable = ContextCompat.getExternalFilesDirs(this, null)[1];
THE_PATH = String.valueOf(removable) + "/Documents/";
//System.out.println("ALL TRUE ==> " + THE_PATH);
} else {// if (state.equals(Environment.MEDIA_MOUNTED_READ_ONLY)) {
THE_PATH = "";
//System.out.println("ALL FALSE ==> "+ THE_PATH);
}
When I eject the SD CARD on the emulator and a real device I use this code to create the path
Context context = this;
String removable = getFilesDir().getAbsolutePath();
THE_PATH = String.valueOf(removable)+"/";
System.out.println("INTERNAL PATH ======> "+THE_PATH);
File file = new File(context.getFilesDir(), "NAME_OF_FILE");
String PA = String.valueOf(file);
System.out.println("Where AM I ======> "+PA);
I do not think Android permits you to navigate to the internal storage without a File Manager application on your device. Have you considered installing a File Manager app on the emulator. Down side to this is I think your need AS 2.4 beta to be permitted to do this
Ok, I have searched and searched without any success for someone with a similar question. I am developing an Android app using Android Studio and have started creating my SQLite database. In order to test my creation and upgrade functions I would like to extract my SQLite database and view it's contents.
Instructions online are fairly clear, open up Android Device Monitor, select the device, go to file explorer, and then browse a few levels deep in the data folder to find your .db file. Here is where the trouble starts. I am unable to expand the root level data folder at all. I have found numerous other questions regarding people having the same problem but they are all due to people trying to do it on un-rooted physical devices. I am simply trying to do it on an emulated device. I am certain it is a permissions problem but I'm not sure how to fix it.
Things I've tried:
Verified that my app is listed as a process on the device selected in the device monitor.
Restarted the AVD, Android Studio, and then my entire machine.
Uninstalled my app and reinstalled.
TLDR; can't access data folder in DDMS for emulated device in order to extract SQLite database file.
Same question to me.
When I want to access /data directory via Android Device Monitor, some error have occurred :
08-21 07:32:36.837: W/ls(3101): type=1400 audit(0.0:50): avc: denied { getattr } for path="/default.prop" dev="rootfs" ino=2941 scontext=u:r:shell:s0 tcontext=u:object_r:rootfs:s0 tclass=file permissive=0
08-21 07:32:37.418: W/PlatformStatsUtil(2507): Could not retrieve Usage & Diagnostics setting. Giving up.
This information tells us we don't have permission to access the directory.
Here are what I have done and works for me.
My OS is Window10
Start your ADV & Open Android Device Monitor
cd to /the/path/to/Android/sdk/platform-tools
Open your cmd or openshell here (shift + right click you will see the option)
execute following commands
.
./adb.exe shell
su
chmod -R 777 /data/data/your/package
Now, enjoy your coding.
Run your app in an emulator with API 23 (or lower).
check detailed information in link below,
Android Device Monitor "data" folder is empty
I'm trying to parse an XML file thru a DOM parser. However, I am having difficulty in getting my Main Activity to actually read the file. I've read that I should place the file in Assets and then called with getAssets(). I used something like this:
InputStream is = this.getAssets().open("myXML.xml");
This just results in an error: Unexpected error while launching logcat. Try reselecting the device.] device not found.
I've also tried new File("myXML.xml") using variations on the absolute path. Nothing seems to work. I'm getting a little frustrated. Does anyone have any suggestions?
sounds to me, as if your IDE has no connection to the Emulator or device on which you are trying to test your app.
LogCat is a logging output stream that can be used by any app to print out informations /logs. And LogCat needs to be connected (via ADB) to your device.
If you don't have a real phone connected you can use an emulator:
/path/to/your/androidSDK/tools/android
this SDK manager helps you to create a new AVD (Android Virtual Device). Klick Tools>
Manage ACDs> New...
If you have a real phone or tablet connected to your computer, try restarting ADB
(should be possible from within your IDE) or use the command line.
change to the directory where the Android SDK is installed (in windows something like):
c:\Program Files\Android\android-sdk-windows\platform-tools\
on linux it could be:
/opt/android-sdk-linux/platform-tools/
then type (win and linux)
adb kill-server
adb start-server