My app freezes for some time while the first opening of the app. From there on app fires up with no time. Why is this happening and any ways to fix this? I have tried adding a Simple Activity with one small image, even then it freezes for the first time.
There is a strange issue with newly released Android Studio 2.0 or 2.1. First time of launching application take longer than usual. This issue happens only in debug mode and not effect to your released APK. Also I was suffering this issue and found this solution.
Settings/Preferences→ Build, Execution, Deployment → Instant Run and uncheck Instant Run
Related
I encounter a problem where my Xamarin Forms Android app won't start (blank screen) after I change the Android OS date to an earlier date. I only happens when it's not connected through the debugger.
I'm using the latest version of Visual Studio and Xamarin. At the time of this post, I tested with:
Visual Studio 2019 - 16.6.2 (Also happens in 16.5.3)
Xamarin Forms 4.7.0.968 (Also happens in previous 4.X versions)
Phone: Samsung Galaxy S8, Android 9.
Steps to reproduce:
Create the sample Xamarin Forms app using the "Blank Page" template.
Run it through the debugger first (The app works and displays the welcome message).
Close the app.
Set the OS date/time to manual and go back one day.
From the phone itself (without using the debugger), run the app.
After the last step, the app won't start but will instead display a blank screen. No crash. Resetting the time to automatic date when the app is closed, the app will run correctly again. If I do the same procedure but always start the app using the debugger, everything works fine.
Does anybody knows how to resolve this issue?
Edit: Since it doesn't happen while the debugger is attached, I added logs so I can use logcat to know where it reaches. When it hangs, it doesn't even seem to reach the "Oncreate" of my MainActivity class.
I tried your steps and reproduced the issue , it shows white screen on my side and it seems be stuck .
The problem only occurs when i set time to earlier date , it works fine if i set it later date.
I have raised the issue on github : https://github.com/xamarin/Xamarin.Forms/issues/11128 , you could monitor the progress.
This happens every time I run a test as long as I remember (Android Studio 2+, 3.0, 3.1, 3.2)
.
Sometimes the stop button even shows multiple processes. Also it doesn't matter how many times I click the stop button, it will never work (it does stop the test but the button remains in active state).
It seems to be a bug in Android Studio. I have found that it was reported previously on Google Issue Tracker with ID 64031765 and is not fixed yet.
For some reason my answer was deleted by a moderator without any explanation. It is a bug and there is nothing more to add.
Instant Run is a necromancer. It is supposed to apply changes instantly for debugging, distinct from recompiling the entire project from scratch which is a time consuming process for a fairly iterative development process.
Sometimes, it actually accomplishes instant changes as expected. In a few seconds after I am satisfied with my code changes, my application updates with the latest code running.
But then, it goes beyond that.
Sometimes, it says it gave my application the latest code which will be instantly applied to the part of the application I was viewing and debugging, but the application closes and restarts.
Sometimes, the application closes and restarts and shows up with no code changes. I can't trust the outcome, is my code wrong or is something else awry.
Sometimes, the application closes and restarts and shows up with old code. A build that should no longer exist. Resurrected from a cache graveyard that I didn't know existed. How is this possible?
Sometimes, the application closes and restarts and informs me that it is running an old version and that the only remedy is to use Instant Run.
??????????
How and under what circumstances does InstantRun do the above things, especially the part where it resurrects the old build?
While working today, it seemed as if suddenly I could no longer debug our application. The funny thing is, if I ran the app normally it would work just fine. To clarify, I was running the debugger all morning without incident (apart from the occasional glitch or crash). Then after lunch it began failing 100% of the time. Of course, I've been making changes all day, hence the "it seems" above. So, here are some relevant details:
Android Studio 2.1.1 (April 28, 2016 build)
This app starts up with a log in screen. The user must then authenticate with a username/password which calls out to an external service.
I can get to the login screen, but the app would always crash at the same point in the middle of the authentication.
Here is the stack trace:
05-24 14:56:25.764 2399-2745/com.mycomp.myapp.test E/Crashlytics: Failed to execute task.
java.lang.InterruptedException
at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:375)
at java.util.concurrent.FutureTask.get(FutureTask.java:162)
at com.crashlytics.android.v.a(SourceFile:1936)
at com.crashlytics.android.v.uncaughtException(SourceFile:307)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
05-24 14:56:25.764 2399-2745/com.mycomp.myapp.test E/AndroidRuntime: FATAL EXCEPTION: pool-5-thread-1
Process: com.mycomp.myapp.test, PID: 2399
java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:1991)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2025)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:820)
Here are the things I've tried to fix it:
Back out all my changes (git stash)
Uninstall application from phone
Do a clean build
Do a Gradle Project Resync
Remove all breakpoints (seriously?)
Ok, I've been adding breakpoints all over to see how things work, so who knows? There's some merit there.
Restart Android Studio! (turn it off and on again)
And so far, nothing works. However, I can't emphasize enough that if I just run the app (play button, ^R) and run it on the very same device, it works just fine! Log in with no problem. So, it doesn't seem to be a code problem.
Furthermore, if you look at the stack trace, there is nothing pointing to our project.
Any ideas?
Well, I figured it out. It turns out I had a "Java Field Watchpoint" selected with "Suspend Thread" as one of the options. See the attached screenshot for clarification. Takeaways:
As you can see, I had been using a bunch of breakpoints, so it got buried in the window and I didn't see it.
I still don't know how it got set. I had been using watches on a previous day, but I had deleted them all. Furthermore, I'm quite certain I didn't turn it on, so how it mysteriously stopped working in the middle of the day is still a mystery. Also, I certainly wouldn't have checked "suspend thread" on my own. Some sort of default setting?
Point remains - if you are seeing weird stack traces, it might be good to check all the breakpoints and watch point settings.
I hope this helps someone.
Instant Run appears to be the culprit (at least in my case with Android Studio 2.3.3). Instead of disabling breakpoints, try disabling Instant Run. Once I did this, breakpoints ceased to cause crashes.
See Android app crashes when launched in debug mode for details. Under Mac OS X, I disabled Instant Run by going to Android Studio->Preferences->Build, Execution, Deployment->InstantRun and unchecking "Enable Instant Run to hot swap ...".
There is a "Having trouble with Instant Run?" message displayed in the settings panel. I clicked on "Re-enable and activate extra logging", reproduced the crash, and then immediately reported using the "Help - Report Instant Run Issue..." option as they requested.
Turn off instant run, It'll fix all the issues
I changed emulators (from Android 8.1 to Android 7.0) and did not experience this again. I wasted 3 hours on this. I hope I help someone by suggesting this.
I keep getting the message 'Activity not started, its current task has been brought to the front' despite making changes to the code. I wasn't aware of changing any settings in Eclipse besides creating a new AVD and it was working fine earlier today. Now it's not reinstalling at all.
I'm not sure why the problem started when it did but I installed some updates from Eclipse and Android and it seems to be working fine now.
There are several thing that you can do to solve this problem:
You can close your AVD and then start it again.
You can manually uninstall your application using AVD interface (Home - Menu button - Manage apps - All tab - Your app - Force stop/Uninstall).
The solution was to start the task manager and end multiple AVD emulator processes that had somehow built up.
i also constantly have this problem, even when i change the code. what helps for me is simply to start my application in the debug mode; then it starts without that warning. later when i start the application in the non-debugging mode again it normally starts without that warning (at least for a while).