How can I test an application for performance in Android? What is the support provided in Android and how do I use it?
If you want to profile your application to find performance bottlenecks you can use the traceview tool. This gives you a graphical view of performance traces of your application.
To create a trace add the following to your code where you want to start tracing:
Debug.startMethodTracing("myapp");
and then put the following when you want to stop tracing:
Debug.stopMethodTracing();
This will create a trace file call myapp.trace in the root directory of the SD Card. As it is written to the SD Card:
If you're using the emulator you'll need to add an SD card to your AVD.
You'll need to give you app permission to write the SD card by adding the following to your Manifest:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Once the file has been created you'll need to copy it to your PC. You can do this using the adb command:
adb pull /sdcard/myapp.trace c:/my/dir/myapp.trace
Finally, start traceview giving it the full path to the trace file:
traceview c:/my/dir/myapp.trace
I did have some problems with traceview failing with OutOfMemory exceptions. I fixed this on Windows by changing the last line of traceview.bat from:
call java -Djava.ext.dirs=%javaextdirs% -Dcom.android.traceview.toolsdir= -jar %jarpath% %*
to:
call java -Xmx1g -Djava.ext.dirs=%javaextdirs% -Dcom.android.traceview.toolsdir= -jar %jarpath% %*
Adding the -Xmx1g option allows traceview to use more memory.
Also, theoretically, DDMS can get memory allocations for your program and then you can analyze the dump using profilers.
DDMS Reference.
The reason why I have theoretically in italics is that I myself have not tried doing anything such, yet.
I think traceView contains too much information, you can easily get lost.
My solution is just log the system time at three place in the code.
Before and after and center at the potiential slow code.
like binary search, next time, narrow it down step by step, then finally find the culprit code.
Another way to test is Using TruClient on Load Runner
Steps to be followed for Mobile Web are:
New VuGen Script
Mobile Protocol
Select TruClient Mobile Web
Click Create
Now you can generate scripts
Click Develop Script button
PoP up window appears to select the device
Select Actions and you can record the scripts
Steps to be followed for Native Mobile are:
New VuGen Script
Mobile Protocol
Select TruClient Native Mobile
Click Create
Now you can generate scripts
click develop script
TruClient window that plugged with Firefox appears
Click General Settings
Configure the SERVER URL PORT
If u don't know the server url port means install OS MONITOR application on your device. here you can find the ip address
Enter User Name and Password
Click done
you can record the scripts and perform your testing....
you can use load runner.,
use this link to find more about it.,
http://www.perftesting.co.uk/recording-and-performance-testing-android-applications-with-hp-loadrunner-vugen/2011/11/14/
Steps to be followed are:
Create New VuGen Script
Select Mobile Application-HTTP/HTML
Recording Options--> Select Record Emulator
Give the path to Record Emulator as D:\android\AVD Manager.exe
In the command line
-avd AVD_NAME -netspeed full -netdelay none
where AVD_Name is the name of your Device
select the working directory
click finish
Now you can perform your test.,
Related
I am building an Ionic 4 App + PouchDB, I have built the app by executing the command ionic cordova run android and for a few days, it works well. Recently though, the app just won't open anymore and I have no idea how to check what went wrong.
Prior to this, whenever something went wrong in the app, I am able to check it using the chrome://inspect. However, with the app not being able to open at all, it's impossible to check the cause of the problem since I am also unable to check using chrome://inspect.
When I tried to run it using ionic cordova run android -l, I get the same result, which is the app loads and closes a few moments later, and I'm still unable to get into chrome://inspect.
I had a hunch that it has something to do with PouchDB. The app starts to behave this way when the storage is almost reaching 200mb. Upon reading the PouchDB FAQ, it's stated;
In PhoneGap/Cordova, you can have unlimited data on both iOS and Android by using the SQLite Plugin.
But I am already using the SQLite Plugin for PouchDB, I have used cordova-sqlite adapter for my PouchDB too.
Below is an example of line in my code:
this._userdb = new PouchDB('user.db', { adapter: 'cordova-sqlite'});
With the app being unable to open, I'm out of ideas on how to retrieve the data stored inside PouchDB since I can't even get into the chrome://inspect at all (I can't see any console.log() for the stored data).
I feel like clearing the app data would allow the app to be opened as how it used to be but I really need to do a backup of the data stored inside PouchDB but I really have no idea how other than getting the console.log() of the data.
Is there any other way I can access the data stored inside the PouchDB to do the backup?
After many failed attempts to figure out how to retrieve the data stored inside PouchDB , I found one solution which is to pull the APK and extract the backup file.
By referring to this article, open CMD and shell into your device by;
adb shell
Provided that you know the app's package name, proceed to pull the APK by running;
adb backup -noapk com.app.your.package.name
**Note: Some devices like Samsung Galaxy stock Android 11 requires password to 'Backup my data'
Once pulled, you will find a backup.ab file and you need to extract this file. At this step, as a Windows user, I was unable to use the openssl method. I get an error using Python too.
But I found a solution that worked well for a Windows user. According to that solution;
Download Android Backup Processor
Go into the directory android-backup-tookit\android-backup-processor\executable (this directory should have a abp.jar file
Copy your backup.ab into this directory.
Open CMD, and run;
java -jar abp.jar unpack backup.ab test.tar
If the device was required password during the backup process, you will be asked to enter password. Enter the same password you provided during backup. Be sure to read the README for further details.
Once done, you will find test.tar file in the same directory. To view the file, simply extract it. The databases created inside the app should be in \test\apps\com.yourappname\f. The sqlite databases files can be viewed using DB Browser for SQLite.
When I click on Ui automator viewer after connecting my mobile device--> Device screenshot throws error
Error :
Error obtaining UI hierarchy Reason : Error while creating temporary file to save snapshot : null
Please let me know how to fix this issue?. Thanks
Download an old version of platform tools from Google
copy adb.exe and replace with current one in your SDK tools.
Source: https://softwaretestingboard.com/q2a/1654/appium-automator-viewer-could-android-emulators-screenshot#ixzz5qS8ez6GY
As I believe this app is not allow you to take screen shot from your device and from uiautomator as well.
As I am also getting same error but when I used to get the screenshot of other app it works fine but in the case of my app its not allowed to take screen shot using uiautomator.
So better way for now to get allow it by developer in test version of app so it works to get the element of app screens.
Take the screenshot and dump manually and open from "uiautomator". It will work. Use below commands to create and pull the dump from device:
-> adb shell uiautomator dump
-> adb pull /sdcard/window_dump.xml
Go to Ui automator, then select open file, select screenshot and corresponding dump xml file. Now we can see all the elements in UiAutomator tool.
Note: If you are using Mac-OS file should be window_dump.uix
There are two solutions :
1. Disconnect your device and reconnect. It should work.
OR
2. Kill all instances of adb.exe from task manager And restart UIAutomator. It should work.
I am taking those viewer using command prompt:
adb shell uiauomator dump
adb pull /sdcard/windows_dump.xml
reading those id manually
I am working on a custom android device using the i.MX53 board from NXP (formerly Freescale). I have the OS source code, various intermediate files, and the final resulting files once produced by another developer (who customized the OS, but has since left our company). I now need to modify the contents of the system partition on these devices. I have attempted to build and load a new system.img file using make_ext4fs.exe and the directory which contains the original collection of files the prior developer must have used. I believe I have created a nearly identical system image, as the one previously used. They are both ext4, 200MB.
There is a utility for this board (called MfgTool) which copies and mounts images automatically for you at the click of a button. That MfgTool successfully writes my image to the device. When I try to boot, however, it fails and just loops with the custom boot image being displayed. If I swap out the new system image and restore the prior one in this process, everything works again. So it has to simply be a matter of getting this system image built correctly.
What might be the cause? What difference in the images might cause this? Is it possible there is a signature needed, or some other kind of protection which I'm failing to account for?
Replace one of the system image service executable with a shell that dump kmsg and logcat to a file (in data partition or external storage for example) and then call the original executable. Then, boot to your previous system and collect those logs.
It turned out that my primary problem was that I need to set the mount point for the image to "system" NOT "/system" when it was created via make_ext4fs despite all documentation out there to the contrary! I figured this out by carefully reading the ASOP source: ...build\tools\releasetools\img_from_target_files.
Of note, after this hurdle, I ran it another problem where the device was acting funky. That turned out to be the result of not having any symbolic links in the image. It seems like at the least you normally have symbolic links directing your "bash" commands to the toolbox binary in system/bin. I don't know how you normally get those, but creating those links and then bundling them into the image fixed that. I suggest checking the bin directory for symbolic links if you manually create a system image like this.
I want to send email from terminal android application. Is there any command for this or any email functions?
I, too, want to be able to send emails from terminal/shell scripts in Android. It took me over a week to figure out how to do it. Obstacles included:
Android's default command line toolbox doesn't offer this functionality
The busybox (v1.22.1 bionic) on my android device (MotoG with CyanogenMod 11) seems to have been compiled without the sendmail applet (!?)
Judging from the fact that I was not able to find an answer to your question anywhere, it seems that not many people seem to care about this functionality
I finally did find a simple solution: curl. It is dead-simple to get it working, but only if you have root access to your device. Here's how to set it up:
A. On your computer (desktop or laptop):
Download the curl package for android available here: http://curl.haxx.se/download.html (scroll down until you find the version for android)
Extract the package's contents using your preferred application
B. Use USB cable to plug your android device into your computer
C. Copy the curl binary from your computer (/data/local/bin/curl in the extracted package) to somewhere in your android device's PATH (I copied it into the /system/xbin directory) and make sure that the file is executable
D. Disconnect device from your computer and happy emailing!
Now you can use curl at the command line (or in your shell scripts) to send emails. Usage example is here: Using curl to send email. You can even send text messages! (see here: http://osxdaily.com/2014/03/12/send-sms-text-message-from-command-line/)
How to view the output of log functions like GST_CAT_INFO, GST_DEBUG etc in Android environment? Can I view them in logcat?
The log is written to stderr. You can redirect it to a file (2>debug.log) and download it to your computer. There you can just read it using 'less' or 'more'. Alternatively disable the ansi colors (GST_DEBUG_NO_COLOR=1) and use gst-debug-viewer to interactively browse it.
There is a method to redirect stdio to the log so it is visible in logcat:
Redirect stdout to logcat in Android NDK
I have used this several times. I also remount /system read-write on android and edit "/system/build.prop" to add the setting so it survives a reboot. On development platforms, you can even use "vi" within adb shell to edit the file.