Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lambdatest integration java.lang.RuntimeException: Unable to instantiate instrumentation #2493

Open
DmytroChuchmaiBarges opened this issue Jan 16, 2025 · 12 comments
Assignees
Labels
device farms integration Related to issues with running patrol on device farms

Comments

@DmytroChuchmaiBarges
Copy link

DmytroChuchmaiBarges commented Jan 16, 2025

Steps to reproduce

  1. Write any patrol test, and make sure it is running with patrol_cli 3.4.1
  2. open /app/build.gradle and replace testInstrumentationRunner "pl.leancode.patrol.PatrolJUnitRunner" with pl.leancode.patrol.LambdaTestPatrolJUnitRunner
  3. run "patrol test --targets integration_test/your_test.dart --debug --verbose"
    expected: the tests should normally run
    actual: test don't run, an app is installed on emulator and then deleted
    when upload to LambdaTest, same behavior in the test logs, as in local test report

Actual results

When I build an app with testInstrumentationRunner "pl.leancode.patrol.LambdaTestPatrolJUnitRunner"
upload to lambdatest or run tests locally via "patrol test" command
it produces an error in test report:

java.lang.RuntimeException: Unable to instantiate instrumentation ComponentInfo{com.myapp.stage.test/pl.leancode.patrol.LambdaTestPatrolJUnitRunner}: java.lang.ClassNotFoundException: Didn't find class "pl.leancode.patrol.LambdaTestPatrolJUnitRunner"

Logs

Logs
java.lang.RuntimeException: Unable to instantiate instrumentation ComponentInfo{com.myapp.stage.test/pl.leancode.patrol.LambdaTestPatrolJUnitRunner}: java.lang.ClassNotFoundException: Didn't find class "pl.leancode.patrol.LambdaTestPatrolJUnitRunner"
on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/system/framework/android.test.base.jar", zip file "/data/app/~mMW9Tm-zvsGOd0DDxE2vhA==/com.myapp.stage.test-ElPT892YUgrP1yN5Z3ZkSg==/base.apk", zip file "/data/app/~~JQpVigu8CctLgvcT3ao-qg==/com.myapp.stage.test-plChV-l37OLMbYeJfvtJiw==/base.apk"],nativeLibraryDirectories=[/system/lib64, /system_ext/lib64]]

Patrol version

patrol: 3.13.1

Patrol Doctor output

Patrol Doctor output
Patrol CLI version: 3.4.1
Flutter command: flutter 
  Flutter 3.24.4 • channel [user-branch]
Android: 
• Program adb found in /Users/dchuchmai/Library/Android/sdk/platform-tools/adb
• Env var $ANDROID_HOME set to /Users/dchuchmai/Library/Android/sdk
iOS / macOS: 
• Program xcodebuild found in /usr/bin/xcodebuild
• Program ideviceinstaller found in /opt/homebrew/bin/ideviceinstaller

Flutter Doctor output

Flutter Doctor output
[!] Flutter (Channel [user-branch], 3.24.4, on macOS 15.1.1 24B91 darwin-arm64, locale en-UA)
    ! Flutter version 3.24.4 on channel [user-branch] at /Users/dchuchmai/src/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.95.3)
[✓] Connected device (4 available)
[✓] Network resources
@Paul2022-app
Copy link

Same Issue

@zoskar zoskar self-assigned this Jan 20, 2025
@zoskar
Copy link

zoskar commented Jan 22, 2025

Hi @DmytroChuchmaiBarges, thanks for the report. We will investigate that

@zoskar zoskar assigned fylyppo and unassigned zoskar Jan 22, 2025
@zoskar zoskar added the device farms integration Related to issues with running patrol on device farms label Jan 22, 2025
@DmytroChuchmaiBarges
Copy link
Author

