Not able to debug my app on android device - java

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

Related

Appium fails to launch on Android emulator with multiple activities

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

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.

Runtime.getRuntime().exec not launching desired app on Android

I'm trying to open the settings app from inside my sample app.
Code snippet inside onCreate:
Process process;
try {
process = Runtime.getRuntime().exec("am start -a android.intent.action.MAIN -n com.android.settings/.Settings");
process.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String s = reader.readLine();
Toast.makeText(this, s, Toast.LENGTH_LONG).show();
}
catch(Exception e) {
e.printStackTrace();
}
When I run this, my app opens, but settings app does not start (neither does any other app I try). The toast inserted for debugging displays "Starting: Intent { act=android.intent.action.MAIN cmp=com.android.settings/.Settings } but it doesn't actually start. Nothing useful visible in logcat either (unless I've missed something in it).
Same command is working using adb (adb shell am start -a android.intent.action.MAIN -n com.android.settings/.Settings)
I'm using Android Studio and an Android 4.4 device if that matters. I've been searching online to figure out what I might be doing wrong, but things seem correct in the above code. Could someone please help?
Update:
Apologies for not giving further details, but Settings is not the app that I finally plan to launch in the actual version of this app, Settings was just a test. It is another app which doesn't have android:exported="true" and takes parameters. To be precise, it opens files of a certain extension which it takes as parameters like "adb shell am start -W -a android.intent.action.VIEW -d ..."
The right way to run another application in Android would be According to this answer
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.android.settings");
startActivity(launchIntent);
Why don't you open Settings by Intent? Something like this:
startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);

app can't install after update eclipse?

I've build android application using eclipse, everything work well when i change my code and run on emulator before i update my eclipse,after my eclipse update, i change my code, my app didn't install new code but still running previous code and show log like this.
[2013-11-25 10:27:07 - ChatKrawala] Application already deployed. No need to reinstall.
[2013-11-25 10:27:07 - ChatKrawala] Starting activity com.ltvie.chatkrawala.ChatkraActivity on device S5830ae0c94c8
[2013-11-25 10:27:07 - ChatKrawala] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.ltvie.chatkrawala/.ChatkraActivity }
why my eclipse cant install new app when i change my code after i update my eclipse and ADT?

Categories

Resources