flutter app stuck on white blank screen and then losses device connection - android

I am unable to launch a flutter, both on mobile and on android emulator. I've checked all other questions similar to mine, but the answers provided could not help solve this issue. Who else has encountered something like this and what fix worked for you? The file is pretty large, over 5k lines of code, I could have just paste it here.

One of the possible cause of this occurrence is the presence of an infinite loop anywhere in your code. Once flutter encounters any infinite loop while preparing your app state, it gets stuck on executing this and the device/emulator connection timeout, hence connection lost. Place a print statement in all loops in code concerned with the homepage of your app, it's one of the stress free way to detect the culprit loop.

Related

Choreographer(697): Skipped 152 frames! Debug log [duplicate]

This question already has answers here:
Meaning of Choreographer messages in Logcat [duplicate]
(5 answers)
Closed 8 years ago.
I am building a new game with andengine and for some reason i keep getting this debug statement in the logcat:
01-31 21:29:50.503: I/Choreographer(697): Skipped 152 frames! The application may be doing too much work on its main thread.
Im not really sure what is causing this error exactly during my game. I am checking a lot of collisions, but they arent initiated until after the game play scene has started.
I also noticed on my galaxy S3 the game causes my phone to "flicker" when swiping changing home screens and pulling down the task bar at the top.
I think this error has something to do with it, but i am not sure. What do you guys think?
Also each time the user goes to another level i initialized the collision detectors all over again. But i dont unregister or stop the last collisions that were started. I thought they would be automatically cleaned up when the new one is initialized.
What do you guys think?
It sounds like you're aware of what the message is telling you, i.e., your frame rate is lagging. Your follow up question, "why?" is going to be impossible to answer without more information. You've provided some possibilities: is it the collision handling? Is it processing of unnecessary collisions? Is it some problem in the scene transitions? The answer is, maybe. Maybe it's any of those things. Maybe it's something else. At the moment all we can do is guess, because we're not looking at the code.
But the good news is, you're not without recourse! What you need to do is test your code and find where the bottlenecks are. A good place to start is to throw in some calls to clock the milliseconds between blocks of your code that you suspect are the problem. You may discover that things you'd assume we're slow are actually happening pretty quickly, and conversely, things you thought were fast are happening slowly. Focus on the latter! Put more calls in there to see where exactly things are taking longer. And look at your code to see why it might be running slowly there. Are a lot of objects being instantiated there? Is it reading from disk? Etc.
When you're ready for them, there are some great third party tools to get deeper into the testing, but it's worth spending some time to clock and review your own code first. You have the advantage as the author of suspecting where the problems may be. Start investigating!
Side note, I'd provide some links to third party tools, but I'm writing this from a jacuzzi. I'll update later.

Logcat issues (pausing, buffer, output redirection)

I've searched around for everything that seems to be capable of affecting logcat, but I just can't find an answer to this problem. I'm debugging a large application that dumps several hundred logcat messages to screen per second. In Eclipse, I'm using a regular expression to filter by log tag, but this is where things get weird. The "pause" button keeps on activating for no apparent reason, and given the massive volume of new messages, before I can get the logs for the specific sequence of events I'm investigating, they'll be overwritten, a little at a time. I've even set breakpoints and tried to capture the logs bit by bit with the "export" button, but the app is multithreaded and they still disappear too quickly because of messages from other threads. It would be nice to increase the buffer somehow, or make old messages stick around, though at this point I'm willing to dispense with it altogether and just output it to a file, but I'm not sure how to filter by log tag using my regular expression from the command line. What are my options?
P.S. I have been looking around and I hope this isn't redundant--I haven't found anything specifically addressing my problem, though I have of course run across abundant related threads that don't quite help. Thanks so much!
I had similar problem to this. I was working on application which communicate to web server and download a huge amount of data. I had logs almost for every variable and I had to test them to see if the result which I'm receiving from JSON is correct. So the thing that I did was to log all logs on a file on my sd card and I did something like this :
public void log2File(String filename, String log, int type){
switch(type){
case 1: // debug
case 2: //verbose
case 3: //warning
//..and etc
}
}
I didn't find anything better for my solution, so that's the way which I did it.And of course you have to add your logs on a file and save it.
Hope this solutions seems good for you.
I've found the eclipse logcat window to be fairly buggy with high logging volume - it won't even stay disabled if you try to turn it off.
To actually capture the desired data, I tend to use the adb logcat command from the commandline. On linux, or presumably cygwin or osx you should be able to do:
adb logcat | tee logfile
And both see the messages flying by and have them recorded to a file.
I know this question is old but I had the exact same problem as you. I looked everywhere for a good solution but did not find one that worked for me so I took to creating my own tool. If you are on a Mac you could use LogRabbit to do what you want to do. It could help solve your problem in two different ways.
You could use adb logcat -v threadtime on the command line and write the logs to disk and import that into LogRabbit.
The filtering mechanism should be plenty fast enough to handle the log volume you are talking about.
Have a look at http://lograbbit.com I hope this helps.

