java.lang.RuntimeException: Unable to start activity - java

I have an unusual problem. I have a simple activity, which includes nine buttons with background images and background to the main layout.
I run my apps on my Nexus, one which is pretty fast, so I never had problem with the app. Until I updated to Android 2.3.3 (Gingerbread). My app won't run and force closes. Then I deleted the code below,
this.getWindow().setBackgroundDrawableResource(R.drawable.image);
And the app ran fine with no problems. It turned out that the image that I was using was too big, and Android 2.3.3 is somehow slower than Android 2.2. So I used image.png rather than image.jpg, which solved the problem for Nexus One phones. However, the slower phones won't run my app still cause its taking too long to create the activity. So the main Thread is timing out causing the app to crash.
What can I do it in this case?

I finally found the problem. The VM was running out of memory due to the large size of the image.
Each app has 16 MB of memory to play with. If you exceed 16 MB the app will crash. Nexus One has 28 MB of memory for each app.

Related

My Android Studio emulator is not working correctly

I downloaded the Pixel emulator and Android API 25, but when running it
appears for a few seconds and then disappears
In the Event Log, this is what appears
I need help pls
The same Problem got me a few months ago:
I fixed it by doing this:
Whenever you run the project or app you have to clear the data of that AVD
To wipe the data of Emulator follow these steps-
Go To AVD Manager then you will see all emulators there then simply wipe data. ie- like in this image shown.
step 1
step 2
step 3
I also had random emulator crashes, everything would work for a short while, but then the emulator would just disappear as if it had stopped. The emulator.exe would still be running task manager, no way to recover the window and the .lock file couldn't be removed.
Even just starting the emulator and swiping the home screen left and right (not even starting my app), or going into the the apps drawer and back would cause the the emulator to stop working properly.
What worked for me was to always start Android Studio as "Run as administrator". So right click on the startmenu shortcut and select Run as administrator.
Not sure why it randomly stops working otherwise, I'm sure the Android Studio QA team thoroughly tests this on real-world laptops outside of Google labs right...? /s

when I tried to test the game on my device crushed "Unfortunately App name has stopped

i have a problem launching my game on my phone or any virtual device, I've exported the game from Buildbox to an android source code and imported into eclipse without any problem and export it to android application also with no problem, when I tried to test the game on my device crushed "Unfortunately App name has stopped", I've run it on my virtual device and those are the logs that gave me.
Usually when a game crashes when testing the app on a mobile device you need to optimize your atlas.
Usually you are having problems with the images and animations that are too big and too heavy they make the game crash.
In order to optimize the atlas go to View > Atlases
You atlases should look like this one. So many images should exist in 1 atlas. You need to check all your atlases and if you have only 4 or 5 images per atlas you need to redo the sizes for those specific animations and reface them in the atlas.
After you do all that design work and replace them in Buildbox (you need to erase all the old images that you had) and then you go to the atlases and optimize and rebuild the atlases.
Allways keep a backup before doing all of this.
Then export and build another application and you should be good to go.
Option 2:
If it's still not working, check you scenes as they may be too long and may be using too much memory at once and that should be making the game crash.

My application crashes after showing the splash screen on a real device, but not on a virtual one

I have created an application with Android Studio, never change a single word in any file.
When trying to run it on real device I got the following error:
following is logcat. please help solving this problem!
Android Studio - on Real device application crashes after splash screen but not on Virtual device
LOg
According to your log lots of frames is skipping when application is running. So maybe you should profile your GPU and see where is the problem from.
Here are some links that maybe helpful :
Meaning of Choreographer
inspect GPU rendering speed and overdraw
and it will be helpful if you share your code.
This is a bug in ListView in android Api < 4.1 and you can't prevent it i think, just try to remove lines that use lookForSelectablePosition or you can increase minSdkVersion

android's hello world tutorial application is not working

