Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio Instrumented Test stuck at: Task :app:connectedDebugAndroidTest

I have encountered a problem that when I tried to run Android Instrument test, android studio will start building, everything is good until it stuck to this line

"> Task :app:connectedDebugAndroidTest"

and run for the next 2hrs and never proceed the actual test. What I have seen is that the test app has been successfully built into my device but just won't open and run.

Strange thing is that I have built successfully once before, but after when I tried to build again, it never success anymore. Even when I didn't change my code.

Here are the things I had tried

  • Update Android Studio - version 2021.3.1 Patch 1
  • Clean and Rebuild Project
  • Invalidate cache and Restart
  • Update SDK build tools
  • Restart Computer
  • Restart phone device

But still can't build!

Here is my instrument test class screen shot

Here is my instrument test class

running process screen shot

enter image description here

enter image description here

Has anyone had this problem before?

like image 234
GAME TTXD Avatar asked Sep 13 '25 10:09

GAME TTXD


1 Answers

Found answer to this issue. Apparently when you open logcat side by side when building, you encounter this error which is the root cause of build never completing:

java.lang.ClassNotFoundException: Didn't find class "androidx.test.platform.io.PlatformTestStorageRegistry"

Add this dependency to get this class:

debugImplementation "androidx.test:monitor:1.6.1"

You're good to go :)

like image 75
Jasjeet Singh Avatar answered Sep 15 '25 01:09

Jasjeet Singh