我想实现新的RemoteController API,它已经与API19(Kitkat,4.4)一起引入.API要求我实现一个从NotificationListenerService扩展的类(与API18一起引入)并实现RemoteController.OnClientUpdateListener接口.(关于如何实现这一切的进一步信息可以发现这里和一个非常有益的示例项目,可以发现这里)
在我的API19(Kitkat,4.4)设备和其他所有API <18设备上,一切正常.然而问题是,应用程序立即崩溃API18(Jelly bean,4.3),因为正在发送"android.service.notification.NotificationListenerService"并启动我的RemoteService,然后使用以下Stacktrace立即崩溃应用程序:
05-24 09:32:48.945 893-893/com.example E/AndroidRuntime? FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate service com.example.RemoteService: java.lang.ClassNotFoundException: Didn't find class "com.example.RemoteService" on path: DexPathList[[zip file "/data/app/com.example-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example-1, /system/lib]]
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2561)
at android.app.ActivityThread.access$1600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1338)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.RemoteService" on path: DexPathList[[zip file "/data/app/com.example-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example-1, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53) …Run Code Online (Sandbox Code Playgroud)