Search code examples
androidgoogle-chrome-arc

How to debug an android app that crashes the plugin on ChromeOS


I have an android app that works fine on Android devices and on the ARC Welder/Mac. When I try to run it on the ChromeOS it crashes and I get the "sad puzzle face" (the plugin crashes).

Because the plugin crashes I can't get to logcat. It seems that every time the app starts the logcat is reinitialized so I can't see any output from the previous crash either.

I looked into /var/log and didn't find any clues. I tried the latest "stable" and the latest "dev-channel" builds - same results.


Solution

  • If you define a non-empty metadata list setting for "shell", you can override the normal commands issued to launch the application. You can set it something trivial that does nothing:

    "shell": [""]
    

    If you then load the CRX file with this metadata set, and you try to launch the app, it will launch, but only show the splash screen (app icon).

    The Android session has been started, but your application hasn't actually been launched.

    You now have a chance to issue some shell commands from the javascript console.

    What I think you can do is use logcat -f /sdcard/logfile.txt to write the log to a persistent location, and then start your app:

    plugin.shell('logcat -f /sdcard/logfile.txt');
    plugin.shell('am start com.package.name/com.package.name.ActivityName')
    

    Then when your application crashes, just start it back up, but now issue the shell command:

    plugin.shell('cat /sdcard/logfile.txt');
    

    This should print out the persisted log, and hopefully point the way to the error.