patrol 3.14 and cli 3.5.0
I got following output from lambdatest:
`INSTRUMENTATION_STATUS: class=co.myapppackage.android.staging_new.MainActivityTest
INSTRUMENTATION_STATUS: current=1
INSTRUMENTATION_STATUS: id=AndroidJUnitRunner
INSTRUMENTATION_STATUS: numtests=1
INSTRUMENTATION_STATUS: stream=
co.myapppackage.android.staging_new.MainActivityTest:
INSTRUMENTATION_STATUS: test=initializationError
INSTRUMENTATION_STATUS_CODE: 1
INSTRUMENTATION_STATUS: class=co.myapppackage.android.staging_new.MainActivityTest
INSTRUMENTATION_STATUS: current=1
INSTRUMENTATION_STATUS: id=AndroidJUnitRunner
INSTRUMENTATION_STATUS: numtests=1
INSTRUMENTATION_STATUS: stack=java.lang.RuntimeException: pl.leancode.patrol.contracts.PatrolAppServiceClientException: Invalid response 500, dial tcp 127.0.0.1:8082: connect: connection refused

at pl.leancode.patrol.PatrolJUnitRunner.listDartTests(PatrolJUnitRunner.java:126)
at co.myapppackage.android.staging_new.MainActivityTest.testCases(MainActivityTest.java:17)
... 21 trimmed

Caused by: pl.leancode.patrol.contracts.PatrolAppServiceClientException: Invalid response 500, dial tcp 127.0.0.1:8082: connect: connection refused

at pl.leancode.patrol.contracts.PatrolAppServiceClient.listDartTests(PatrolAppServiceClient.kt:18)
at pl.leancode.patrol.PatrolAppServiceClient.listDartTests(PatrolAppServiceClient.kt:46)
at pl.leancode.patrol.PatrolJUnitRunner.listDartTests(PatrolJUnitRunner.java:114)
... 23 more

INSTRUMENTATION_STATUS: stream=
Error in initializationError(co.myapppackage.android.staging_new.MainActivityTest):
java.lang.RuntimeException: pl.leancode.patrol.contracts.PatrolAppServiceClientException: Invalid response 500, dial tcp 127.0.0.1:8082: connect: connection refused

at pl.leancode.patrol.PatrolJUnitRunner.listDartTests(PatrolJUnitRunner.java:126)
at co.myapppackage.android.staging_new.MainActivityTest.testCases(MainActivityTest.java:17)
... 21 trimmed

Caused by: pl.leancode.patrol.contracts.PatrolAppServiceClientException: Invalid response 500, dial tcp 127.0.0.1:8082: connect: connection refused

at pl.leancode.patrol.contracts.PatrolAppServiceClient.performRequest(PatrolAppServiceClient.kt:47)
at pl.leancode.patrol.contracts.PatrolAppServiceClient.performRequest$default(PatrolAppServiceClient.kt:27)
at pl.leancode.patrol.contracts.PatrolAppServiceClient.listDartTests(PatrolAppServiceClient.kt:18)
at pl.leancode.patrol.PatrolAppServiceClient.listDartTests(PatrolAppServiceClient.kt:46)
at pl.leancode.patrol.PatrolJUnitRunner.listDartTests(PatrolJUnitRunner.java:114)
... 23 more

INSTRUMENTATION_STATUS: test=initializationError
INSTRUMENTATION_STATUS_CODE: -2`

@Paul2022-app
Copy link

I fixed it after running flutter clean

@DmytroChuchmaiBarges
Copy link
Author

I fixed it after running flutter clean

with 3.14 it builds fine but on LambdaTest it runs a very first test and fails the build, and the results show all (11 in my case) tests but when you open to watch video, it shows the video from that 1st test.

@fylyppo
Copy link
Collaborator

fylyppo commented Jan 27, 2025

@DmytroChuchmaiBarges I suppose you used this doc, it's a great mistake that it's linked in our documentation.
You should use Espresso endpoints https://www.lambdatest.com/support/docs/getting-started-with-espresso-testing/

@DmytroChuchmaiBarges
Copy link
Author

@fylyppo I followed the doc you've mentioned above, using pl.leancode.patrol.LambdaTestPatrolJUnitRunner
So the tests went a bit forward: I got the list of my tests displayed, but each of them fails with error in instrumentation logs:
onError: commandError=true message=Invalid userId -2
Activity manager (activity) commands:

@iammofidul
Copy link

@DmytroChuchmaiBarges were you able fix it
We are also planning to use patrol with Lambdatest

