Android mismatch in Calculator package (emulator vs. real device) - android

I have a physical Pixel 2 XL device. The Calculator app on it is com.google.android.calculator. However, when I use a virtual Pixel 2 XL device (created via Andrdoid Studio's virtual device manager) the Calculator on it is com.android.calculator2.
Questions:
a/ What's the reason for this discrepancy?
b/ How can I create a virtual device with a Calculator app that is identical to the one on physical devices?
Virtual device:
$ adb shell getprop ro.build.version.release
8.1.0
$ adb shell getprop ro.build.version.sdk
27
$ adb shell getprop ro.product.model
Android SDK built for x86
$ adb shell pm list packages calc
package:com.android.calculator2
Physical device:
$ adb shell getprop ro.build.version.release
8.1.0
$ adb shell getprop ro.build.version.sdk
27
$ adb shell getprop ro.product.model
Pixel 2 XL
$ adb shell pm list packages calc
package:com.google.android.calculator

Related

Check if headless android emulator is running

I am running a headless emulator (Android api 25) on a Ubuntu linux 14 server and I see the below output for the command-
$./adb devices
List of devices attached
emulator-5556 device
However, If i try to run any other command I get error
$./adb shell dumpsys deviceidle get deep
Can't find service: deviceidle
$./adb shell 'pm list packages -f'
Error: Could not access the Package Manager. Is the system running?
How can i verify that my emulator is functional?
is adb devices -l not working? it should show you the status of the device as well
try adb push, for eg
adb push foo.txt /sdcard/foo.txt
or adb install for eg
adb -s emulator-5556 install apkname.apk
these commands will work with any running emulator/device
all these commands are available on the documentation

How to check Android OS version of bluestacks Emulator

I searched a lot for this in Google, but no hope, how to check the OS version of Bluestacks emulator in Windows? There is a video in YouTube for checking bluestack version, but not the Android version used in it.
I went to settings – > Advanced settings, but there was no tab corresponding to About tab which is found in an Android emulator like in the case of Genymotion emulator.
There is an easier way of getting to know the android version without having to install any application.
There are some scripts (php/js) that can detect your android version while visiting websites:
Try; http://demo.mobiledetect.net/ Or;
http://detectmobilebrowsers.com/
Install Terminal Emulator from Play Store, open the application and type:
getprop ro.build.version.release
you will get something like: 4.4.4 for KitKat.
or
getprop ro.build.version.sdk for getting the sdk version which will return 19
Open a browser in Bluestacks and go to http://demo.mobiledetect.net
I have tested this on multiple devices of which the Android version is known, and it is accurate.
Currently responds to Bluestacks as v4.4.2 (Kitkat)
Without any installation, you could use your adb commands.
For example, for your main emulator
adb -s emulator-5554 shell getprop ro.build.version.release
adb -s emulator-5554 shell getprop ro.build.version.sdk
For your multi emulators add up by 10,
adb -s emulator-5564 shell getprop ro.build.version.release
adb -s emulator-5564 shell getprop ro.build.version.sdk
adb -s emulator-5574 shell getprop ro.build.version.release
adb -s emulator-5574 shell getprop ro.build.version.sdk
//... so on
You could also do the shell commands by their local ip,
adb -s 127.0.0.1:5555 shell getprop ro.build.version.release
adb -s 127.0.0.1:5555 shell getprop ro.build.version.sdk
adb -s 127.0.0.1:5565 shell getprop ro.build.version.release
adb -s 127.0.0.1:5565 shell getprop ro.build.version.sdk
adb -s 127.0.0.1:5575 shell getprop ro.build.version.release
adb -s 127.0.0.1:5575 shell getprop ro.build.version.sdk
//... so on
just use Droid Info .. which gives you alot of Information quite easely.

adb and multiple device simultaneously

I am automating some test on android devices.
I am using Jenkins in order to run the tests (via jobs)
each job runs with a 95% success rate when only 1 device is connected to the machine
but when I plug 2 android devices or more, it seems adb has some trouble and I get a 5% success rate.
is it ok to run multiple instances of adb command?
here is the command I run for each job:
adb -s DEVICESERIAL shell am force-stop com.myapp.test
adb -s DEVICESERIAL shell am force-stop com.myapp
adb -s DEVICESERIAL uninstall com.myapp adb -s DEVICESERIAL uninstall com.myapp.test
adb -s DEVICESERIAL install -r com.myapp adb -s DEVICESERIAL install -r com.myapp.test
adb -s DEVICESERIAL shell am instrument -w TESTNAME/android.test.InstrumentationTestRunner
adb -s DEVICESERIAL logcat -d -v time
all command run with success but when the test starts and when I have multiple devices connected i get errors like for example:
- Unable to find instrumentation target package
- INSTRUMENTATION_STATUS_CODE: 0
- Failure [INSTALL_FAILED_INVALID_URI]
at first I thought the test apk was not installed correctly, but when trying manually after the failure, it worked fine (so the test file is installed)
again. Using 1 device only, everything is stable.
Is there something special to do in order to install and run the test on different devices simultaneously?
note that I have tried different usb ports, different cables etc...
thanks

Why is Jenkins Android Emulator Plugin recreating my Emulator Snapshots in every build?

I use Jenkins to build one of my projects. The Android Emulator Plugin automatically starts an emulator with the following configuration:
Configuration of the Emulator Plugin:
.
Every time the job is running I get the following output:
Erasing existing emulator data... $
/ci/home/tools/android-sdk//tools/emulator -no-boot-anim -ports
64470,64471 -prop persist.sys.language=de -prop persist.sys.country=DE
-avd hudson_de-DE_240_480x720_Google_Inc._Google_APIs_8 -no-snapshot-load -no-snapshot-save -wipe-data
.
.
shell input keyevent 4 [android] Giving the system some time to settle
before creating initial snapshot... $
.
.
localhost:64471 shell log -p v -t Jenkins "Creating snapshot..."
[android] Creating snapshot... $
Full log below.
It seems that the plugin is creating a new emulator every time and is not using snapshots.
This takes something between 2 and 4 minutes depending on the emulator configuration.
The plugin creates .avd and .ini files in the .android/avd directory inside the job folder. The avds are not deleted after the run process.
If I disable the use snapshots config the emulator needs less then a minute to start.
Is this an issue with the emulator plugin or are snapshots not possible because of my configuration?
I hope that using snapshots will speed up my building process a lot.
Full log:
$ /ci/home/tools/android-sdk//tools/android list target [android]
Using Android SDK: /ci/home/tools/android-sdk/ [android] Adding 200M
SD card to AVD 'hudson_de-DE_240_480x720_Google_Inc._Google_APIs_8'...
[android] Setting hardware properties: hw.ramSize: 512
$ /ci/home/tools/android-sdk//platform-tools/adb start-server
$ /ci/home/tools/android-sdk//tools/emulator -snapshot-list -no-window -avd hudson_de-DE_240_480x720_Google_Inc._Google_APIs_8
[android] Starting Android emulator and creating initial snapshot
[android] Erasing existing emulator data...
$ /ci/home/tools/android-sdk//tools/emulator -no-boot-anim -ports 64470,64471 -prop persist.sys.language=de -prop persist.sys.country=DE -avd hudson_de-DE_240_480x720_Google_Inc._Google_APIs_8 -no-snapshot-load -no-snapshot-save -wipe-data
* daemon not running. starting it now on port 64472 *
* daemon started successfully *
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
[android] Waiting for emulator to finish booting...
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471
shell getprop dev.bootcomplete error: device offline
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 shell getprop dev.bootcomplete
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 shell getprop dev.bootcomplete
$ /ci/home/tools/android-sdk//platform-tools/adb disconnect localhost:64471
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 shell getprop dev.bootcomplete
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 shell getprop dev.bootcomplete
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 shell getprop dev.bootcomplete
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 logcat -v time
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
[android] Attempting to unlock emulator screen
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 shell input keyevent 82
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 shell input keyevent 4
[android] Giving the system some time to settle before creating initial snapshot...
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 logcat -c
$ /ci/home/tools/android-sdk//platform-tools/adb -s localhost:64471 shell log -p v -t Jenkins "Creating snapshot..."
[android] Creating snapshot...
$ /ci/home/tools/android-sdk//platform-tools/adb connect localhost:64471
[android] Emulator is ready for use (took 158 seconds)
Buildfile for an example job:
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.plugins.git.GitSCM">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<name></name>
<refspec></refspec>
<url>git#project...</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<disableSubmodules>false</disableSubmodules>
<recursiveSubmodules>false</recursiveSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<authorOrCommitter>false</authorOrCommitter>
<clean>false</clean>
<wipeOutWorkspace>false</wipeOutWorkspace>
<pruneBranches>false</pruneBranches>
<remotePoll>false</remotePoll>
<ignoreNotifyCommit>false</ignoreNotifyCommit>
<useShallowClone>false</useShallowClone>
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
<gitTool>default</gitTool>
<submoduleCfg class="list"/>
<relativeTargetDir></relativeTargetDir>
<reference></reference>
<excludedRegions></excludedRegions>
<excludedUsers></excludedUsers>
<gitConfigName></gitConfigName>
<gitConfigEmail></gitConfigEmail>
<skipTag>false</skipTag>
<includedRegions></includedRegions>
<scmName></scmName>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>true</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>true</blockBuildWhenUpstreamBuilding>
<triggers class="vector">
<hudson.triggers.SCMTrigger>
<spec>*/5 * * * *</spec>
</hudson.triggers.SCMTrigger>
</triggers>
<concurrentBuild>false</concurrentBuild>
<builders>
<hudson.tasks.Ant>
<targets>clean debug install</targets>
<antName>(Default)</antName>
</hudson.tasks.Ant>
<hudson.tasks.Ant>
<targets></targets>
<antName>(Default)</antName>
<buildFile>checkstyle-ant.xml</buildFile>
</hudson.tasks.Ant>
<hudson.tasks.Shell>
<command>os_opts="-Djava.awt.headless=true" lint --xml lint-results.xml .</command>
</hudson.tasks.Shell>
<hudson.plugins.android__emulator.monkey.MonkeyBuilder>
<packageId>de....</packageId>
<eventCount>1000</eventCount>
<throttleMs>10</throttleMs>
<seed>timestamp</seed>
</hudson.plugins.android__emulator.monkey.MonkeyBuilder>
<hudson.tasks.Shell>
... distribution script
</hudson.tasks.Shell>
</builders>
<publishers>
<org.jenkinsci.plugins.android__lint.LintPublisher>
<healthy></healthy>
<thresholdLimit>low</thresholdLimit>
<pluginName>[android-lint] </pluginName>
<defaultEncoding></defaultEncoding>
<canRunOnFailed>false</canRunOnFailed>
<useStableBuildAsReference>false</useStableBuildAsReference>
<useDeltaValues>false</useDeltaValues>
<thresholds>
<unstableTotalAll></unstableTotalAll>
<unstableTotalHigh></unstableTotalHigh>
<unstableTotalNormal></unstableTotalNormal>
<unstableTotalLow></unstableTotalLow>
<unstableNewAll></unstableNewAll>
<unstableNewHigh></unstableNewHigh>
<unstableNewNormal></unstableNewNormal>
<unstableNewLow></unstableNewLow>
<failedTotalAll></failedTotalAll>
<failedTotalHigh></failedTotalHigh>
<failedTotalNormal></failedTotalNormal>
<failedTotalLow></failedTotalLow>
<failedNewAll></failedNewAll>
<failedNewHigh></failedNewHigh>
<failedNewNormal></failedNewNormal>
<failedNewLow></failedNewLow>
</thresholds>
<shouldDetectModules>false</shouldDetectModules>
<dontComputeNew>false</dontComputeNew>
<doNotResolveRelativePaths>false</doNotResolveRelativePaths>
<pattern></pattern>
</org.jenkinsci.plugins.android__lint.LintPublisher>
<hudson.plugins.checkstyle.CheckStylePublisher>
<healthy></healthy>
<unHealthy></unHealthy>
<thresholdLimit>low</thresholdLimit>
<pluginName>[CHECKSTYLE] </pluginName>
<defaultEncoding></defaultEncoding>
<canRunOnFailed>false</canRunOnFailed>
<useStableBuildAsReference>false</useStableBuildAsReference>
<useDeltaValues>false</useDeltaValues>
<thresholds>
<unstableTotalAll></unstableTotalAll>
<unstableTotalHigh></unstableTotalHigh>
<unstableTotalNormal></unstableTotalNormal>
<unstableTotalLow></unstableTotalLow>
<failedTotalAll></failedTotalAll>
<failedTotalHigh></failedTotalHigh>
<failedTotalNormal></failedTotalNormal>
<failedTotalLow></failedTotalLow>
</thresholds>
<shouldDetectModules>false</shouldDetectModules>
<dontComputeNew>true</dontComputeNew>
<doNotResolveRelativePaths>false</doNotResolveRelativePaths>
<pattern></pattern>
</hudson.plugins.checkstyle.CheckStylePublisher>
<hudson.plugins.warnings.WarningsPublisher>
<healthy></healthy>
<unHealthy></unHealthy>
<thresholdLimit>low</thresholdLimit>
<pluginName>[WARNINGS] </pluginName>
<defaultEncoding></defaultEncoding>
<canRunOnFailed>false</canRunOnFailed>
<useStableBuildAsReference>false</useStableBuildAsReference>
<useDeltaValues>false</useDeltaValues>
<thresholds>
<unstableTotalAll></unstableTotalAll>
<unstableTotalHigh></unstableTotalHigh>
<unstableTotalNormal></unstableTotalNormal>
<unstableTotalLow></unstableTotalLow>
<failedTotalAll></failedTotalAll>
<failedTotalHigh></failedTotalHigh>
<failedTotalNormal></failedTotalNormal>
<failedTotalLow></failedTotalLow>
</thresholds>
<shouldDetectModules>false</shouldDetectModules>
<dontComputeNew>true</dontComputeNew>
<doNotResolveRelativePaths>true</doNotResolveRelativePaths>
<parserConfigurations/>
<consoleParsers>
<hudson.plugins.warnings.ConsoleParser>
<parserName>Java Compiler (Eclipse)</parserName>
</hudson.plugins.warnings.ConsoleParser>
</consoleParsers>
</hudson.plugins.warnings.WarningsPublisher>
<hudson.plugins.analysis.collector.AnalysisPublisher>
<healthy></healthy>
<unHealthy></unHealthy>
<thresholdLimit>low</thresholdLimit>
<pluginName>[ANALYSIS-COLLECTOR] </pluginName>
<defaultEncoding></defaultEncoding>
<canRunOnFailed>false</canRunOnFailed>
<useStableBuildAsReference>false</useStableBuildAsReference>
<useDeltaValues>false</useDeltaValues>
<thresholds>
<unstableTotalAll></unstableTotalAll>
<unstableTotalHigh></unstableTotalHigh>
<unstableTotalNormal></unstableTotalNormal>
<unstableTotalLow></unstableTotalLow>
<failedTotalAll></failedTotalAll>
<failedTotalHigh></failedTotalHigh>
<failedTotalNormal></failedTotalNormal>
<failedTotalLow></failedTotalLow>
</thresholds>
<shouldDetectModules>false</shouldDetectModules>
<dontComputeNew>true</dontComputeNew>
<doNotResolveRelativePaths>true</doNotResolveRelativePaths>
<isCheckStyleDeactivated>false</isCheckStyleDeactivated>
<isDryDeactivated>true</isDryDeactivated>
<isFindBugsDeactivated>true</isFindBugsDeactivated>
<isPmdDeactivated>true</isPmdDeactivated>
<isOpenTasksDeactivated>true</isOpenTasksDeactivated>
<isWarningsDeactivated>false</isWarningsDeactivated>
</hudson.plugins.analysis.collector.AnalysisPublisher>
<hudson.plugins.android__emulator.monkey.MonkeyRecorder>
<failureOutcome>FAILURE</failureOutcome>
</hudson.plugins.android__emulator.monkey.MonkeyRecorder>
<hudson.plugins.cigame.GamePublisher/>
<hudson.tasks.Mailer>
<recipients></recipients>
<dontNotifyEveryUnstableBuild>false</dontNotifyEveryUnstableBuild>
<sendToIndividuals>true</sendToIndividuals>
</hudson.tasks.Mailer>
</publishers>
<buildWrappers>
<hudson.plugins.locksandlatches.LockWrapper>
<locks>
<hudson.plugins.locksandlatches.LockWrapper_-LockWaitConfig>
<name>AndroidEmulator</name>
</hudson.plugins.locksandlatches.LockWrapper_-LockWaitConfig>
</locks>
</hudson.plugins.locksandlatches.LockWrapper>
<hudson.plugins.android__emulator.AndroidEmulator>
<osVersion>Google Inc.:Google APIs:8</osVersion>
<screenDensity>240</screenDensity>
<screenResolution>480x720</screenResolution>
<deviceLocale>de_DE</deviceLocale>
<sdCardSize>200M</sdCardSize>
<hardwareProperties>
<hudson.plugins.android__emulator.AndroidEmulator_-HardwareProperty>
<key>hw.ramSize</key>
<value>512</value>
</hudson.plugins.android__emulator.AndroidEmulator_-HardwareProperty>
</hardwareProperties>
<wipeData>false</wipeData>
<showWindow>true</showWindow>
<useSnapshots>true</useSnapshots>
<deleteAfterBuild>false</deleteAfterBuild>
<startupDelay>0</startupDelay>
<commandLineOptions></commandLineOptions>
</hudson.plugins.android__emulator.AndroidEmulator>
</buildWrappers>
</project>
A bug was introduced in SDK Tools r20, whereby trying to list the available snapshots (via the emulator -snapshot-list command) would result in a crash.
Since the command crashes without listing the available snapshots, the Android Emulator Plugin believes that there are no existing snapshots, which causes a new snapshot to be created in every build.
I discovered that these crashes only occur with certain versions of the emulator application, i.e. it is possible to avoid the crash.
Thankfully, the Jenkins plugin lets you select the emulator binary to run.
So you can work around this problem by going into your job configuration, pressing Advanced… in the emulator config and selecting the "emulator-arm" (or another) binary.
In addition to Christopher Orr's answer, there is another possible cause. In my environment, emulator -snapshot-list listed the size of my snapshot as "1.0G". The pattern that matches snapshots in the Android Emulator Plugin as of 2014-01-14 matches whole number megabyte values.
I submitted a pull request to address that cause.

running multiple android emulators

I have more than one android emulator running, along with devices connected to the same machine.
I want to to know how to connect to a single emulator/device from the command prompt.
For example: adb shell emulator-5554
But that doesn't work.
You should use -s switch:
adb -s emulator-5554 shell
with the command
adb devices
you get a list of all connected devices like:
$ adb devices
List of devices attached
emulator-5554 device
emulator-5556 device
emulator-5558 device
Then you can run all commands normally, but you have to attach the -s option
e.g.
adb -s emulator-5556 install helloWorld.apk
Take a look at the tutorial if you want to know more about adb.
adb connect xx.xx.xx.xx
adb disconnect xx.xx.xx.xx
it can be X86 Emulators ;)
http://blog.gokifu.com/2011/05/android-x86-faster-emulator/

Categories

Resources