Android adb shell am startservice:找不到错误

前端之家收集整理的这篇文章主要介绍了Android adb shell am startservice:找不到错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图从adb shell启动服务.已经有类似的问题: How to start and stop android service from a adb shell?
但是,当我开始服务时:
adb shell am startservice com.mypackage/com.mypackage.service.MyService

我收到这个消息:

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

我在AndroidManifest.xml中声明服务:

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

你有什么想法吗?
谢谢!

解决方法

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

-n添加’line_no:’前缀

原文链接:https://www.f2er.com/android/310130.html

猜你在找的Android相关文章