0

I am continually getting these crash reports and I can't figure out why. This comes from a Kindle Fire, and they seem to be the only devices I am having errors on. I don't have one to test, but does anybody know why this NullPointerException only happens on Kindle Fire? Is it not compatible with SQLite? I never have any issues on my own test device or any crash reports from other Android devices. Any insight would be appreciated.

Also, fyi there is nothing I can identify from the code that should be causing this NullPointerException so I don't know what is making it happen only on a Kindle Fire..

java.lang.RuntimeException
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2060)
    at android.app.ActivityThread.access$600(ActivityThread.java:127)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1181)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4558)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
    at org.orman.dbms.ResultList$ResultRow.getColumn(ResultList.java:31)
    at org.orman.mapper.ReverseMapping.map(ReverseMapping.java:51)
    at org.orman.mapper.Model.fetchQuery(Model.java:439)
    at com.appsbydesign.soundfxfree.helpers.SQLiteHelper.getSounds(SQLiteHelper.java:23)
    at com.appsbydesign.soundfxfree.SoundsActivityGrid.onStartSoundsActivityGrid (SoundsActivityGrid.java:260)
    at com.appsbydesign.soundfxfree.SoundsActivityGrid.onStart(SoundsActivityGrid.java)
    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1133)
    at android.app.Activity.performStart(Activity.java:4646)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2008)
    ... 11 more

Here is part of the code from my SQLite Helper class that the error log says the issue is coming from:

public class SQLiteHelper {

        public static List<Category> getCategories() {
            return Model.fetchAll(Category.class);
        }

        public static List<Sound> getSounds(long categoryId) {
            Query query = ModelQuery.select().from(Sound.class)
                .where(C.eq(Sound.Columns.CATEGORY, categoryId)).getQuery();
            return Model.fetchQuery(query, Sound.class);
        }

Line 23 is this one: return Model.fetchQuery(query, Sound.class);

Here is part of the code from my SoundActivityGrid class that is also called in the error log. Line 260 is case 1: sounds = SQLiteHelper.getSounds(categoryId); in the code:

@Override
protected void onStart() {
    super.onStart();
    switch (activityName) {
    case 1:
        sounds = SQLiteHelper.getSounds(categoryId);
        break;

    case 2:
        sounds = SQLiteHelper.getRecordedCategory(categoryId);
        break;

    case 3:
        sounds = SQLiteHelper.getFavouriteSounds(categoryId);
        break;

    case 5:
        List<Sound> timedSounds = SQLiteHelper.getSounds(categoryId);
        sounds = new ArrayList<Sound>();
        for (Sound sound : timedSounds) {
            EntityList<Sound, Timer> timers = sound.getTimers();
            if (timers.size() > 0) {
                sounds.add(sound);
            }
        }
        break;
    case 7:
        List<Sound> timedSoundsGrid = SQLiteHelper.getSounds(categoryId);
        sounds = new ArrayList<Sound>();
        for (Sound sound : timedSoundsGrid) {
            EntityList<Sound, Timer> timers = sound.getTimers();
            if (timers.size() > 0) {
                sounds.add(sound);
            }
        }
        break;
    case 6:
        sounds = SQLiteHelper.getwidgetPlaySound(categoryId);
        break;

    }

I don't have access to org.orman.dbms.

Edit:

I was able to access the ResultList code in the orman dbms and this is what it said:

public class ResultList {
private String[] columnNames;
private Map<String, Integer> columnNameMap;


private Object[][] records;


public final class ResultRow {
    private Map<String, Integer> columnNameMap;
    private Object[] row;


    private ResultRow(Map<String, Integer> columnNameMap, Object[] row) {
        this.columnNameMap = columnNameMap;
        this.row = row;
    }


    public Object getColumn(String columnName) {
        return row[columnNameMap.get(columnName)]; // TODO if column does not exist throw xceptn
    }
}

Line 31 is:

return row[columnNameMap.get(columnName)]; // TODO if column does not exist throw xceptn

I don't know why it thinks a column does not exist. I do not fully understand how the database code works.

Nick Lopez
  • 27
  • 7
  • 1
    if is nothing about the code that should be causing this NullPointerException why did it happen. Posting only logs is not going to help you. Please post relevant code too. – Illegal Argument Jun 22 '14 at 16:27
  • I've posted the relevant code for the error. – Nick Lopez Jun 22 '14 at 16:38
  • "I don't have access to org.orman.dbms" -- that is some library that you are using. You may need to contact the authors of that library to determine why you are crashing inside of it. – CommonsWare Jun 22 '14 at 16:43
  • It's been a while since you edited your question and even longer since I posted an answer. Could you show us the code that maps the database fields to Class members? I would take a stab and say there's a typo or something there. If the library can't map the results to the datatype then I'd think the issue is there. – indivisible Aug 10 '14 at 19:24
  • But you may have well moved on and either gotten the issue sorted or found another way around the issue. If that's the case I'd urge you to answer your own question with whatever solution you implemented. There's imaginary internet points and badges in it for you! – indivisible Aug 10 '14 at 19:36
  • I am still investigating this issue but what I have found out is that it is not only on kindle devices I am getting this error. After some testing, I discovered that when I updated my application to a new version and released it, anyone who had the previous version and updated would receive this error if they had altered the database in any way. I have a few tables in my application and anytime someone would modify the sound or category tables by removing or adding sounds, when they updated to the new version they get this force close error. I don't have access to the onUpgrade method in orman – Nick Lopez Aug 25 '14 at 14:55

1 Answers1

1

Something is null when something else tries to use it.

Caused by: java.lang.NullPointerException
    at org.orman.dbms.ResultList$ResultRow.getColumn(ResultList.java:31)

I would start looking there.
Or if that is not a package you own then:

at com.appsbydesign.soundfxfree.helpers.SQLiteHelper.getSounds(SQLiteHelper.java:23)

Without seeing the code surrounding these locations all anyone can do it make wild guesses.

What I can possibly surmise from the stacktrace though is that you may be swallowing/catching too many Exceptions without logging the errors. If you get a null ResultSet or ResultRow I'd expect that you should see a complaint from somewhere earlier down the line.


Edit:

You are making it very difficult on yourself. It's incredibly tough to pinpoint exactly which object or what method is letting you down because you have so many condensed on each line.

My best guess would be

Query query = ModelQuery.select().from(Sound.class)
            .where(C.eq(Sound.Columns.CATEGORY, categoryId)).getQuery();

But what you should do right now is go back to your code and split it apart so that you only perform one action per line. Then if/when it crashes again you will have a much better idea of exactly which bit is causing the difficulty.

Update your code and stacktrace with the new versions and we'll see where we stand then.

indivisible
  • 4,892
  • 4
  • 31
  • 50
  • I'm sorry but I don't quite understand what you mean by my code is condensed. I am still learning android code. Can you explain to me where the code I posted needs to be split apart? – Nick Lopez Aug 04 '14 at 16:22
  • I was able to access the dbms in the orman code. I posted the code above. – Nick Lopez Aug 04 '14 at 16:37