My App always dies immediately. Can't debug either.

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

My App always dies immediately. Can't debug either.

Postby GasBot » Fri Oct 17, 2008 7:42 am

I'm working on my first app. I can get a plain old Hello Android to run on the emulator, but whenever I try adding an ImageView it seems to crash it (I just added a plain image view to the HelloAndroid app referencing the @drawable/icon graphic and it still crashed it).

Am I missing an import somewhere? I'm sure I'm just making a stupid newb mistake. Thanks for the help.
GasBot
Experienced Developer
Experienced Developer
 
Posts: 50
Joined: Fri Oct 17, 2008 7:19 am

Top

Postby MrSnowflake » Fri Oct 17, 2008 11:41 am

Take a look at the logcat!
From cmd.exe:
Code: Select all
adb logcat
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby GasBot » Fri Oct 17, 2008 4:50 pm

This is the stack trace I'm seeing out of there.

W/dalvikvm( 747): threadid=3: thread exiting with uncaught exception (group=0x4
0010e28)
E/AndroidRuntime( 747): Uncaught handler: thread main exiting due to uncaught e
xception
E/AndroidRuntime( 747): java.lang.RuntimeException: Unable to instantiate appli
cation net.gasbot.GasBot: java.lang.ClassCastException: net.gasbot.GasBot
E/AndroidRuntime( 747): at android.app.ActivityThread$PackageInfo.makeAp
plication(ActivityThread.java:456)
E/AndroidRuntime( 747): at android.app.ActivityThread.handleBindApplicat
ion(ActivityThread.java:3407)
E/AndroidRuntime( 747): at android.app.ActivityThread.access$2500(Activi
tyThread.java:112)
E/AndroidRuntime( 747): at android.app.ActivityThread$H.handleMessage(Ac
tivityThread.java:1616)
E/AndroidRuntime( 747): at android.os.Handler.dispatchMessage(Handler.ja
va:88)
E/AndroidRuntime( 747): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 747): at android.app.ActivityThread.main(ActivityThrea
d.java:3742)
E/AndroidRuntime( 747): at java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 747): at java.lang.reflect.Method.invoke(Method.java:5
15)
E/AndroidRuntime( 747): at com.android.internal.os.ZygoteInit$MethodAndA
rgsCaller.run(ZygoteInit.java:739)
E/AndroidRuntime( 747): at com.android.internal.os.ZygoteInit.main(Zygot
eInit.java:497)
E/AndroidRuntime( 747): at dalvik.system.NativeStart.main(Native Method)

E/AndroidRuntime( 747): Caused by: java.lang.ClassCastException: net.gasbot.Gas
Bot
E/AndroidRuntime( 747): at android.app.Instrumentation.newApplication(In
strumentation.java:1032)
E/AndroidRuntime( 747): at android.app.Instrumentation.newApplication(In
strumentation.java:1017)
E/AndroidRuntime( 747): at android.app.ActivityThread$PackageInfo.makeAp
plication(ActivityThread.java:451)

