7

I tried to run a test on a device(non-handheld) that is connected over ethernet, but all I see is a failure. I use the Gradle task connectedAndroidTest to run the instrumentation tests and is working fine on a handheld device connected over USB directly to my PC. However, the same test could not be even started on the remote device. The error shown is "No tests found". Previously I have seen the same error if I start the instrumentation test without any device connected, but Android Studio as well as the output from adb devices showed that the remote device is seen by the toolchain. Then I tried to run the same Gradle task but on the command line, with more info. So I entered:
gradlew connectedAndroidTest --stacktrace --debug

In the bunch of debug output I found a better description of the error:

[INFO] [org.gradle.api.Project] Skipping device 'DEVICE_IP:5555' for 'AppNameHere:': Unknown API Level
[WARN] [org.gradle.api.Project]
_FoundCompatibleDevices[TestRunner] FAILED

I searched this error in google and I stumbled upon the source code that prints it. So I downloaded the android's platform tools source code to be able to more easily navigate through it and it seems to me that the API level is detected by reading property IDevice.PROP_BUILD_API_LEVEL, which seems to be equal to "ro.build.version.sdk". After some more googling I found that it should be defined in /system/build.prop. The content of this file on the device showed me that it has the correct API level 19. And actually the same API level is shown in Android Studio, the android tab that shows the current connected devices (and their logcat output, open processes etc). However, it seems that in some cases this value is not getting correct.

Any idea where things could get wrong? Where should I look for the real problem here? In Android's toolchain, Android on the device, something was done wrong during my investigation?

I am currently using:
- Windows 7
- Android Studio 1.1 Preview 1
- Android SDK Tools 24.0.2
- Android SDK Platform-tools 21
- Android SDK Build-tools 19.1

Abhinav
  • 83
  • 1
  • 10
dragi
  • 3,385
  • 5
  • 22
  • 40
  • any update on this? Im also having the same issue trying to run connectedAndroidTests on jenkins on a remote server.. – sirFunkenstine Mar 05 '15 at 10:45
  • @sirFunkenstine No, but I haven't been dealing with it recently. I guess I will try again soon and if I have any updates, I will add them here. I would expect the same from you as well ;) – dragi Mar 05 '15 at 11:39
  • I'm voting to close this question as off-topic because the problem is not reproducible anymore. I am not REALLY sure it should be closed, but it seems my setup is not used that much on SO. Besides that I am not sure what was the root-cause of the issue - Android OS on the device may be updated and/or I have updated few times Android Studio & tools since the issue has occurred so the "fix" is not known to me, but some of the answers(wrong for my case) may be helpful to others, according to votes. – dragi Apr 27 '15 at 10:51
  • for me, it was just a matter of detaching and reattaching the cable to my device.. – eis Aug 05 '18 at 18:58

5 Answers5

4

So I was encountering the same issue getting my robotium integration tests to run on a remote jenkins server. I fixed finally it by adding a local.properties file to the remote android projects root directory and adding in the sdk path. For me it looked like this.

   sdk.dir=/usr/local/sdk

Then i was getting a device not connected error so i had to run

/pathToAndroidSdk/platform-tools/adb start-server

and authenticate the device i had plugged in. Ive lost most of my hair in the process but Now the integration tests are running properly.

Let me know if you have any other issues.

sirFunkenstine
  • 8,135
  • 6
  • 40
  • 57
  • 7
    How do you `authenticate` the device? I am stuck with `Skipping device 'testAVD(AVD)' for 'app:': Unknown API Level > : No compatible devices connected.[TestRunner] FAILED Found 1 connected device(s), 0 of which were compatible.` The avd has started and is connected but not recognised on the gilab-CI localy an equivalent emulator works. :-( – madlymad Apr 07 '18 at 17:21
  • 1
    Please tell us how you authenticated the device. – yUdoDis Jan 02 '19 at 12:20
  • I am also stuck in authenticating the device. Were you able to find any solution to it @madlymad – Prethia Jan 20 '21 at 14:35
0

I ran into the same error. I suspected the device hadn't fully booted, so I added

while ! "$ANDROID_HOME/platform-tools/adb" shell getprop ro.build.version.sdk; do
  sleep 1
done

That seems to be working for me.

Update: it might be better to check init.svc.bootanim as Travis CI's android-wait-for-emulator script does. See also Detect when Android emulator is fully booted.

Community
  • 1
  • 1
Daniel Lubarov
  • 7,796
  • 1
  • 37
  • 56
  • In my case the device is always fully booted when I try to run the tests, so this would not make a difference. – dragi Apr 27 '15 at 10:27
0

I had to change my USB configuration from Charging to MIDI.

In my Samsung I had to go into Configurations -> Developer options -> USB configuration.

double-beep
  • 5,031
  • 17
  • 33
  • 41
0

I encountered the same issue when setting up my REACT-NATIVE application on my physical android device. I managed to install the app by switching the 'Select USB configuration' in the phone's developer options to 'RNDIS (USB ethernet)'.

Fronzie
  • 33
  • 6
0

When a "always accept this computer" usb debug message appears check always accept. For me it solved.