0

I see lots of people here with this problem for the iPhone, but this is a Nexus 7 device. App crashes with the release build, yet when I debug directly on the device, the crash doesn't happen. I can tell it's the latest, newest version of the software.

Anyone else run into this?

Release version and debug version are even running off the same database.

Here is the code that's crashing (null pointer exception - line indicated):

        mTabHost = (TabHost)findViewById(R.id.tabHost);
    mTabHost.setup();
    mTabHost.setOnTabChangedListener(this);

    String className = this.getLocalClassName();

    if (surveyID < 68) { 
        String sql = "Select * FROM L_Options WHERE Type = 'TabSetup' AND Setting = '" + optIncludeSurvey + "' " 
                   + "AND Value = " + surveyID;
        Cursor c = DataBaseConnector.query(sql);
        if (c != null) { 
            if (c.moveToFirst()) { 
                surveyID = c.getInt(c.getColumnIndex("FK_RecID"));
            }
        }
    }

    String sql = "SELECT TS.TextID, TS.TabClass, TS.TabHeaderID, TS.Comments,O.Value "//
            + "FROM L_TabSetup AS TS LEFT JOIN L_Options O ON "//
            + "O.FK_RecID = TS.TabSurveyID AND O.Type = 'TabSetup' AND O.Setting = '" + optIncludeSurvey + "' "//
            + "WHERE TS.ScreenClass = '" + className + "' "//
            + "AND TS.Active = 1 "//
            + "AND O.Active = 1 "//
            + "AND TS.TabSurveyID = " + surveyID + " ";

    if (GlobalVars.subjectLeftToRight == 1) {
        sql += "ORDER BY TS.DisplayOrder ASC";
    } else {
        sql += "ORDER BY TS.DisplayOrder DESC";
    }

    Cursor c = DataBaseConnector.query(sql);

    if (c != null) {
        if (c.moveToFirst()) {
            TabInfo tabInfo = null;

            do {
                String comment = c.getString(c.getColumnIndex("Comments"));
                int includeSurveyID = c.getInt(c.getColumnIndex("Value"));
                Class<?> tabClass = getClass(c.getString(c.getColumnIndex("TabClass")));
                int tabHeaderID = c.getInt(c.getColumnIndex("TabHeaderID"));
                //put in included SurveyID
                if (args != null) { 
                    if (args.getInt(optIncludeSurvey, -1) == -1) {                  
                        args.putInt(optIncludeSurvey, includeSurveyID);
                    }
                }
                else { 
                    args = new Bundle();
                    args.putInt(optIncludeSurvey, includeSurveyID);
                }

                String[] texts = Lookups.getText(c.getInt(c.getColumnIndex("TextID")));

                //crash line
                ////////////////////////////////////////////////////////
                tabInfo = new TabInfo(tabClass, args, texts, c.getInt(c.getColumnIndex("TextID")), tabHeaderID, comment, surveyID);
                //end crash line
                //////////////////////////////////////////////////////////

                addTab(this, tabInfo);
                this.mapTabInfo.put(tabInfo.texts[0], tabInfo);

            } while (c.moveToNext());
        }
        c.close();
        c = null;
    }

Please be kind about the coding practices - this is legacy code.

EDITED: Logcat file

08-15 10:07:09.818: E/AndroidRuntime(1221): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.assistek.ediary/com.assistek.ediary.SubjectMenuEvent}: java.lang.NullPointerException
08-15 10:07:09.818: E/AndroidRuntime(1221):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
08-15 10:07:09.818: E/AndroidRuntime(1221):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
08-15 10:07:09.818: E/AndroidRuntime(1221):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-15 10:07:09.818: E/AndroidRuntime(1221):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
08-15 10:07:09.818: E/AndroidRuntime(1221):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-15 10:07:09.818: E/AndroidRuntime(1221):     at android.os.Looper.loop(Looper.java:137)
08-15 10:07:09.818: E/AndroidRuntime(1221):     at android.app.ActivityThread.main(ActivityThread.java:5039)
08-15 10:07:09.818: E/AndroidRuntime(1221):     at java.lang.reflect.Method.invokeNative(Native Method)
08-15 10:07:09.818: E/AndroidRuntime(1221):     at java.lang.reflect.Method.invoke(Method.java:511)
 08-15 10:07:09.818: E/AndroidRuntime(1221):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
 08-15 10:07:09.818: E/AndroidRuntime(1221):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
 08-15 10:07:09.818: E/AndroidRuntime(1221):    at dalvik.system.NativeStart.main(Native Method)
08-15 10:07:09.818: E/AndroidRuntime(1221): Caused by: java.lang.NullPointerException
08-15 10:07:09.818: E/AndroidRuntime(1221):     at com.assistek.ediary.SubjectMenuEvent.setupTabHost(SubjectMenuEvent.java:255)
08-15 10:07:09.818: E/AndroidRuntime(1221):     at com.assistek.ediary.SubjectMenuEvent.onCreate(SubjectMenuEvent.java:96)
08-15 10:07:09.818: E/AndroidRuntime(1221):     at android.app.Activity.performCreate(Activity.java:5104)
08-15 10:07:09.818: E/AndroidRuntime(1221):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
08-15 10:07:09.818: E/AndroidRuntime(1221):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
08-15 10:07:09.818: E/AndroidRuntime(1221):     ... 11 more

Related question: Reinstalling app does not bring over all the changes of released app android

Community
  • 1
  • 1
Kristy Welsh
  • 7,828
  • 12
  • 64
  • 106
  • Any idea what line could be failing? Might be worth having loads of if statements (for testing on a device) and if one of them is null to display an error explaining which of the variables is null. Also using a try catch here and there might be useful too... The potential reason the debug works is because code runs much slower, which gives time for a variable not to be null (if initiated on a thread or similar) – apmartin1991 Aug 14 '14 at 21:51
  • I put the line that was failing in the code. I was able to see what was going on in Logcat. I will do a try catch block to test this out. Thanks for taking a look. – Kristy Welsh Aug 14 '14 at 22:27
  • Not running this in a thread (I know bad design). – Kristy Welsh Aug 14 '14 at 22:28
  • Can you provide the full logcat crash? – Larry Schiefer Aug 15 '14 at 01:34
  • As above your logcat will be useful here. Threads are not always a good thing for simple apps anyway so don't worry about it :) – apmartin1991 Aug 15 '14 at 06:42

1 Answers1

1

It looks like the application was not be updated with the most current release (the old apk from previous downloads was not being deleted). So this is a non-issue. I did learn a lot, though.

Kristy Welsh
  • 7,828
  • 12
  • 64
  • 106