Could not start a new session

Hi,

I’m trying to automate android testing with github actions.
When I start appium programmatically, getting the below error, but the same code works fine when I execute it on my mac.
I use the same java, node, appium and UiAutomator2 versions across environments.

@Login 
Scenario Outline: Unsuccessful login. - UnHappy Path                 # src/test/resources/features/Login.feature:26
Starting appium server
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
[Appium] Welcome to Appium v2.0.1
[Appium] Non-default server args:
[Appium] { address: '127.0.0.1', sessionOverride: true }
[Appium] Attempting to load driver uiautomator2...
[debug] [Appium] Requiring driver at /home/runner/.appium/node_modules/appium-uiautomator2-driver
[Appium] Appium REST http interface listener started on http://127.0.0.1:4723
[Appium] Available drivers:
[Appium]   - [email protected] (automationName 'UiAutomator2')
[Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use.
[HTTP] --> GET /status
[HTTP] {}
[debug] [AppiumDriver@1dac] Calling AppiumDriver.getStatus() with args: []
[debug] [AppiumDriver@1dac] Responding to client with driver.getStatus() result: {"build":{"version":"2.0.1"}}
[HTTP] <-- GET /status 200 5 ms - 39
[HTTP] 
[HTTP] --> GET /status
[H[   70.470878] healthd: battery l=100 v=5000 t=25.0 h=2 st=2 c=900000 fc=3000000 cc=10 chg=a
[   70.980486] binder: undelivered TRANSACTION_COMPLETE
[   70.982457] binder_cleanup_transaction: 3 callbacks suppressed
[   70.982458] binder: undelivered transaction 312840, process died.
[   71.527650] binder: 1065:1300 transaction failed 29189/-22, size 3292-0 line 2920
[   71.557773] binder: 1065:1300 transaction failed 29189/-22, size 2244-0 line 2920
[   71.580825] binder: 1065:1298 transaction failed 29189/-22, size 2560-0 line 2920
[   71.583438] binder: 1065:1300 transaction failed 29189/-22, size 3128-0 line 2920
[   71.647489] binder: 1065:1300 transaction failed 29189/-22, size 524-0 line 2920
[   71.697644] binder: 1065:1300 transaction failed 29189/-22, size 2700-0 line 2920
[   71.835995] binder: 1065:1300 transaction failed 29189/-22, size 168-0 line 2920
[   71.870918] binder: 1065:1298 transaction failed 29189/-22, size 168-0 line 2920
[   75.304376] binder_alloc: 1065: binder_alloc_buf size 1056768 failed, no address space
[   75.306733] binder_alloc: allocated: 0 (num: 0 largest: 0), free: 1040384 (num: 1 largest: 1040384)
[   75.329630] binder: 1176:3030 transaction failed 29201/-28, size 1056768-0 line 3101
[   75.369698] logd: logdr: UID=10116 GID=10116 PID=1176 n tail=0 logMask=4 pid=0 start=0ns deadline=0ns
TTP] {}
[debug] [AppiumDriver@1dac] Calling AppiumDriver.getStatus() with args: []
[debug] [AppiumDriver@1dac] Responding to client with driver.getStatus() result: {"build":{"version":"2.0.1"}}
[HTTP] <-- GET /status 200 1 ms - 39
[HTTP] 
Appium server started
getting capabilities
appUrl is/home/runner/work/app-release.apk
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. 
Host info: host: 'runner', ip: '10.0.0.36'
Build info: version: '4.11.0', revision: '040bc5406b'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-1042-azure', java.version: '17.0.7'
Driver info: io.appium.java_client.android.AndroidDriver
Command: [null, newSession {capabilities=[{appium:app=/home/runner/work/app-release.apk, appium:appActivity=com.app.Mobile.MainActivity, appium:appPackage=com.app.Mobile, appium:automationName=UiAutomator2, appium:chromeDriverPort=11002, appium:deviceName=Pixel 6 API 33 5gb A13, appium:fullReset=true, appium:isHeadless=true, platformName=ANDROID, appium:platformVersion=13.0, appium:systemPort=10002, appium:udid=emulator-5554}], desiredCapabilities=Capabilities {app: /home/runner/work/tests.app..., appActivity: com.app.Mobile..., appPackage: com.app.Mobile, automationName: UiAutomator2, chromeDriverPort: 11002, deviceName: Pixel 6 API 33 5gb A13, fullReset: true, isHeadless: true, platformName: ANDROID, platformVersion: 13.0, systemPort: 10002, udid: emulator-5554}}]
Capabilities {app: /home/runner/work/tests.app..., appActivity: com.app.Mobile..., appPackage: com.app.Mobile, automationName: UiAutomator2, chromeDriverPort: 11002, deviceName: Pixel 6 API 33 5gb A13, fullReset: true, isHeadless: true, platformName: ANDROID, platformVersion: 13.0, systemPort: 10002, udid: emulator-5554}
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:536)
	at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:274)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:159)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:89)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:101)
	at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:113)
	at org.Mobile.utilities.DriverManager.initializeDriver(DriverManager.java:29)
	at org.Mobile.stepDefinitions.Hooks.initialize(Hooks.java:19)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at io.cucumber.java.Invoker.doInvoke(Invoker.java:66)
	at io.cucumber.java.Invoker.invoke(Invoker.java:24)
	at io.cucumber.java.AbstractGlueDefinition.invokeMethod(AbstractGlueDefinition.java:47)
	at io.cucumber.java.JavaHookDefinition.execute(JavaHookDefinition.java:64)
	at io.cucumber.core.runner.CoreHookDefinition.execute(CoreHookDefinition.java:46)
	at io.cucumber.core.runner.HookDefinitionMatch.runStep(HookDefinitionMatch.java:21)
	at io.cucumber.core.runner.ExecutionMode$1.execute(ExecutionMode.java:10)
	at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:85)
	at io.cucumber.core.runner.TestStep.run(TestStep.java:57)
	at io.cucumber.core.runner.TestCase.run(TestCase.java:78)
	at io.cucumber.core.runner.Runner.runPickle(Runner.java:75)
	at io.cucumber.junit.PickleRunners$NoStepDescriptions.lambda$run$0(PickleRunners.java:151)
	at io.cucumber.core.runtime.CucumberExecutionContext.lambda$runTestCase$5(CucumberExecutionContext.java:129)
	at io.cucumber.core.runtime.RethrowingThrowableCollector.executeAndThrow(RethrowingThrowableCollector.java:23)
	at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:129)
	at io.cucumber.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:148)
	at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:144)
	at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:28)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at io.cucumber.junit.FeatureRunner.run(FeatureRunner.java:137)
	at io.cucumber.junit.Cucumber.runChild(Cucumber.java:196)
	at io.cucumber.junit.Cucumber.runChild(Cucumber.java:89)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at io.cucumber.junit.Cucumber$RunBeforeAllHooks.evaluate(Cucumber.java:266)
	at io.cucumber.junit.Cucumber$RunAfterAllHooks.evaluate(Cucumber.java:281)
	at io.cucumber.junit.Cucumber$StartTestRun.evaluate(Cucumber.java:233)
	at io.cucumber.junit.Cucumber$FinishTestRun.evaluate(Cucumber.java:248)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:364)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:272)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:237)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:158)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:428)
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
	at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:562)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:548)
