0

My prototype android app (I should mention it's my first) crashes whenever I run it through eclipse, as soon as it opens. I have searched this site and many others and this problem seems common, but not in the way it is for me. I have checked the AndroidManifest.xml file and am fairly sure it is correct, but I attach it here anyway.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.cyphr"
  android:versionCode="1"
  android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".NSBHSActivity"
              android:label="@string/app_name"
              android:theme="@android:style/Theme.NoTitleBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".DayActivity"
              android:label="@string/app_name">
    </activity>
    <activity android:name=".WeekActivity"
              android:label="@string/app_name">
    </activity>

</application>

Here are the logcat messages, from the program starting to it dying, as far as I can tell.

08-09 18:23:57.342: INFO/dalvikvm(24229): Debugger has detached; object registry had 1 entries
08-09 18:23:57.358: ERROR/AndroidRuntime(24229): ERROR: thread attach failed
08-09 18:23:57.756: INFO/ActivityManager(1194): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.cyphr/.NSBHSActivity }
08-09 18:23:57.795: INFO/dalvikvm(24239): Debugger has detached; object registry had 1 entries
08-09 18:23:57.819: ERROR/AndroidRuntime(24239): ERROR: thread attach failed
08-09 18:23:57.897: INFO/ActivityManager(1194): Start proc com.cyphr for activity com.cyphr/.NSBHSActivity: pid=24246 uid=10103 gids={}
08-09 18:23:57.959: INFO/foo(1194): ********************** resuming: 1143348080
08-09 18:23:58.155: ERROR/dalvikvm(24246): Stack overflow on calling method:
08-09 18:23:58.155: ERROR/dalvikvm(24246):       android.content.res.AssetManager.loadResourceValue()
08-09 18:23:58.155: ERROR/dalvikvm(24246):       prototype     : (ILandroid/util/TypedValue;Z)I
08-09 18:23:58.155: ERROR/dalvikvm(24246):       shorty        : IILZ
08-09 18:23:58.155: ERROR/dalvikvm(24246):       registersSize : 4
08-09 18:23:58.155: ERROR/dalvikvm(24246):       insSize       : 4
08-09 18:23:58.178: ERROR/dalvikvm(24246):       outsSize      : 0
08-09 18:23:58.178: ERROR/dalvikvm(24246):   method 0x4108cf64, rPC 0x4205308e, self->curFrame 0x4104c224
08-09 18:23:58.178: ERROR/dalvikvm(24246):   rGLUE 0xbef439f8:
08-09 18:23:58.178: ERROR/dalvikvm(24246):     rGLUE->pc 0x41fe8b68, rGLUE->fp 0x4104eeb8, rGLUE->method 0x4108d5b4:
08-09 18:23:58.178: ERROR/dalvikvm(24246):       android.content.res.AssetManager.getResourceValue()
08-09 18:23:58.178: ERROR/dalvikvm(24246):       prototype     : (ILandroid/util/TypedValue;Z)Z
08-09 18:23:58.178: ERROR/dalvikvm(24246):       shorty        : ZILZ
08-09 18:23:58.178: ERROR/dalvikvm(24246):       registersSize : 8
08-09 18:23:58.178: ERROR/dalvikvm(24246):       insSize       : 4
08-09 18:23:58.178: ERROR/dalvikvm(24246):       outsSize      : 4
08-09 18:23:58.178: INFO/dalvikvm(24246): Stack overflow, expanding (0x4104c200 to 0x4104c000)
08-09 18:23:58.178: INFO/dalvikvm(24246): Current stack size is 12288
08-09 18:23:58.178: INFO/dalvikvm(24246): "main" prio=5 tid=3 RUNNABLE
08-09 18:23:58.178: INFO/dalvikvm(24246):   | group="main" sCount=0 dsCount=0 s=N obj=0x4001e368 self=0xbd90
08-09 18:23:58.178: INFO/dalvikvm(24246):   | sysTid=24246 nice=0 sched=0/0 cgrp=unknown handle=-1343993120

onCreate() from NSBHSActivity, as requested:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Resources res = getResources(); // Resource object to get Drawables
    TabHost tabHost = getTabHost();  // The activity TabHost
    TabHost.TabSpec spec;  // Reusable TabSpec for each tab
    Intent intent;  // Reusable Intent for each tab

    // Create an Intent to launch an Activity for the tab (to be reused)
    intent = new Intent().setClass(this, DayActivity.class);

    // Initialize a TabSpec for each tab and add it to the TabHost
    spec = tabHost.newTabSpec("day").setIndicator("Day",
                      res.getDrawable(R.drawable.ic_tab_day))
                  .setContent(intent);
    tabHost.addTab(spec);

    // Do the same for the other tabs
    intent = new Intent().setClass(this, WeekActivity.class);
    spec = tabHost.newTabSpec("week").setIndicator("Week",
                      res.getDrawable(R.drawable.ic_tab_day))
                  .setContent(intent);
    tabHost.addTab(spec);

    tabHost.setCurrentTab(1);

}

Comment if you require extra information. Also, as I said, this is my first Android app, but I have good experience in Java.

cortices
  • 373
  • 2
  • 15
  • Can you post onCreate() from NSBHSActivity? – alexanderblom Aug 09 '11 at 09:09
  • BTW, this is the link to the tutorial: http://developer.android.com/resources/tutorials/views/hello-tabwidget.html – cortices Aug 09 '11 at 09:24
  • ic_tab_day is a regular image right? Not a XML drawable? – alexanderblom Aug 09 '11 at 09:29
  • @alexanderblom the full image file name is ic_tab_day.png – cortices Aug 09 '11 at 09:32
  • Doh! the image i thought was called that wasn't and i changed it, then got this error, this may be a whole new can o' fish: `[2011-08-09 19:33:25 - NSBHS] res/drawable/ic_tab_day.xml:0: error: Resource entry ic_tab_day is already defined. [2011-08-09 19:33:25 - NSBHS] res/drawable/ic_tab_day.png:0: Originally defined here.` – cortices Aug 09 '11 at 09:34
  • It's something about that XML drawable then, rename them and if it still doesn't work post the contents of ic_tab_day.xml. – alexanderblom Aug 09 '11 at 13:43

3 Answers3

1

i don't think android:theme="@android:style/Theme.NoTitleBar" is a valid tag.. remove it and check.

ngesh
  • 13,398
  • 4
  • 44
  • 60
1

You have put application tag out of manifest tag: use like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.cyphr"
  android:versionCode="1"
  android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" >

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".NSBHSActivity"
              android:label="@string/app_name"
              android:theme="@android:style/Theme.NoTitleBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".DayActivity"
              android:label="@string/app_name">
    </activity>
    <activity android:name=".WeekActivity"
              android:label="@string/app_name">
    </activity>

</application>
</manifest>
Vineet Shukla
  • 23,865
  • 10
  • 55
  • 63
0

I finally found out it was because of the image file names. They needed to be ic_tab_day_grey.png and ic_tab_day_white.png for the state list to accept them. Yay! Thanks everyone for your help!

Greg
  • 9,068
  • 6
  • 49
  • 91
cortices
  • 373
  • 2
  • 15