How do I properly report an Android crash? What should I include and what should I not?
Should I include ALL my code? ALL the logcat? Specifically, how do I make my question cleaner, more understandable and with less code?
How do I properly report an Android crash? What should I include and what should I not?
Should I include ALL my code? ALL the logcat? Specifically, how do I make my question cleaner, more understandable and with less code?
For tips on how to ask a question in general, go here.
No. Don't throw your complete logcat with errors or debugging logs that have nothing to do with the crash; that will make your post ugly.
Don't put this:
09-18 18:49:14.789 15956-16028/com.x.x.xE/NativeCrypto: ssl=0x5ff5d910 cert_verify_callback x509_store_ctx=0x61e3fab8 arg=0x0 09-18 18:49:14.790 15956-16028/com.x.x.salawat E/NativeCrypto: >ssl=0x5ff5d910 cert_verify_callback calling verifyCertificateChain authMethod=DHE_RSA 09-18 18:49:16.142 15956-16042/com.x.x.xE/NativeCrypto: ssl=0x5ff4c5b8 cert_verify_callback x509_store_ctx=0x61e3fab8 arg=0x0 09-18 18:49:16.143 15956-16042/com.x.x.xE/NativeCrypto: ssl=0x5ff4c5b8 cert_verify_callback calling verifyCertificateChain authMethod=ECDHE_RSA 10-25 11:44:32.713: W/KeyCharacterMap(928): No keyboard for id 0 10-25 11:44:32.723: W/KeyCharacterMap(928): Using default keymap: /system/usr/keychars/qwerty.kcm.bin 10-25 11:44:40.383: D/AndroidRuntime(928): Shutting down VM 10-25 11:44:40.383: W/dalvikvm(928): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 10-25 11:44:40.393: E/AndroidRuntime(928): FATAL EXCEPTION: main 10-25 11:44:40.393: E/AndroidRuntime(928): java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 10-25 11:44:40.393: E/AndroidRuntime(928): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257) 10-25 11:44:40.393: E/AndroidRuntime(928): at java.util.ArrayList.get(ArrayList.java:311) 10-25 11:44:40.393: E/AndroidRuntime(928): at com.example.barchart_test.Chart_MainActivity$1.onClick(Chart_MainActivity.java:43) 10-25 11:44:40.393: E/AndroidRuntime(928): at android.view.View.performClick(View.java:2408) 10-25 11:44:40.393: E/AndroidRuntime(928): at android.view.View$PerformClick.run(View.java:8816) 10-25 11:44:40.393: E/AndroidRuntime(928): at android.os.Handler.handleCallback(Handler.java:587) 10-25 11:44:40.393: E/AndroidRuntime(928): at android.os.Handler.dispatchMessage(Handler.java:92) 10-25 11:44:40.393: E/AndroidRuntime(928): at android.os.Looper.loop(Looper.java:123) 10-25 11:44:40.393: E/AndroidRuntime(928): at android.app.ActivityThread.main(ActivityThread.java:4627) 10-25 11:44:40.393: E/AndroidRuntime(928): at java.lang.reflect.Method.invokeNative(Native Method) 10-25 11:44:40.393: E/AndroidRuntime(928): at java.lang.reflect.Method.invoke(Method.java:521)
But instead, post this logcat::
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 10-25 11:44:40.393: E/AndroidRuntime(928): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257) 10-25 11:44:40.393: E/AndroidRuntime(928): at java.util.ArrayList.get(ArrayList.java:311) 10-25 11:44:40.393: E/AndroidRuntime(928): at com.example.barchart_test.Chart_MainActivity$1.onClick(Chart_MainActivity.java:43) 10-25 11:44:40.393: E/AndroidRuntime(928): at android.view.View.performClick(View.java:2408) 10-25 11:44:40.393: E/AndroidRuntime(928): at android.view.View$PerformClick.run(View.java:8816) 10-25 11:44:40.393: E/AndroidRuntime(928): at android.os.Handler.handleCallback(Handler.java:587) 10-25 11:44:40.393: E/AndroidRuntime(928): at android.os.Handler.dispatchMessage(Handler.java:92) 10-25 11:44:40.393: E/AndroidRuntime(928): at android.os.Looper.loop(Looper.java:123) 10-25 11:44:40.393: E/AndroidRuntime(928): at android.app.ActivityThread.main(ActivityThread.java:4627) 10-25 11:44:40.393: E/AndroidRuntime(928): at java.lang.reflect.Method.invokeNative(Native Method) 10-25 11:44:40.393: E/AndroidRuntime(928): at java.lang.reflect.Method.invoke(Method.java:521)
Just look for the error message and provide the code. The error message in our case is java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
"How do I find the line of the error?" you ask? Go into your logcat to the error message you got. Look for blue text like this: and click on it. It will take you to the line of crash. Using logic, you can also suspect something and post its code. That's what I call "The line of the crash".
A nice, beautiful, clean, easy-to-answer question is made in many ways. One of the biggest effects on getting people to actually try to solve your problem is having small code. Don't give EXTRA classes unless they have ANY links with the class the error is occuring in it.. Lets say you're getting a ResourceNotFound
Exception, which you can find using the method above, get the everything that could be related to the crash, and don't forget to add a comment such as //Crash here
. Good post::
I'm getting a
ResourceNotFound
on the line that I indicated below:@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //region Toolbar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); assert getSupportActionBar() != null; getSupportActionBar().setDisplayHomeAsUpEnabled(true); editText.setText(0); //error here //endregion //region ViewPager final ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); viewPager.setOffscreenPageLimit(2); setupViewPager(viewPager); //endregion //region Tabs final TabLayout tabs = (TabLayout) findViewById(R.id.tabs); t abs.post(new Runnable() { @Override public void run() { tabs.setupWithViewPager(viewPager); } }); //endregion }
Bad:
I'm getting a
ResourceNotFoundException
.@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if(true) throw new UnknownError(); //region Toolbar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); assert getSupportActionBar() != null; getSupportActionBar().setDisplayHomeAsUpEnabled(true); //endregion //region ViewPager final ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); viewPager.setOffscreenPageLimit(2); setupViewPager(viewPager); //endregion //region Tabs final TabLayout tabs = (TabLayout) findViewById(R.id.tabs); tabs.post(new Runnable() { @Override public void run() { tabs.setupWithViewPager(viewPager); } }); class ViewPagerAdapter extends FragmentPagerAdapter { private final List<Fragment> mFragmentList = new ArrayList<>(); private final List<String> mFragmentTitleList = new ArrayList<>(); ViewPagerAdapter(FragmentManager manager) { super(manager); } @Override public Fragment getItem(int position) { return mFragmentList.get(position); } @Override public int getCount() { return mFragmentList.size(); } void addFragment(Fragment fragment, String title) { mFragmentList.add(fragment); mFragmentTitleList.add(title); }
RandomClassThatHasNothingToDoWithAnything.java:
public class RandomClassThatHasNothingToDoWithAnything extends Dialog implements View.OnClickListener { private View mDialogView; private AnimationSet mModalInAnim; private AnimationSet mModalOutAnim; private Animation mOverlayOutAnim; private Animation mErrorInAnim; private AnimationSet mErrorXInAnim; private AnimationSet mSuccessLayoutAnimSet; private Animation mSuccessBowAnim; private TextView mTitleTextView; private TextView mContentTextView; private String mTitleText; private String mContentText; private boolean mShowCancel; private String mCancelText; private String mConfirmText; private int mAlertType; private FrameLayout mErrorFrame; private FrameLayout mSuccessFrame; private SuccessTickView mSuccessTick; private ImageView mErrorX; private View mSuccessLeftMask; private View mSuccessRightMask; private Drawable mCustomImgDrawable; private ImageView mCustomImage; private Button mConfirmButton; private Button mCancelButton; private FrameLayout mWarningFrame; private OnSweetClickListener mCancelClickListener; private OnSweetClickListener mConfirmClickListener; private boolean mCloseFromCancel; public static final int NORMAL_TYPE = 0; public static final int ERROR_TYPE = 1; public static final int SUCCESS_TYPE = 2; public static final int WARNING_TYPE = 3; public static final int CUSTOM_IMAGE_TYPE = 4; public static interface OnSweetClickListener { public void onClick (SweetAlertDialog sweetAlertDialog); } public SweetAlertDialog(Context context) { this(context, NORMAL_TYPE); } public SweetAlertDialog(Context context, int alertType) { super(context, R.style.alert_dialog); setCancelable(true); setCanceledOnTouchOutside(false); mAlertType = alertType; ...
... More unnecessary ugly excess disgusting etc. code
Remember, let logic guide you. Try to only put the code that the answerer needs. If you can't seem to do so, just put the whole class (not all the classes! Just the class and layout of the class that is crashing), it won't affect it too much. It will attract downvotes if you post your full application's code.
"NullPointerExceptions"
I'm making this title in the biggest text possible. Check out this post if you're getting this error, if it doesn't help you and you can't find the issue, then post it.
NullPointerException
s, while particularly (usually) easy to debug, are not always straightforward. Sorry but -1.
Sep 18, 2016 at 18:41