Appium fails to launch on Android emulator with multiple activities - java

I'm using
Appium v1.22.2
IntelliJ community
Gradle with dependencies
implementation 'io.appium:java-client:7.6.0'
testImplementation 'junit:junit:4.13.1'
implementation 'org.assertj:assertj-core:3.22.0'
Can you please help me to start an application via Appium on Android Emulator with multiple activities?
I couldn't get ahold of the concept of App_Wait_Activity and was trying to find the best suitable activity. While looking at Appium logs, it says that appium found the best match which is presentation.onboarding.OnboardActivity. When I choose this activity the application launches and quits, and there are errors. (See the error log below)
I also checked AndroidManifest.xml on Android Studio and there are multiple activities coming from top to bottom as:
android:name=".presentation.splash.StartActivity"
android:name=".presentation.onboarding.OnboardActivity"
android:name=".presentation.splash.SplashActivity"
android:name=".MainActivity"
android:name=".presentation.custom_view.widgets.WidgetsActivity"
The error log with chosen App_activity as .presentation.onboarding.OnboardActivity.
https://res.cloudinary.com/newslettergs/image/upload/v1657776487/Screen_Shot_2022-07-14_at_11.25.13_diutcy.png
org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'app_package_name' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Error executing adbExec. Original error: 'Command '/Users/baizhan/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am start -W -n app_package_name/app_package_name.presentation.onboarding.OnboardActivity -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000' exited with code 255'; Command output: Security exception: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=app_package_name/.presentation.onboarding.OnboardActivity } from null (pid=10838, uid=2000) not exported from uid 10151
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=app_package_name/.presentation.onboarding.OnboardActivity } from null (pid=10838, uid=2000) not exported from uid 10151
at com.android.server.wm.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1043)
at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:760)
at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:583)
at com.android.server.wm.ActivityStarter.startActivityMayWait(ActivityStarter.java:1288)
at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:514)
at com.android.server.wm.ActivityTaskManagerService.startActivityAndWait(ActivityTaskManagerService.java:1231)
at com.android.server.am.ActivityManagerService.startActivityAndWait(ActivityManagerService.java:3512)
at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:513)
at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:172)
at android.os.ShellCommand.exec(ShellCommand.java:104)
at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:9774)
at android.os.Binder.shellCommand(Binder.java:881)
at android.os.Binder.onTransact(Binder.java:765)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:4498)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2741)
at android.os.Binder.execTransactInternal(Binder.java:1021)
at android.os.Binder.execTransact(Binder.java:994)

I am not able to see automationName in your capabilities. You can follow this guide.
You can also follow this to setup your appActivity or appWaitActivity

Related

How to move the focus to another app in appium

I'm writing test automation for an app. The app launches the phone dialer with a specific phone number when clicking a button. I want to return the phone number to my code and return it to the app.
I'm using appium 1.21 and java.
I've tried to use this code:
androidDriver.activateApp("com.android.phone");
System.out.println(androidDriver.findElement(MobileBy.id("digis")).getText());
androidDriver.activateApp("com.app.test"); //return to the app from dial
but i'm getting an error :
Encountered internal error running command: Error: Cannot activate
'com.android.phone'. Original error: Error executing adbExec. Original
error: 'Command '/Users/idoa/Library/Android/sdk/platform-tools/adb -P
5037 -s ce051605bd453d2502 shell monkey -p com.android.phone -c
android.intent.category.LAUNCHER 1' exited with code 252'; Stderr:
'args: [-p, com.android.phone, -c, android.intent.category.LAUNCHER,
1]
How can I do it?
Key presses on appium are done by
driver.press_keycode(code)
All required codes can be found here
187 - KEYCODE_APP_SWITCH
Try this, not sure whether it solves

LibGDX won't install on one phone, but will another

This is the error message, so far no amount of googling has helped find a solution.
Error while executing: am start -n "com.simplearenagdx.game/com.simplearenagdx.game.AndroidLauncher" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.simplearenagdx.game/.AndroidLauncher }
Error type 3
Error: Activity class {com.simplearenagdx.game/com.simplearenagdx.game.AndroidLauncher} does not exist.
Error while Launching activity
What I don't understand is that yes, it does exist. I can go look at it. Its there.

Android Studio/Android Monitor emulator 5554-is disconnected/offline/No connected devices