Why would it not be able to instantiate the app? So far I have one layout file with a TableLayout, 3 table rows. The first with an ImageView and the second 2 with an ImageButton. Here's my main.xml.

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <TableLayout
  4.  
  5. android:id="@+id/widget108"
  6.  
  7. android:layout_width="fill_parent"
  8.  
  9. android:layout_height="fill_parent"
  10.  
  11. android:orientation="vertical"
  12.  
  13. xmlns:android="http://schemas.android.com/apk/res/android"
  14.  
  15. android:longClickable="false"
  16.  
  17. >
  18.  
  19. <TableRow
  20.  
  21. android:id="@+id/widget109"
  22.  
  23. android:layout_width="fill_parent"
  24.  
  25. android:layout_height="wrap_content"
  26.  
  27. android:orientation="horizontal"
  28.  
  29.  
  30.  
  31. >
  32.  
  33. <ImageView
  34.  
  35. android:id="@+id/widget112"
  36.  
  37. android:layout_width="wrap_content"
  38.  
  39. android:layout_height="wrap_content"
  40.  
  41. android:src="@drawable/gasbot"
  42.  
  43. >
  44.  
  45. </ImageView>
  46.  
  47. <ImageView
  48.  
  49. android:id="@+id/widget112"
  50.  
  51. android:layout_width="wrap_content"
  52.  
  53. android:layout_height="wrap_content"
  54.  
  55. android:src="@drawable/how_search"
  56.  
  57. >
  58.  
  59. </ImageView>
  60.  
  61. </TableRow>
  62.  
  63. <TableRow
  64.  
  65. android:id="@+id/widget110"
  66.  
  67. android:layout_width="fill_parent"
  68.  
  69. android:layout_height="wrap_content"
  70.  
  71. android:orientation="horizontal"
  72.  
  73. >
  74.  
  75. <ImageButton
  76.  
  77. android:id="@+id/widget113"
  78.  
  79. android:layout_width="wrap_content"
  80.  
  81. android:layout_height="wrap_content"
  82.  
  83. android:src="@drawable/by_location"
  84.  
  85. >
  86.  
  87. </ImageButton>
  88.  
  89. </TableRow>
  90.  
  91. <TableRow
  92.  
  93. android:id="@+id/widget111"
  94.  
  95. android:layout_width="fill_parent"
  96.  
  97. android:layout_height="wrap_content"
  98.  
  99. android:orientation="horizontal"
  100.  
  101. >
  102.  
  103. <ImageButton
  104.  
  105. android:id="@+id/widget114"
  106.  
  107. android:layout_width="wrap_content"
  108.  
  109. android:layout_height="wrap_content"
  110.  
  111. android:src="@drawable/by_address"
  112.  
  113. >
  114.  
  115. </ImageButton>
  116.  
  117. </TableRow>
  118.  
  119. </TableLayout>
  120.  
  121.  
Parsed in 0.006 seconds, using GeSHi 1.0.8.4


And my java class is exactly how it was when I started the project. To me it seems like it's choking on the images, but I have no clue. I'm brand new to Android and am very rusty on my java programming.
GasBot
Experienced Developer
Experienced Developer
 
Posts: 50
Joined: Fri Oct 17, 2008 7:19 am

Postby MrSnowflake » Fri Oct 17, 2008 5:14 pm

Sorry it's unknown to me and probably not layout related, but type relate (you sure its an Activity?).
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby GasBot » Fri Oct 17, 2008 6:53 pm

MrSnowflake wrote:Sorry it's unknown to me and probably not layout related, but type relate (you sure its an Activity?).


From what I've read is an Activity is any screen. This is just a screen displaying a logo and two buttons. I used some DroidDraw site to generate the XML. I might try just writing it from scratch and see what happens.
GasBot
Experienced Developer
Experienced Developer
 
Posts: 50
Joined: Fri Oct 17, 2008 7:19 am

Postby GasBot » Fri Oct 17, 2008 9:24 pm

And now I'm getting this error whenever I try to run or debug anything...

[2008-10-17 13:27:54 - HelloAndroid] Failed to upload HelloAndroid.apk on 'emulator-5554': Local file doesn't exist.

I tried restarting Eclipse and the emulator, but am still getting it. :(
GasBot
Experienced Developer
Experienced Developer
 
Posts: 50
Joined: Fri Oct 17, 2008 7:19 am

Top

Postby GasBot » Sat Oct 18, 2008 5:56 am

I don't know what the deal was with that app, but I was able to get the HelloAndroid one working with essentially the same code. So I just deleted my original project and renamed the HelloAndroid one and everything is working. Weird.
GasBot
Experienced Developer
Experienced Developer
 
Posts: 50
Joined: Fri Oct 17, 2008 7:19 am

Postby MrSnowflake » Sat Oct 18, 2008 1:46 pm

I do the same thing when Eclipse fails on me :).
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 3 guests