I am new to java and android and wanted to see how developing for android works
I started by downloading the SDK FROM HERE
However after I finish making the Hello World project sample given in the website HERE, if I try to run it on the emulator as explained HERE, the emulator screen appears, but nothing seems to happen. I can see the word android on the middle of the screen with some animation happening, but that's it. The website says something about unlocking the emulator, but I have no idea what that means. What I have gathered from reading other posts is that the emulator is supposed to have some kind of slider switch as in real smart phones which should be dragged to unlock it, but I can't see it in my case. Now I have no idea why this is happening or what I should check out in order to fix this. Are there any installation logs or something else that I can check to see what the settings are?
What I have tried till now:
I downloaded the SDK ADT bundle from HERE and just unzipped it. Then looked for eclipse.exe and ran it directly. Is there anything else I should have done prior to this?
When I did it for the first time, I had only JRE installed and not JDK, which I realized after reading THIS POST. So I downloaded JDK from HERE, updated the required environment variables and restarted eclipse, but still it's the same thing.
I looked at the Eclipse isn't talking to the emulator section GIVEN HERE, but all it says is to restart eclipse and the emulator, and it doesn't do anything at all.
Rant:
I can understand if the program had failed to compile when I didn't have JDK , or if the IDE gave any indication at all of a faulty program install, but that isn't the case. Everything seems ok, there are no errors, but it just doesn't do anything. This is the type of thing that makes people pull their hair out, and personally, I think the With a single download, the ADT Bundle includes everything you need to begin developing apps: in the android website is very misleading, especially for complete beginners
Anyway, what should I do to make the tutorial program run on my computer? My computer is a bit old and slow so could that be an issue? My computer is Windows XP SP3 on Intel(R) Pentium(4) 4 CPU 3.20 GHz 3.19GHz 2.50GB RAM, but if that was the case I assume the emulator shouldn't even start up
You just have to wait a bit longer. Android loads pretty long on emulator.
Tutorial says about unlocking, because when Android is loaded, your screen on emulator will be locked.
If you find emulator too slow for you, you may want to check this topic out: Why is the Android emulator so slow? How can we speed up the Android emulator?
I had the exact same problem as you when I first got into Android development a week ago. The two things I did are simply
1) Set the usable RAM on your AVD to 768MB
2) When you run your Hello World program in your emulator, give it about 5-10 minutes. Don't touch or click the window at all, just let it load up. Later you can make it persist
3) If your home screen comes up, click and hold the mouse button in the center of the screen, then drag towards the sides and release, this should unlock the device.
Try these steps first, if they don't work then there is likely a problem with your AVD configuration.
If you are launching your app first time with emulator, it will take appropriate time.After that, on Lock icon click and slide to the right. then you can view you application. If not check for your app(icon) installed.
By seeing your configuration of PC I think it will take some time to load emulator. After emulator is load (see below image)
then and then run your code and also check in eclise-device that whether emulator is online or not.
For checking emulator in eclispe :
In second image just above windows logo you can see small rectangular button with plus sign click on that you will get list from which you can select devices. You can find similar button in you eclipse at the bottom.
I had the exact same problem and followed the exact same steps, but was also unsuccessful. I ended up creating a new AVD with a Nexus 4 instead of the latest Nexus 6. The resolution of the 4 is much lower, which I think is what solved my problem. It loaded much more quickly using the 4.
Also, When I was using the 6, I could only see "ndroi" because the size of the screen was much larger than the size of the phone. Now I can see the full device.
vs.
You may just need to relaunch the Android studio 3.6.3.
I got a similar problem. The hello world app does not install on the emulator.
Problem solved after relaunch.

Eclipse was working fine this morning... Now it and the AVD crash every few minutes?

I was using Eclipse this morning and it was working fine, both it and the AVD would load in less than a minute... After a few hours it started crashing.
Now if I'm lucky enough for Eclipse to load without crashing the AVD takes at least half an hour to go from the basic "ANDROID" text to the actual logo.
I've tried cleaning my project, recreating the AVD, increasing the AVD's memory from 256mB to 1024, disabling animations and loading from snapshots...
Other than using Eclipse the only thing I have done with my computer is searching on stackoverflow.
What could have caused such a change in performance over a few hours?
Maybe you started a background application or something. Restart your machine. Your memory is probably being barraged somewhere. Check that the processor isn't on battery save mode or anything.
Also, perhaps this post might help.

Categories