user2602079
user2602079

Reputation: 1403

Determine error from Logcat - Android

Can anyone determine what is going wrong, or give me any clues? I think it is within the current activity (CreateProfileActivity), in this buttonClick method:

public void saveUserClick(View view){
        saveUserDetails();
        insertUserToDB();
        Log.d("yo", "yoyoyo");
        dbHelper.logDataBase();
    }

in particular, this line dbHelper.logDataBase();

Here is that methods declaration:

public void logDataBase(){
        // Getting all clothing items
        Log.d("Get database Items", "Getting all database items");

        List<ClothingItem> allClothingItems = this.getAllClothingItems();
        List<AppUser> allAppUsers = this.getAllAppUsers();
        for (ClothingItem clothingItem : allClothingItems) {
            Log.d("ClothingItem", clothingItem.getIdString());
        }
        for (AppUser appUser : allAppUsers) {
            Log.d("User", appUser.getImagePath());
        }
    }

Here is the Logcat:

12-30 02:39:57.499: D/dalvikvm(277): GC_EXPLICIT freed 5474 objects / 286208 bytes in 138ms
    12-30 02:41:48.227: D/yo(277): yoyoyo
    12-30 02:41:48.227: D/Get database Items(277): Getting all database items
    12-30 02:41:48.227: E/dbHelper(277): SELECT  * FROM ClothingItem
    12-30 02:41:48.247: E/dbHelper(277): SELECT  * FROM AppUser
    12-30 02:41:48.247: D/ClothingItem(277): 1
    12-30 02:41:48.247: D/ClothingItem(277): 2
    12-30 02:41:48.247: D/ClothingItem(277): 3
    12-30 02:41:48.247: D/ClothingItem(277): 4
    12-30 02:41:48.247: D/ClothingItem(277): 5
    12-30 02:41:48.247: D/ClothingItem(277): 6
    12-30 02:41:48.247: D/ClothingItem(277): 7
    12-30 02:41:48.247: D/ClothingItem(277): 8
    12-30 02:41:48.247: D/ClothingItem(277): 9
    12-30 02:41:48.247: D/ClothingItem(277): 10
    12-30 02:41:48.247: D/ClothingItem(277): 11
    12-30 02:41:48.247: D/ClothingItem(277): 12
    12-30 02:41:48.247: D/User(277): content://media/external/images/media/1
    12-30 02:41:48.247: D/User(277): content://media/external/images/media/1
    12-30 02:41:48.247: D/AndroidRuntime(277): Shutting down VM
    12-30 02:41:48.247: W/dalvikvm(277): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
    12-30 02:41:48.267: E/AndroidRuntime(277): FATAL EXCEPTION: main
    12-30 02:41:48.267: E/AndroidRuntime(277): java.lang.IllegalStateException: Could not execute method of the activity
    12-30 02:41:48.267: E/AndroidRuntime(277):  at android.view.View$1.onClick(View.java:2072)
    12-30 02:41:48.267: E/AndroidRuntime(277):  at android.view.View.performClick(View.java:2408)
    12-30 02:41:48.267: E/AndroidRuntime(277):  at android.view.View$PerformClick.run(View.java:8816)
    12-30 02:41:48.267: E/AndroidRuntime(277):  at android.os.Handler.handleCallback(Handler.java:587)
    12-30 02:41:48.267: E/AndroidRuntime(277):  at android.os.Handler.dispatchMessage(Handler.java:92)
    12-30 02:41:48.267: E/AndroidRuntime(277):  at android.os.Looper.loop(Looper.java:123)
    12-30 02:41:48.267: E/AndroidRuntime(277):  at android.app.ActivityThread.main(ActivityThread.java:4627)
    12-30 02:41:48.267: E/AndroidRuntime(277):  at java.lang.reflect.Method.invokeNative(Native Method)
    12-30 02:41:48.267: E/AndroidRuntime(277):  at java.lang.reflect.Method.invoke(Method.java:521)
    12-30 02:41:48.267: E/AndroidRuntime(277):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    12-30 02:41:48.267: E/AndroidRuntime(277):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    12-30 02:41:48.267: E/AndroidRuntime(277):  at dalvik.system.NativeStart.main(Native Method)
    12-30 02:41:48.267: E/AndroidRuntime(277): Caused by: java.lang.reflect.InvocationTargetException
    12-30 02:41:48.267: E/AndroidRuntime(277):  at com.btf271.fashionassistant.CreateProfileActivity.saveUserClick(CreateProfileActivity.java:50)
    12-30 02:41:48.267: E/AndroidRuntime(277):  at java.lang.reflect.Method.invokeNative(Native Method)
    12-30 02:41:48.267: E/AndroidRuntime(277):  at java.lang.reflect.Method.invoke(Method.java:521)
    12-30 02:41:48.267: E/AndroidRuntime(277):  at android.view.View$1.onClick(View.java:2067)
    12-30 02:41:48.267: E/AndroidRuntime(277):  ... 11 more
    12-30 02:41:48.267: E/AndroidRuntime(277): Caused by: java.lang.NullPointerException: println needs a message
    12-30 02:41:48.267: E/AndroidRuntime(277):  at android.util.Log.println_native(Native Method)
    12-30 02:41:48.267: E/AndroidRuntime(277):  at android.util.Log.d(Log.java:122)
    12-30 02:41:48.267: E/AndroidRuntime(277):  at com.btf271.dbhelper.dbhelper.logDataBase(dbhelper.java:138)
    12-30 02:41:48.267: E/AndroidRuntime(277):  ... 15 more

The VM appears to shut down after that logDatabase method for some reason. When i comment it out, it doesn't shut down.

Upvotes: 0

Views: 138

Answers (2)

codeMagic
codeMagic

Reputation: 44571

Can anyone determine what is going wrong, or give me any clues?

Yes. This first couple of lines tells us that it is in the onClick

 java.lang.IllegalStateException: Could not execute method of the activity
 12-30 02:41:48.267: E/AndroidRuntime(277):  at android.view.View$1.onClick(View.java:2072)

its having trouble finishing that method (possibly due to an infinite loop in my experience).

These lines tell us that you are correct in that it is in the onClick() that you posted

Caused by: java.lang.reflect.InvocationTargetException
12-30 02:41:48.267: E/AndroidRuntime(277):  at    
com.btf271.fashionassistant.CreateProfileActivity.
saveUserClick(CreateProfileActivity.java:50)

and this line

Caused by: java.lang.NullPointerException: println needs a message

tells you what the exception is. The next line that references your project

at com.btf271.dbhelper.dbhelper.logDataBase(dbhelper.java:138)

tells you that it is at line 138 of dbhelper.java

Upvotes: 2

Dehan Wjiesekara
Dehan Wjiesekara

Reputation: 3182

when you executing following line

dbHelper.logDataBase();

"dbHelper" reference is null. reason may be you didn't initialise it.

Upvotes: 0

Related Questions