• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Emulator won't show app

I'm trying to run a simple application I' been putting together. This is what I did. There's no error messages in the Eclipse/Android console.


  1. Created an android project
  2. Tinkered a bit with the xml file in layout/ to see if I could display it.
  3. Run as Android application.
The emulator I chose starts but the app won't run in it. I just get an error message, something like,
The application TestApp( process com.perlan.calculator has stopped unexpectedly Please try again!
 
Yes, it's typical beginner's problem. There is eroor in you code. Some errors call expection (ex : dividing by zero or try parse "er34" as number) and if you don't catch it, activity will close with so message. So risky code fragments you should write so:
try{
code
}
catch(Exception e){
note exception, ex call Toast or write to LogCat (e is cause of error)
}
 
I think I've narrowed it down to the main.xml-file.

When I try a xml-file that's 10kB the app won't run. Is there limitations on the main.xml file?
 
I've narrowed it down further... This chunk of code seems to mess it up. It's situated in a vertical linear layout.
Code:
    <LinearLayout android:orientation="horizontal"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:layout_weight="1">

        <TextView android:id="@+id/text1" android:layout_weight="1"
            android:layout_height="wrap_content" android:padding="8dp"
            android:textSize="14dp" android:text="Left" android:gravity="left">
        </TextView>
        <TextView android:id="@+id/text2" android:layout_weight="1"
            android:layout_height="wrap_content" android:padding="8dp"
            android:text="Right" android:gravity="right">
        </TextView>

    </LinearLayout>
The app don't really need it, but I like to know what I'm doing wrong here...
 
I believe the problem is that you need to set android:layout_width on your TextView elements and not just layout_height.
 
Back
Top Bottom