Android: how to install toolkit APK on AVD in a headless host

I am trying to integrate Android JUnit tests with our Bamboo Ant builds. I have already tested the installation locally and I can run the tests.

But when I tried the same setup on our Bamboo server, when I run the tests, I get the following error:

INSTRUMENTATION_STATUS: id=ActivityManagerService INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{com.synapticstuff.guitartabs/pl.polidea.instrumentation.PolideaInstrumentationTestRunner} INSTRUMENTATION_STATUS_CODE: -1 android.util.AndroidException: INSTRUMENTATION_FAILED: com.synapticstuff.guitartabs/pl.polidea.instrumentation.PolideaInstrumentationTestRunner 

Please note that I used a special library for Instrumentation ( http://code.google.com/p/the-missing-android-xml-junit-test-runner/ ) so that I can pull out the JUNit xml test results and submit it to the bamboo.

In addition, the assembly agent used to create the assembly is the Ubuntu virtual machine, which does not have a graphical interface, so I need to do everything through the command line. AVD is already running on this virtual machine.

I ran into the same problem when I first ran the adb shell am instrument .. <snip> locally, and it seemed strange to me that it worked after running the test from Eclipse.

By raising the error log, the Android Instrumentation Framework tells me that

"It is possible that the apk device is not installed on your device or the package name is incorrect in the manifest file."

therefore, it must be established that the hardware apk is not installed.

So, how do I install the apk hardware on AVD?

Thanks!

+6
source share
6 answers

There are probably several situations that can cause this error, but I got it from the fact that the instrumental version of the test package was not installed on the emulator. The documentation is a bit sparse, but I donโ€™t think there is a โ€œtool APKโ€ that you install on the emulator (at least I couldnโ€™t find such a thing); You are creating a test application with instrumentation turned on. Anyway, this is how I run tests from the command line using ant, which now works:

 ant instrument install test 

and it also works on Jenkins using the Android emulator plugin ( https://wiki.jenkins-ci.org/display/JENKINS/Android+Emulator+Plugin ). I found the tool task in the documentation for building the command line: http://developer.android.com/tools/building/building-cmdline.html .

+3
source

There is another possible reason: the package name in the manifest file is incorrect.

First check the package name in the unit test project manifest file!

+2
source

I am also one of the few people who downloaded this custom InstrumentationTestRunner ( http://code.google.com/p/the-missing-android-xml-junit-test-runner/ ), and I'm currently stuck with this a problem! I get the same error message, unfortunately I do not know the answer right now, but I update when I find something useful. In the meantime, I was looking for other options, such as this person. Runner Run: http://www.alittlemadness.com/2010/07/14/android-testing-xml-reports-for-continuous-integration/

There is also another discussion related to continuous integration: How to automatically generate Android test report in HTML

+1
source

you can solve this problem if you add a script to your assembly:

 adb install -r testproject/bin/testproject.apk 

first check what the apk file is named because I still do not understand how ant will do it exactly, but it is usually created in the bin directory.

See also the official Android documentation.

+1
source

I ran into this problem while running my tests against an old Android 1.5 virtual device. After switching to 2.3.3 virtual device, the problem disappeared. I do not know if the problem is that the virtual device OS is old or the virtual device is created with the old Android SDK tools.

0
source

I ran into the same problem when running android build under Bamboo. I found that for some reason, the android:targetPackage in my test project manifest was incorrect. It was configured as a package of my main project, not a test project. For some reason, starting when running tests in eclipse eveything worked fine, but it died when I tried to run the ant test on the command line. Key instrumental measuring system read:

 <instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.example.blah" /> 

This was automatically created by eclipse when I created the project. I changed it to read:

 <instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.example.blah.test" /> 

and all of a sudden everything went fine.

-1
source

Source: https://habr.com/ru/post/892225/


All Articles