Android device doesn't launch activities on the screen while espresso testing - android

As long as I saw in a YouTube video that an android device tends to launch and show activities that are launched in my test, I think there is a problem here, since mine doesn't react at all (the screen is always on though, animations are turned off).
When I was trying to test the activity which runs first in the app (logically), I tried to open the app by myself while testing and somehow it worked. Now I'm testing another one and this trick doesn't work anymore.
Anyways I always get the error:
java.lang.AssertionError: Activity never becomes requested state "[RESUMED, STARTED, CREATED, DESTROYED]"
My test code uncludes:
val scenario = ActivityScenario.launch(HomeActivity::class.java)
And then I just check the presence of a layout element (textview or anything)
Any ideas why it may occur?
Thanks in advance
UPD: android emulator works fine.

this also happening to my test when following codelab from google kotlin unit test
when im trying to run the test via emulator, it run perfectly, but when i run into my device, which is xiaomi redmi note 5, the error showed up like yours,
i found an answer in this question and it directed to this github
i try to enable app permission "Display pop-up windows while running in the background", and when i run the test again, it passes

Related

Android studio: Error: Activity not started, unknown error code 5

Currently developing an Android app for my company.
Everything was fine, till my last debugging session on my test-device (tablet attached to android via adb).
When I try to run or debug my app, the "Run App" log simply shows:
Error: Activity not started, unknown error code 5
There is no further information, no stack trace, no nothing...
I tried to figure out, what I changed since the last time, but nothing seems to fix this.
Has anybody else had this error code 5 before and can help me?
Long story short: Unknown error 5 means (at least in my case), there is a lock (meaning a pinned app) on the device, so no other app can be started.
After a bunch of things I tried, I finally figured this out.
My app uses startLockTask() to pin it (so you can't accidentally press one of the navigation buttons).
The problem was, that this lock seemed to be active, even though the app wasn't running. I only realized that, after I tried to push the home button on my tablet (it already showed the android home screen, so it didn't occur to me, to try that...).
Once I released the lock (pressing both Back and Overview at the same time), I could start the debugging again, with no problem.
Restarting the device fixed the problem

IONIC - Why ionic application did not run correctly on device?

I have tested my application using ionic-serve and everything run normally.
But, when i tried it using device, the application will first run the splash screen (which is not run when using ionic serve) and nothing happen, only white screen.
Can somebody please help me with this situation?
I have no idea about what happen.
The white screen issue often occurs on devices and not in the browser when you are injecting something into a module that kicks off your app. Try to figure out which one, and remove it (if it's not being used) or update it.
First thing to do is to check for errors in the log. To see them, type the address chrome://inspect/#devices in chrome, and click on your app. You'll need to make sure your device has usb debugging turned on.

How do you debug an Android app that crashes the device?

I'm currently having an issue with certain Samsung devices where starting an activity with an intro animation sometimes causes the whole device to crash.
The app essentially transitions from an Activity with a VideoView to another activity with a VideoView. The video of the activity that just started stutters in a loop for about 10 seconds before the whole device crashes and restarts.
It's not crashing the device all the time, but is limited to a couple Samsung devices from what I've tested.
I've looked at crash logs of the device which currently seem to be inconclusive from what I can see.
Important but relevant note, I am finishing the activity once starting the next.
You could try to attach the debugger manually through Android Studio if your process is alive long enough after the boot sequence.
Source:
https://developer.android.com/studio/debug/index.html
One more thing you could try is to put the 'wait for debugger' instruction in your code, using the Debug.waitForDebugger() method.
Source: https://developer.android.com/reference/android/os/Debug.html#waitForDebugger()
Other than that, you could put a lot of logs in your code, then fetch them using adb logcat > crash-log.txt command from your CMD/Terminal.

Is android:excludeFromRecents broken for the first app that is launched on the device on Android L?

Is seems like the current way to exclude apps from the recent apps-lists in android L is broken. Our app is using android:excludeFromRecents and it works just fine. Unless our app is the FIRST app to start when the device reboots.
This is how it looks when our app is exited as the first app on the device:
And here is how it looks if we first start the camera (or any other app), then our app and exit both:
Simply put: If an app with android:excludeFromRecents is started as the first app on the device, the directive android:excludeFromRecents isn't working. If another app has been started before the android:excludeFromRecents-app, it works as expected.
Is this a really weird edge-case bug or am i'm missing something very obvious here?
We build a very privacy cautious web browser (http://inbrowserapp.com), so we cannot have any screenshots from the app showing once the app is closed. But this should also affect banking-apps, password-managers etc since sensitive information will be screenshotted if the app is the first to start after a reboot.
Maybe we can go about the route and hide the sensitive information with a blank view when the user is exiting on Android L. But its seems like something is buggy here?
I'm happy to say that this is fixed for Android 5.1. Just confirmed it on a device running 5.1.
So the correct solution, for us anyways, is to deny screenshots with getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); for Lollipop with SDK version 21, anything below or above that should be fine.
You can at least prevent the screenshot in recents by setting this flag:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
But it's still a bug that never should have made it to release..

Force Close always occuring on android device (even with very simple hello world code)

My university recently got monodroid working in the labs and I've spent the day trying to get to grips with it.
However, upon building the basic tutorial scripts to an actual phone (desire hd and incredible s) they will instantly bring up a force close message.
[EDIT] Ok here goes. This is (in my view), an extremely simple procedure based on the initial monoDevelopProject.
I've left out using the namespace sections for clarity, these are all left default.
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.MyButton);
// on button click change button text
button.Click += delegate { button.Text = string.Format("You clicked the button!") };
}
So, this compiles, builds and runs with no errors on a standard sdk 2.3 emu. But not on an actual device.
I am unable to retrieve any debugging information from the device (I've followed the instructions to allow wifi debugging). With a break point included at line 3 above (base.onCreate(bundle);) it appears to not even step into this method and simply stops the debug after the force close.
I will try and debug this again from the device and get some more details now. I may have gotten something wrong.
I have just tried a few example projects from the xamarin gitHub, ranging from simple layouts to full 3d oGL examples and all return a force close messages upon running on my device. I will look into some of the compiler settings and do a reboot of this system
When I run the debug (green arrow), it doesn't even enable the pause/stop buttons (like it should and does on the emu). Genuinely no idea what's wrong, it's as if the app is being killed as soon as its sent to the device. I have a feeling it's not been installed correctly on these systems as I've tried two computers in the lab now.
Try running it without debugging (Ctrl-F5), let it crash, and then check the debug log for the exception causing the crash:
http://docs.xamarin.com/android/advanced_topics/android_debug_log
In addition to jpobst's answer I'd recommend you get a log viewer for your device and watch it while your app is running. I have no affiliation with these guys but I have found myself using their app again and again. https://market.android.com/details?id=com.nolanlawson.logcat&hl=en
OP says that they have solved the problem:
MonoDroid was not installed correctly in the labs, even though all information pointing to registration/authentication stated otherwise.

Categories

Resources