Reputation: 321
Hi I am new to Android Application Development.I want to know the procedure how do i know which line crashed my application to crash.
I have following code in main.java
package com.example.app_list_view_1;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.text.AndroidCharacter;
import android.util.Log;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import android.os.Build;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("DEEPAK","HELLO WORLD");
String[] cityNames = new String[]{
"A",
"M",
"R",
"H",
};
Toast.makeText(this, "Hello", Toast.LENGTH_LONG).show();
ArrayAdapter<String> myAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
cityNames);
ListView lv = (ListView)findViewById(R.id.list_view_1);
lv.setAdapter(myAdapter);
}
}
Upvotes: 1
Views: 770
Reputation: 1505
Most folks are moving over to Android Studio now a days. Eclipse has a way to view Logcat in one of the tabs. Open that and you will see the line number and stack trace.
From the command-line regardless of IDE you can run:
$ANDROID_SDK/platform-tools/adb logcat -v threadtime
When the application crashes you will get a stack trace that tells you the stack at the time of the crash.
Another good option is Crashlyitc because that will give you vision into failures in the field.
If you need an advanced log tool check out http://lograbbit.com
I hope this helps.
Upvotes: 1
Reputation: 1098
I'd recommend switching to Android Studio
, and use the logcat
output.
https://developer.android.com/sdk/index.html
Upvotes: 0