Android Unit tests running forever in android studio - android

For whatever reason the unit tests in Android Studio will not stop running despite hitting the stop button multiple times.
I've tried ./gradlew --stop in the terminal already, and I've also checked Android Instrumentation Tests Stuck "Running Tests" Forever Android Studio, as well as well as Gradle Build too long, but they did not solve my problem.
If someone can please help me I will greatly appreciate it. Thanks!
Picture of android Studio screen showing the running processes in the top right

Related

Instrumented test is stuck on "Connected to process"

When I try to run the ExampleInstrumentedTest on my Android Studio project, it builds fine, installs the test and then it is stuck on "Connected to process ####..." and no test results are displayed.
I've waited for more than 2 minutes and still no result. When I create a new Android Studio project with Empty Activity, the test runs fine and results are displayed. It's not working unfortunately for my existing project which I had been working on for a long time but never tried to run the Example test.
Things I've tried:
Restart Physical device
Uninstall app
Invalidate Caches and Restart
Clean Project
Here's the screenshot of how it looks like:
I don't know how I solved this problem but these are the changes I made:
I changed the Kotlin version from 1.6 to 1.7.
I removed an unnecessary test file Navigation.
I removed all the unnecessary testing dependencies.
And, finally I clean built the project and voila. It works.

Android Studio gradle build got stuck

Recently my android studio got stuck in gradle building very frequently, as shown in the picture above, which already took 30m to run and still keeps running. The only way to finish it is just force to stop android studio and restart the computer. Is there any way to solve this problem? Thanks for any idea!

Android Studio 3.2 empty test suite

I have created a new project in Android Studio 3.2. Without making any changes I am not able to run all the unit tests in the group. I receive and error saying No tests were found
I am attempting to run the tests by right clicking on the group and clicking Run Tests.
I can run the unit tests if I open up the file and click on the run button next to the class declaration. I can also run the unit tests if I open the project in Android Studio 3.1.4. I can right click on the group and run all the unit tests with no error.
Looking at this bug report, I think it should be fixed in 3.2.1: https://issuetracker.google.com/issues/115708445#comment12
After spending an entire day trying resolve this while writing some unit tests I found one workaround that works for my project.
Basically what my workaround is to add Build to the Before launch options.
After adding this option I'll occasionally get the No tests found error message but simply rerunning the test worked every time after adding that setting.
I'm not sure if it will help with everyone's problem but it seems to have mitigated the issue with my project. Hopefully this works for someone else as well.
The workaround until the bug is fixed is running tests in terminal, just type:
./gradlew test
or
./gradlew testDebugUnitTest. If you are using Windows replace ./gradlew with gradlew.bat. You can also download Android Studio 3.3 Canary from here https://developer.android.com/studio/preview/ – there aren't problems with running tests via this version.

Android studio build fast but run wrong in emulator

Exactly my problem, if I have small change in app about display UI (modify activity code or resource layout), Android studio build very fast and then run my app in emulator without kill "previous version" process (running in emulator), sometime it's run and display correct, but sometime it doesn't run correct what I want, I must kill process manual and rebuild project, it takes a lot of time, and makes me confused because I don't know where go wrong,
I thought this is my bug.
It happen recently when I update Android studio, I think this feature is very powerful and helpful, application mustn't rerun from the beginning whenever build new version.
But how to enabled/disabled "fast build", sometime I want Android studio build my project normally.
You have 2 solution:
1)You can also disable Instant Run from Settings > Build,Execution,Deployment > Instant Run - and disable it
2)Clean Project when studio doesn't build properly
Press the stop button before running the app and then run the app so dialog will be displayed to choose the emulator.

Test launch failed due to internal error: Running tests on UI thread

I am creating a unit testing project for my application. It was working fine before. but I had updated the ADT plugin and android SDK. after that I could launch this project but cannot separately run the test cases. It will execute first test case and then stop. Before I could manually execute the second testcase. But now when I tried to do that I got error "Test launch failed due to internal error: Running tests on UI thread".please help me to solve this...
note:using robotium 3.2.1
Are you running the indidual method from a test from the Eclipse Junit window? Try running the test method from project explorer. Right click and run from the Project Explorer, not the JUnit window.
RightHandedMonkey's work-around works for me.
It also looks like this is a known issue and will be fixed in ADT 21 (see: http://code.google.com/p/android/issues/detail?id=34170)
There's also a changelist there to pull the fix if you are building the ADT from source.

Categories

Resources