How to debug an android app crashing instantly

I have another posts here Can't get app to build that uses cordova and firebase

I am literally ready to smash the computer up! The firebase plugins for cordova just cause never ending headaches.

I managed to get the app from my other post to build, but it instantly crashes on the emulator or a device. How can i diagnose this? It doesn’t give any console output at all, and i can’t open the web inspector due to the app crashing

ionic cordova emulate android

It’s running on an android 9 emulator after building for android 9.0.0 but i have also tried a couple of android versions above and it still crashes.

If you use firebase, are you sure you have put the correct “google-service.json” file? This is a common oversight that causes the app to crash on startup.
Otherwise by running the app from androidstudio, you will have more logs

Yes the google-services.json file is in the root, it wouldn’t build without it.

I don’t know how to use android studio to run the app in the emulator with logs? I use other software like php storm for development (the ide on android actually looks like it’s made by intelij)

Could you advise on how i’d run the ionic app to emulator via android studio with showing crashing log? I get no errors when i just run ionic cordova emulate android, the app simply crashes on the emulator and no log in the console at all, just this:

[native-run] Selected emulator emulator-5554
[native-run] Installing platforms/android/app/build/outputs/apk/debug/app-debug.apk…
[native-run] Starting application activity uk.co.greenwaterservices.app/uk.co.greenwaterservices.app.MainActivity…
[native-run] ADBs is unresponsive after 5000ms, killing server and retrying…
[native-run] Run Successful

Normally, there is nothing very complex to launch android studio…
You launch android studio and open the android folder of your project (in platform/android)
Then in the taskbar at the top, either you see your devices and just do “run” (the green triangle). Either you have to download an emulator/sdk via “AVD manager” a phone icon with the android mascot (or tools → AVD manager)

If all goes well, you will have the logs in a console at the bottom (logcat or build)

Hey

I have used logcat, and i see a whole bunch of errors. Here is one of them, it’s complaining about not having audio recording permission, yet we don’t even do audio recording in the app? It connects to a bluetooth device and reads serial input data; i also keep noticing one complaining about ACCESS_BACKGROUND_LOCATION yet we also don’t request this:

01-25 14:55:18.171 6884 12018 W ErrorReporter: reportError [type: 211, code: 524300]: Error reading from input stream
01-25 14:55:18.171 6884 6963 I MicroRecognitionRunner: Stopping hotword detection.
01-25 14:55:18.171 6884 12018 W ErrorProcessor: onFatalError, processing error from engine(4)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: com.google.android.apps.gsa.shared.speech.b.g: Error reading from input stream
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at com.google.android.apps.gsa.staticplugins.microdetection.d.k.a(SourceFile:91)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at com.google.android.apps.gsa.staticplugins.microdetection.d.l.run(Unknown Source:14)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at com.google.android.libraries.gsa.runner.a.a.b(SourceFile:32)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at com.google.android.libraries.gsa.runner.a.c.call(Unknown Source:4)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at com.google.android.apps.gsa.shared.util.concurrent.b.g.run(Unknown Source:4)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at com.google.android.apps.gsa.shared.util.concurrent.b.aw.run(SourceFile:4)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at java.lang.Thread.run(Thread.java:764)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at com.google.android.apps.gsa.shared.util.concurrent.b.i.run(SourceFile:6)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: Caused by: com.google.android.apps.gsa.shared.exception.GsaIOException: Error code: 393238 | Buffer overflow, no available space.
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at com.google.android.apps.gsa.speech.audio.Tee.j(SourceFile:103)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at com.google.android.apps.gsa.speech.audio.au.read(SourceFile:2)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at java.io.InputStream.read(InputStream.java:101)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at com.google.android.apps.gsa.speech.audio.ao.run(SourceFile:17)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at com.google.android.apps.gsa.speech.audio.an.run(SourceFile:2)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458)
01-25 14:55:18.171 6884 12018 W ErrorProcessor: … 10 more
01-25 14:55:18.171 6884 12018 I AudioController: internalShutdown
01-25 14:55:18.172 6884 6884 I MicroDetector: Keeping mic open: false
01-25 14:55:18.172 6884 6884 I MicroDetectionWorker: #onError(false)
01-25 14:55:18.172 6884 6957 I DeviceStateChecker: DeviceStateChecker cancelled

You can see it cancelled the device state checker, i’m assuming this is why the app is crashing.

Finally worked it out, had the use permissions tags in the wrong place in config.xml, then there was an issue with “globalThis” being missing, so added that and now it works! Thanks for your time to try and help

2 Likes

Hi, I have the same problem. What did you change in config.xml?