Home » Android » debugging – Android studio: Error: Activity not started, unknown error code 5

debugging – Android studio: Error: Activity not started, unknown error code 5

Posted by: admin June 15, 2020 Leave a comment

Questions:

Currently developing an Android app for my company.

Everything was fine, till my last debugging session on my test-device (tablet attached to android via adb).
When I try to run or debug my app, the “Run App” log simply shows:

Error: Activity not started, unknown error code 5

There is no further information, no stack trace, no nothing…

I tried to figure out, what I changed since the last time, but nothing seems to fix this.

Has anybody else had this error code 5 before and can help me?

How to&Answers:

Long story short: Unknown error 5 means (at least in my case), there is a lock (meaning a pinned app) on the device, so no other app can be started.

After a bunch of things I tried, I finally figured this out.

My app uses startLockTask() to pin it (so you can’t accidentally press one of the navigation buttons).

The problem was, that this lock seemed to be active, even though the app wasn’t running. I only realized that, after I tried to push the home button on my tablet (it already showed the android home screen, so it didn’t occur to me, to try that…).

Once I released the lock (pressing both Back and Overview at the same time), I could start the debugging again, with no problem.

Answer:

Restarting the device fixed the problem