Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Unknown API level" error when trying to run instrumentation test

Tags:

android

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

like image 966
dragi Avatar asked Jan 28 '15 14:01

dragi


1 Answers

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.

like image 70
sirFunkenstine Avatar answered Sep 29 '22 00:09

sirFunkenstine