Caused by: java.lang.NoSuchMethodError: 'java.lang.String org.openqa.selenium.json.Json.toJson(java.lang.Object, int)'
	at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:126)
	at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:111)
	at org.openqa.selenium.remote.NewSessionPayload.create(NewSessionPayload.java:105)
	at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:101)
	at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:182)
	at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:250)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:518)
	... 58 more
  Given the asset app user is on asset app login page.                                # org.Mobile.stepDefinitions.LoginStepDefinitions.theAssetAppUserIsOnAssetAppLoginPage()
      java.lang.NullPointerException: Cannot invoke "io.appium.java_client.android.AndroidDriver.findElements(org.openqa.selenium.By)" because "this.driver" is null
	at org.Mobile.assetAppScreen.AndroidActionsPage.webElements_ById(AndroidActionsPage.java:105)
	at org.Mobile.assetAppScreen.LoginScreen.verifyTheUserIsOnTheLoginPage(LoginScreen.java:39)
	at org.Mobile.stepDefinitions.LoginStepDefinitions.theAssetAppUserIsOnAssetAppLoginPage(LoginStepDefinitions.java:26)
	at ✽.the asset app user is on asset app login page.(file:///home/runner/work/./src/test/resources/features/Login.feature:5)

  When the asset app user enter "" username.                                          # org.Mobile.stepDefinitions.LoginStepDefinitions.theAssetAppUserEnterUsername(java.lang.String)
  And the asset app user enter "" password.                                           # org.Mobile.stepDefinitions.LoginStepDefinitions.theAssetAppUserEnterPassword(java.lang.String)
  And the asset app user clicks on Continue button.                                   # org.Mobile.stepDefinitions.LoginStepDefinitions.theAssetAppUserClicksOnContinueButton()
  Then the asset app user unable to login "Please enter an email address." displayed. # org.Mobile.stepDefinitions.LoginStepDefinitions.theAssetAppUserUnableToLoginDisplayed(java.lang.String)
[   83.927455] init: processing action (persist.device_config.lmkd_native.thrashing_limit_critical=*) from (/system/etc/init/lmkd.rc:44)
[   83.931066] init: processing action (lmkd.reinit=1) from (/system/etc/init/lmkd.rc:10)
[   83.932961] init: starting service 'exec 23 (/system/bin/lmkd --reinit)'...
[   83.988500] init: Service 'exec 23 (/system/bin/lmkd --reinit)' (pid 4996) exited with status 0 oneshot service took 0.053000 seconds in background
[   83.991767] init: Sending signal 9 to service 'exec 23 (/system/bin/lmkd --reinit)' (pid 4996) process group...
[   83.995780] libprocessgroup: Successfully killed process cgroup uid 0 pid 4996 in 1ms
[   84.369125] init: Unable to set property 'persist.device_config.tethering.bpf_net_maps_enable_java_bpf_map' from uid:1000 gid:1000 pid:568: SELinux permission check failed
[   84.373512] type=1107 audit(1691492585.057:8): uid=0 auid=4294967295 ses=4294967295 subj=u:r:init:s0 msg='avc: denied { set } for property=persist.device_config.tethering.bpf_net_maps_enable_java_bpf_map pid=568 uid=1000 gid=1000 scontext=u:r:system_server:s0 tcontext=u:object_r:default_prop:s0 tclass=property_service permissive=0'

Java: 17.0.7
Node: 20.4
Appium: 2.0.1
UiAutomator2: 2.29.3
Android emulator version 32.1.14.0

I tried to run GitHub Actions on macOS and Linux runners and got the same error.

I would appreciate your help.

Any luck? facing same issue