When I click Android Studio, Open a project and then click Android Monitor the Monitor/logcat says that the emulator-5554 is offline/diconnected. SOmetimes there stands "No connected devices".
I uninstalled and intsalled Android Studio. I tried to wipe the data of the emulator. I deleted the emulator and installed it again. I trie in tools the SDK manager installing something but it failed. I tried in Settings of Android Studio switching off Instant run but nothing. I tried giving in the Terminal adb devices but it say that it can`t find them or any commands i give in it cant find. This is for a Course named Android and Developer course and i first noticed this when I tried activating the code and the emulator.
06/15 15:01:32: Launching app
$ adb push C:\Users\Dayan\Downloads\AnSt\02.05\DemoApp\app\build \outputs\apk\app-debug.apk /data/local/tmp/com.robpercival.demoapp
$ adb shell pm install -r "/data/local/tmp/com.robpercival.demoapp"
pkg: /data/local/tmp/com.robpercival.demoapp
Failure [INSTALL_FAILED_DEXOPT]
$ adb shell pm uninstall com.robpercival.demoapp
DELETE_FAILED_INTERNAL_ERROR
Error while Installing APK
Event Log
14:49:38 Gradle sync started
14:49:52 * daemon not running; starting now at tcp:5037
14:49:52 * daemon started successfully
14:50:44 Gradle sync completed
14:50:44 Executing tasks: [:app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources]
14:50:55 Gradle build finished in 10s 710ms
15:01:02 Executing tasks: [:app:assembleDebug]
15:01:30 Gradle build finished in 28s 681ms
15:02:24 Session 'app': Error Installing APK
C:\Users\Dayan\Downloads\AnSt\02.05\DemoApp>adb devices
Der Befehl "adb" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
I expected in logcat to see Username: .......... and Password:..........
But now i dont see anything only a ery long text in logcat which i cant understand

Original error: io.appium.uiautomator2.common.exceptions.UiAutomator2Exception

Getting unknown server-side error while running the script.
The script would terminate while scrolling else it would work fine.
Log error:
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: io.appium.uiautomator2.common.exceptions.UiAutomator2Exception: java.lang.IllegalStateException: UiAutomation not connected!
at io.appium.uiautomator2.utils.UiExpressionParser.invokeMethod(UiExpressionParser.java:251)
at io.appium.uiautomator2.utils.UiScrollableParser.consumeMethodCall(UiScrollableParser.java:124)
at io.appium.uiautomator2.utils.UiScrollableParser.parse(UiScrollableParser.java:60)
at io.appium.uiautomator2.utils.UiAutomatorParser.consumeStatement(UiAutomatorParser.java:93)
at io.appium.uiautomator2.utils.UiAutomatorParser.parse(UiAutomatorParser.java:49)
at io.appium.uiautomator2.utils.LocationHelpers.toSelectors(LocationHelpers.java:95)
at io.appium.uiautomator2.utils.LocationHelpers.toSelector(LocationHelpers.java:88)
at io.appium.uiautomator2.handler.FindElement.findElement(FindElement.java:144)
at io.appium.uiautomator2.handler.FindElement.safeHandle(FindElement.java:75)
at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:37)
at io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:250)
at io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:241)
at io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:44)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
* **Element info:
{Using=-android uiautomator, value=new UiScrollable(new UiSelector()).scrollIntoView(new UiSelector().text(" val "));}
Appium Log:
restarting adb before the test run with adb kill-server; adb start-server.
because sometimes the appium server having issue with adb so by restarting you can avoid this problem not every time when this error comes you can again start executing if not solved then please restart adb and then start executing script that will work..
Happy to help...
In case you have any doubts comment down below..

Not able to debug my app on android device

I'm not able to debug my app on my android device after I changed the package name (it was working before). I keep seeing the message below in Debug tab when I click the "Run" button.
This is the error message:
Error while executing: am start -n "com.anhnt/com.focuslab.flashlightnotif.activities.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.anhnt/com.focuslab.flashlightnotif.activities.MainActivity }
Error type 3
Error: Activity class {com.anhnt/com.focuslab.flashlightnotif.activities.MainActivity} does not exist.
Error while Launching activity
Make sure that in the Manifest you have updated the information. The manifest file is currently searching to launch MainActivity in com.anhnt/com.focuslab.flashlightnotif.activities and I believe you have refactored the path to reach it.
Change the package name also in the Manifest File and in the Gradle File

Categories

Resources