Search code examples
androidadb

Android adb shell am startservice: Error not found


I am trying to start the service from adb shell. There already is similar question: How to start and stop android service from a adb shell? However, when I start service with:

adb shell am startservice com.mypackage/com.mypackage.service.MyService

I receive this message:

Starting service: Intent { act=android.intent.action.VIEW dat=com.mypackage/com.mypackage.service.MyService }
Error: Not found; no service started.

I declare service in AndroidManifest.xml:

<application>
  ...
  <service
    android:name="com.mypackage.service.MyService"
    android:label="@string/local_service_label"
    android:icon="@drawable/ic_launcher">
  </service>
</application>

Do you have any idea how to solve this? Thank you!


Solution

  • adb shell am startservice -n com.mypackage/.service.MyService
    

    Update (Per adb shell am help start-service):

    -n <COMPONENT_NAME>