@iammofidul
Copy link

@fylyppo Please look into this
Patrol is pretty good and it runs locally well
We are planning to migrate flutter test to patro test but Integration with Lambdatest is must for us

@iammofidul
Copy link

I am getting this exception on lambda
Raw Crash Logs 02-03 19:53:51.473 9573 9573 E AndroidRuntime: FATAL EXCEPTION: main 02-03 19:53:51.473 9573 9573 E AndroidRuntime: Process: in.stage.dev, PID: 9573 02-03 19:53:51.473 9573 9573 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate instrumentation ComponentInfo{in.stage.dev.test/pl.leancode.patrol.LambdaTestPatrolJUnitRunner}: java.lang.ClassNotFoundException: Didn't find class "pl.leancode.patrol.LambdaTestPatrolJUnitRunner" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/system/framework/android.test.base.jar", zip file "/data/app/~~M-e3i3dUS_uqHGoEjpV4QA==/in.stage.dev.test-8KFOUYenbpMuGellz8wY7g==/base.apk", zip file "/data/app/~~rmUjEx_toMx92O2MH02qOA==/in.stage.dev-xt2HlrVdF0mKbiB2y_QoPA==/base.apk"],nativeLibraryDirectories=[/system/lib64, /system/system_ext/lib64]] 02-03 19:53:51.473 9573 9573 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7496) 02-03 19:53:51.473 9573 9573 E AndroidRuntime: at android.app.ActivityThread.access$1500(ActivityThread.java:301) 02-03 19:53:51.473 9573 9573 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2166) 02-03 19:53:51.473 9573 9573 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106) 02-03 19:53:51.473 9573 9573 E AndroidRuntime: at android.os.Looper.loop(Looper.java:246) 02-03 19:53:51.473 9573 9573 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8633) 02-03 19:53:51.473 9573 9573 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 02-03 19:53:51.473 9573 9573 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) 02-03 19:53:51.473 9573 9573 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130) 02-03 19:53:51.473 9573 9573 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "pl.leancode.patrol.LambdaTestPatrolJUnitRunner" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/system/framework/android.test.base.jar", zip file "/data/app/~~M-e3i3dUS_uqHGoEjpV4QA==/in.stage.dev.test-8KFOUYenbpMuGellz8wY7g==/base.apk", zip file "/data/app/~~rmUjEx_toMx92O2MH02qOA==/in.stage.dev-xt2HlrVdF0mKbiB2y_QoPA==/base.apk"],nativeLibraryDirectories=[/system/lib64, /system/system_ext/lib64]] 02-03 19:53:51.473 9573 9573 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207) 02-03 19:53:51.473 9573 9573 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:379) 02-03 19:53:51.473 9573 9573 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:312) 02-03 19:53:51.473 9573 9573 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7492) 02-03 19:53:51.473 9573 9573 E AndroidRuntime: ... 8 more

@DmytroChuchmaiBarges
Copy link
Author

DmytroChuchmaiBarges commented Feb 4, 2025

@iammofidul nope, I can't get what caused that issue.
and about the stacktrace you write, It seams there can be an issue with "patrol build" command, in my case, I don't do patrol build, since the build dirs remain empty after it (try it by removing the build/app folder), so I do "patrol test" for running the tests and as soon as the tests start, I stop the execution, then I upload the tests from build/app/outputs/apk/androidTest/stage/debug/app-stage-debug-androidTest.apk folder and app from build/app/outputs/apk/stage/debug/app-stage-debug.apk

@iammofidul
Copy link

iammofidul commented Feb 4, 2025

I have tried this but getting this class not found exception

java.lang.RuntimeException: Unable to instantiate instrumentation ComponentInfo{in.stage.dev.test/pl.leancode.patrol.LambdaTestPatrolJUnitRunner}: java.lang.ClassNotFoundException: Didn't find class "pl.leancode.patrol.LambdaTestPatrolJUnitRunner" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file
lambda-logs-devicelog-txt
Note : We have dev android flavor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
device farms integration Related to issues with running patrol on device farms
Projects
None yet
Development

No branches or pull requests

5 participants