Android adb shell am startservice:找不到错误

ste*_*mit 11 android adb

我正在尝试从adb shell启动服务.已经有类似的问题:如何从adb shell启动和停止android服务? 但是,当我开始服务时:

adb shell am startservice com.mypackage/com.mypackage.service.MyService
Run Code Online (Sandbox Code Playgroud)

我收到此消息:

Starting service: Intent { act=android.intent.action.VIEW dat=com.mypackage/com.mypackage.service.MyService }
Error: Not found; no service started.
Run Code Online (Sandbox Code Playgroud)

我在AndroidManifest.xml中声明了服务:

<application>
  ...
  <service
    android:name="com.mypackage.service.MyService"
    android:label="@string/local_service_label"
    android:icon="@drawable/ic_launcher">
  </service>
</application>
Run Code Online (Sandbox Code Playgroud)

你知道如何解决这个问题吗?谢谢!

Jay*_*ybo 13

adb shell am startservice -n com.mypackage/.service.MyService
Run Code Online (Sandbox Code Playgroud)

-n 添加'line_no:'前缀