4

My app works well in the emulator of eclipse, and I can view many error information when I debug the app in the emulator.

After I finish testing my app, I installed the app in real android mobile samsung i8150 mobile (Android 2.3.6), but sometimes I get the following error.

I don't know what caused the error, how to view the error information of a crash app when I run the app in real android mobile ?

enter image description here

Illegal Argument
  • 10,090
  • 2
  • 44
  • 61
HelloCW
  • 843
  • 22
  • 125
  • 310

8 Answers8

3

Once the crash occurs connect the device and you can see the cause in your IDE Logcat.

LoveMeSomeFood
  • 3,137
  • 7
  • 30
  • 53
  • I keep connect when I test my app in real moblie, but eclipse IDE Logcat don't display any error information, why? – HelloCW Nov 07 '13 at 08:10
  • 1
    From the Eclipse DDMS > Device Select Device(your connected device). once try this.I was facing sme prob and by selecting device like ths way m able to see logcat. hope ths will help ... – user1140237 Nov 12 '13 at 04:43
  • If the crash is happening, you can add a tag "AndroidRuntime" to your logcat. With this tag, you can find the crash reason in the logcat easily. – shallOvercome Nov 15 '13 at 19:42
2

There are various apps available for viewing logs on the device, like aLogcat https://play.google.com/store/apps/details?id=org.jtb.alogcat&hl=en

With aLogcat you can search for you output tag and find the error.

softarn
  • 5,327
  • 3
  • 40
  • 54
1

Try to test your app while your device is connected to your PC. In order to do so, follow this step:

  1. Declare your application as "debuggable" in your Android Manifest. When using Eclipse, you can skip this step, because running your app directly from the Eclipse IDE automatically enables debugging. In the AndroidManifest.xml file, add android:debuggable="true" to the "application" element.

  2. Enable USB debugging on your device: nn most devices running Android 3.2 or older, you can find the option under Settings > Applications > Development.

  3. Set up your system to detect your device. If you're developing on Windows, you need to install a USB driver for adb. For an installation guide and links to OEM drivers, see the OEM USB Drivers document. If you're developing on Mac OS X, it just works. Skip this step.

Finally run your app on your device and see in LogCat what's happening.

I tried it on my app and it is very useful. I took all info here.

JJ86
  • 5,055
  • 2
  • 35
  • 64
1

Combining all the possibilities Why you are not getting a Logcat
Possibilities

  1. Application is not debuggable.
  2. Developer options are not enabled in your phone (Since you mentioned you installed app in your phone but did not specify using apk to by debugging OR adb drivers for your phone are not installed)
  3. Logcat output set to info or other levels lower than error
  4. ADB cannot attach debugger (adb server is not running, falied, etc..)

Respective solutions

  1. In you app's android manifest set android:debuggale="true"
  2. Install the right ADB drivers for your phone (Remember ADB drivers are not always installed by default, others are. If you can access your phone from your computer (transfer files, play music, connect to pc suite etc.. ) - that does not mean ADB drivers are installed). Check your manufacturers website and download the right ADB drivers for your phone.
  3. Set your logcat output to VERBOSE
  4. Is ADB running? (try restarting ADB - adb kill-server, adb start-server)
    OR ALTERNATIVELY
    you can add this little piece of code to view your app crash reason
    Create a new Application class like this.

    public class App extends android.app.Application
    {
          @Override
          onCreate(...) {
          super.onCreate();
          Thread.setDefaultUncaughtExceptionHandler(new Thread.
          UncaughtExceptionHandler() {
          public void uncaughtException(Thread t, Throwable e) {
          Toast.makeText(getApplicationContext(), t + " has " + e, Toast.LENGTH_LONG).show();
    }
    });
    


And in your application manifest

<application ...... name="com.yourpackage.App" > ......  </application>
johntheripp3r
  • 989
  • 6
  • 15
1

https://play.google.com/store/apps/details?id=com.nolanlawson.logcat&hl=en

use this app,many features are there

  • Color-coded tag names
  • Easy-to-read column display
  • Real-time search
  • Recording mode (with widget)
  • Save & open from SD card
  • Send logs as email or attachment
  • Auto-scrolls when at the bottom of the screen (just like tail -f)
  • Search autosuggestions & saved filters
  • Select parts of logs
  • Open-source and ad-free
Dinesh Raj
  • 664
  • 12
  • 30
1

Connect your phone to your computer and run eclipse.

Open up the logcat in eclipse and you will see some profiling of what your phone is doing at the moment.

Open up your app and crash it.

When it crashes, you will see an error message in red.

superuser
  • 731
  • 10
  • 28
1
  1. Connect phone to PC.
  2. In eclipse click on the arrow next to the 'run' button, select 'Run Configurations'.
  3. Select your phone and your app and run.
  4. Now all the error messages will be posted on LogCat.
vergil corleone
  • 1,091
  • 3
  • 16
  • 34
1

I would prefer that you should implement Google Analytics for your application which is the best Analytics tool by Google. By using Google Analytics you can view what your app is doing, on which screen user is right now, you can detect crash logs, any many more things/informations about your Applications. Also, its very easy to integrate Google Analytics with your App.

Lalit Poptani
  • 67,150
  • 23
  • 161
  • 242