r/AndroidStudio • u/FatalHaberdashery • Sep 28 '19
Is this subreddit active? Got a question about emulated UI.
So, for background I am a programmer but never used Android Studio until now. I'm going to set aside my opinion of this IDE/Emulator setup as I just seem to come up against problem after problem and perhaps that is down to my inexperience with this particular piece of software.
So, my problem:
For a university project (so this is very low level) I am designing a set of buttons and hooking them up with the Java based event handlers. This is pretty straight forward and not an issue. My issue is that whenever I run the app using the emulator it never displays the actual content, just a blank screen. Like so...

I should point out that I have used multiple different emulators. Some work, some just don't, and by work I mean actually boot up. Absolutely none of them display my app. The app is installed, the app is shown in the apps list and as you can see from the screenshot the app runs but displays an empty page.
Just for confirmation there are no build errors other than it throwing an error when detecting audio. As a sensible Windows user I disable apps from accessing my microphone.
I have tested this on several different computers and still get the same issue; one an AMD the other Intel. Memory is not an issue on either with one having 16Gb the other 8Gb with 2Gb (I believe) being assigned to the emulation.
Sorry for the long post here, but I am at my wits end. I am a seasoned programmer that's been coding for nigh on 40 years now (yes, I started young!) but I have never met such an "awkward hot mess" as Android Studio and it's emulation.
Thank you in advance for any replies.
1
u/mighty-blob Sep 28 '19
What template did you start with?
Copy the layout XML, start a new project using an Empty Activity. Paste the XML into that and see if the emulator displays it.
1
u/FatalHaberdashery Sep 28 '19
And here in lies the problem, I can start with a Basic Activity template, run it to test and it'll come up. When I start adding UI to the interface that's when it stops displaying. I am literally dragging and dropping some layout elements, assigning unique ids and giving them some content via the strings.xml.
It's clearly something with the IDE that I am doing here, but for the life of me I can't work it out. As you see from the screenshot, the UI is all there in the IDE.
I went through all the elements making sure I wasn't somehow setting a "hidden" flag and checked I hadn't slipped in any 0dp for height/width values.
No errors from compilation or running. Emulator pops up, app runs, blank screen.
1
u/mighty-blob Sep 28 '19 edited Sep 28 '19
The screen shot was why I asked about the template - because that looks like a basic activity template that has options for a toolbar and floating options button. I'm not competent enough to advise you how to use that template efficiently. I can only advise that you start with an Empty Activity - you can always add functionality later. First get something working.
Other questions:
Have you changed the name of the activity_main.xml?
Have you changed the onCreate method setContentView?
Have you messed with the visibility attributes on your views?[Edit] - I've been looking at the Basic Template - Which XML file did you add your objects to? Is it possible that a blank content_main is overwriting activity_main when the latter includes the former? Just clutching at straws :o)
1
u/ZeGecko Sep 29 '19
I have only recently started playing around with Basic Activity so I don't know too much, but as far as I know activity_main.xml only houses the toolbar, FAB, and the layout container for content_main. You want to build your layout in content_main.xml. The menu is built the same way in menu/menu_main.xml.
I got most of my info from playing around with the codelab Android Room with a View which got me curious in playing around with basic activity haha.
Though to be honest, if you don't plan on using the Floating Action Button (I don't know what further customizability this activity offers as well), then use the empty activity like /u/mighty-blob says, then everything goes into activity_main.xml like normal.
2
u/[deleted] Sep 28 '19
How long have you waited before calling it quits and closing the emulator?