从logcat的判断错误 - Android电子 [英] Determine error from Logcat - Android
问题描述
谁能决定什么错误,或者给我任何线索?我认为这是当前活动(CreateProfileActivity)内,在这个buttonClick方法:
公共无效saveUserClick(查看视图){
saveUserDetails();
insertUserToDB();
Log.d(哟,yoyoyo);
dbHelper.logDataBase();
}
特别是,此行 dbHelper.logDataBase();
下面是方法声明:
公共无效logDataBase(){
//让所有衣物
Log.d(获取数据库项目,让所有数据库项目); 清单< ClothingItem> allClothingItems = this.getAllClothingItems();
清单<&APPUSER GT; allAppUsers = this.getAllAppUsers();
对于(ClothingItem clothingItem:allClothingItems){
Log.d(ClothingItem,clothingItem.getIdString());
}
对于(APPUSER APPUSER:allAppUsers){
Log.d(用户,appUser.getImagePath());
}
}
下面是logcat的:
2月12日至30日:39:57.499:D / dalvikvm(277):GC_EXPLICIT释放在138ms 5474对象/ 286208字节
2月12日至30日:41:48.227:D /哟(277):yoyoyo
2月12日至30日:41:48.227:D /获取数据库项目(277):让所有数据库项目
2月12日至30日:41:48.227:E / dbHelper(277):SELECT * FROM ClothingItem
2月12日至30日:41:48.247:E / dbHelper(277):SELECT * FROM APPUSER
2月12日至30日:41:48.247:D / ClothingItem(277):1
2月12日至30日:41:48.247:D / ClothingItem(277):2
2月12日至30日:41:48.247:D / ClothingItem(277):3
2月12日至30日:41:48.247:D / ClothingItem(277):4
2月12日至30日:41:48.247:D / ClothingItem(277):5
2月12日至30日:41:48.247:D / ClothingItem(277):6
2月12日至30日:41:48.247:D / ClothingItem(277):7
2月12日至30日:41:48.247:D / ClothingItem(277):8
2月12日至30日:41:48.247:D / ClothingItem(277):9
2月12日至30日:41:48.247:D / ClothingItem(277):10
2月12日至30日:41:48.247:D / ClothingItem(277):11
2月12日至30日:41:48.247:D / ClothingItem(277):12
2月12日至30日:41:48.247:D /用户(277):内容://媒体/外部/图像/媒体/ 1
2月12日至30日:41:48.247:D /用户(277):内容://媒体/外部/图像/媒体/ 1
2月12日至30日:41:48.247:D / AndroidRuntime(277):关闭VM
2月12日至30日:41:48.247:W / dalvikvm(277):主题ID = 1:螺纹未捕获的异常退出(组= 0x4001d800)
2月12日至30日:41:48.267:E / AndroidRuntime(277):致命异常:主要
2月12日至30日:41:48.267:E / AndroidRuntime(277):java.lang.IllegalStateException:无法执行活动的方法
2月12日至30日:41:48.267:E / AndroidRuntime(277):在android.view.View $ 1.onClick(View.java:2072)
2月12日至30日:41:48.267:E / AndroidRuntime(277):在android.view.View.performClick(View.java:2408)
2月12日至30日:41:48.267:E / AndroidRuntime(277):在android.view.View $ PerformClick.run(View.java:8816)
2月12日至30日:41:48.267:E / AndroidRuntime(277):在android.os.Handler.handleCallback(Handler.java:587)
2月12日至30日:41:48.267:E / AndroidRuntime(277):在android.os.Handler.dispatchMessage(Handler.java:92)
2月12日至30日:41:48.267:E / AndroidRuntime(277):在android.os.Looper.loop(Looper.java:123)
2月12日至30日:41:48.267:E / AndroidRuntime(277):在android.app.ActivityThread.main(ActivityThread.java:4627)
2月12日至30日:41:48.267:E / AndroidRuntime(277):在java.lang.reflect.Method.invokeNative(本机方法)
2月12日至30日:41:48.267:E / AndroidRuntime(277):在java.lang.reflect.Method.invoke(Method.java:521)
2月12日至30日:41:48.267:E / AndroidRuntime(277):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:868)
2月12日至30日:41:48.267:E / AndroidRuntime(277):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
2月12日至30日:41:48.267:E / AndroidRuntime(277):在dalvik.system.NativeStart.main(本机方法)
2月12日至30日:41:48.267:E / AndroidRuntime(277):由:java.lang.reflect.InvocationTargetException
2月12日至30日:41:48.267:E / AndroidRuntime(277):在com.btf271.fashionassistant.CreateProfileActivity.saveUserClick(CreateProfileActivity.java:50)
2月12日至30日:41:48.267:E / AndroidRuntime(277):在java.lang.reflect.Method.invokeNative(本机方法)
2月12日至30日:41:48.267:E / AndroidRuntime(277):在java.lang.reflect.Method.invoke(Method.java:521)
2月12日至30日:41:48.267:E / AndroidRuntime(277):在android.view.View $ 1.onClick(View.java:2067)
2月12日至30日:41:48.267:E / AndroidRuntime(277):11 ...更多
2月12日至30日:41:48.267:E / AndroidRuntime(277):显示java.lang.NullPointerException:由引起的println需要一个消息
2月12日至30日:41:48.267:E / AndroidRuntime(277):在android.util.Log.println_native(本机方法)
2月12日至30日:41:48.267:E / AndroidRuntime(277):在android.util.Log.d(Log.java:122)
2月12日至30日:41:48.267:E / AndroidRuntime(277):在com.btf271.dbhelper.dbhelper.logDataBase(dbhelper.java:138)
2月12日至30日:41:48.267:E / AndroidRuntime(277):15 ...更多
虚拟机出现某种原因logDatabase方法之后关闭。当我注释掉,就不会关闭。
谁能决定什么错误,或者给我任何线索?
块引用>是的。这第几行告诉我们,这是在
的onClick
java.lang.IllegalStateException:无法执行活动的方法
2月12日至30日:41:48.267:E / AndroidRuntime(277):在android.view.View $ 1.onClick(View.java:2072)它有麻烦整理的方法(可能是由于我的经验,一个无限循环)。
这几行告诉我们,你是正确的,因为它是在
的onClick()
您发布产生的原因:java.lang.reflect.InvocationTargetException
2月12日至30日:41:48.267:E / AndroidRuntime(277):在
com.btf271.fashionassistant.CreateProfileActivity。
saveUserClick(CreateProfileActivity.java:50)和此行
产生的原因:显示java.lang.NullPointerException:需要的println消息
告诉你的例外是什么。下一行引用您的项目
在com.btf271.dbhelper.dbhelper.logDataBase(dbhelper.java:138)
告诉你,这是在
138线dbhelper.java
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.
解决方案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 postedCaused 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
这篇关于从logcat的判断错误 - Android电子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!