Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Espresso test on Android P Preview: Detected problems with API compatibility error

I am using Espresso for instrumentation testing and running them on Android Preview P Emulator. I have 5 test cases in my test class out of which one test is failing when running the test suite and getting the error below.

Detected problems with API compatibility

Whereas the failing test case is passing when run individually and not in suite.

Since the dialog gets displayed on the view which says Detected problems with API compatibility, I am getting no matching view found in hierarchy exception along with the above mentioned error.

like image 952
Charu Rani Avatar asked Apr 21 '18 15:04

Charu Rani


2 Answers

Changing targetSdkVersion to 28 (previously was 27) made the problem disappear. I assume for most of the cases this won't be a valid solution but in my case, it allowed to go forward with my project.

like image 162
Efi G Avatar answered Nov 15 '22 13:11

Efi G


Referencing to docs: In Android P, this dialog showing

Detected problems with API compatibility

Why this dialog is being shown?

Reason: Your code hit the

dark greylist

What are dark greylist apis? Such apis that are not permissible to call by other apps, In my case i was using the startSoftAp method that was dark grey listed. Removing that call vanished the dialog.

How will you find?

In your logcat -> verbose -> Search("Accessing hidden")

LOGCAT RESULT

Accessing hidden method:Landroid/net/wifi/WifiManager:startSoftAp(Landroid/net/wifi/WifiConfiguration;)Z (dark greylist, reflection)

like image 3
SaadurRehman Avatar answered Nov 15 '22 15:11

SaadurRehman