Data seems to stay saved even after closing and re-opening Android app. I don't want it to

I keep adding data to a List as my app runs. When I close it and run the app again, the old list is somehow still there and the new data is added to the end of it. I don't want this to happen and I don't know why it's happening... I think I'm initializing it properly and closing things with onPause() and onDestroy().
I'm not quite sure what's going on or where, and maybe the problem is from elsewhere in the code... All I know is that the app is not working right (on the first run it doesn't work like its supposed to, but when I close it and run it again it works just fine). And this was the only fishy, seemingly related problem (?) I could find in several hours. I don't even know what part of my code to post so I'm not looking for any specific answers, but any insights, ideas, or tips would be greatly appreciated.
EDIT: Okay, I fixed the specific issue with the List, by initializing it in OnResume(), as suggested. However, the problem remains that on the first run, things are derpy, but closing and reopening it fixes everything. It seems like there's still something going on that transfers over...
Read these...
Application Fundamentals
Activity
In particular learn that the concept of an app is not the same as any individual application component such as an Activity. Also understanding the Activity life-cycle (creation, starting, resuming, pausing, stopping, destruction) is paramount to understanding where and when to perform various actions.
Sorry - a bit of a generic answer but as you haven't provided any code it's not possible to give anything definitive.
One thing I will say though is both of those links above when combined would probably solve 50% of all the common Android questions I see here on SO.

Android Database Locking Behaviour

I still haven't really wrapped my head around synchronization. I know it's there, I know why it's used and what the idea is behind it, but Im lacking the practical skill and real world examples to understand exactly how it works and how it's implemented when several activies are trying to read/write to the database at the same time. Do you share your objects through Application, or is the system intelligent enough to synchronize various objects of the same type?
Perhaps a Content Provider is a better way to go as I understand that has built in sync.
I digress though.
Im still confused over database activity. Remember that I have a service running every 60 seconds in the background reading the same table an update function is writing to. Yes Im looking to change this, but right now I want to understand database handling in Android more and work out what's happening.
If I have a loop such as:
db = provider.getReadableDatabase();
while(theres_still_work_today) {
do_some_calculations;
update_database;
}
provider.close();
this works fine as a standalone. If I try and place this in a thread, I get errors galore about locking. But when run like this:
while(theres_still_work_today) {
do_some_calculations;
db = provider.getReadableDatabase();
provider.close();
update_database;
}
I find that bizarrely, this actually seems faster, and gives no locking issues.
Am I just being incredibly lucky that I don't get two events triggering at the same time causing a lock? Is there some kind of timeout built into database handling in Android/SQLite?
I don't understand why the last bit of code should work OK, and why it should work faster?
Im not entirely confident about the Android Emulator though. If I use the first option with a single open/close outside the loop, sometimes I can get through a long long loop fine even though the service triggers in the background.
Other times it crashes on a whim.
I also don't know why "isDatabaseLockedByOtherThreads()" does not report that it is locked by other threads.
Any advice?
Thanks
Simon

Adwhirl Layout issue

I am currently using admob for a couple of my apps. This seems to work well, except the fill rates can get down to as low as 78%. So I decided to signup for AdWhirl.
So, I followed the instructions, what they are, on the setup instructions page for AdWhirl, but can not get anything to work. I either wind up with code that throws no errors and does not work, or if I add <AdWhirlLayout> to my xml the app will not run at all.
Can someone please explain to me what I need to do to get this working?
It appears there are some steps that are assumed and not explained.
I found this very helpful in getting AdWhirl up and running. The emulator is still very fickle in displaying the adds... watch the LogCat to try and decipher what is happening with AdWhirl, but first go to this link and follow instructions.
https://stackoverflow.com/questions/4898838/howto-implement-adwhirl-in-an-android-project
Oh, and it takes some time before the ads actually display (for me I had to wait overnight after implementing) for my key to work and serve up ads.

Categories

Resources