Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android espresso test fails with UnknownServiceException: CLEARTEXT

Our UI tests fail for Android 9 because our test environments don't use HTTPS. The problem is that we are making network calls from the espresso tests (for example creating brand new user directly on the back end to be used in the test) which means they run on the espresso test app.

Adding networkSecurityConfig to the app manifest does not help because the app is not the problem but the espresso app.

How can I fix this? Does the espresso app have manifest where I can add that or any way to change this permission programmatically?

My question is different from

CLEARTEXT communication not supported on Retrofit and Android 8: Cleartext HTTP traffic not permitted

Because I can't find a way to access the espresso app manifest. I can make the changes in my app manifest but it does not matter because the app is already working. I'm failing from the espresso part.

like image 654
STARGATEBG Avatar asked Nov 07 '22 22:11

STARGATEBG


1 Answers

Go to Android Manifest file. In the Application tag, write this line

android:usesCleartextTraffic="true"
like image 59
MANOJ G Avatar answered Nov 15 '22 11:11

MANOJ G