无法实例化服务:ClassNotFoundException异常 [英] Unable to Instantiate Service: ClassNotFoundException

查看:150
本文介绍了无法实例化服务:ClassNotFoundException异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过上百问题,同一类别,但没有帮助。我有一个工作的应用程序,然后重构了包名称,它编译并运行。一个星期后我回来进行这项工作,并获得发射的ClassNotFoundException。更糟糕的是,如果我签出previous从回购(一个任何重构之前,这里的一切工作),该项目引发的推出了同样的错误(除非使用不同的包名)。提交

我用尽了一切我能想到的,我不知道如何追踪问题了。我也做了明显的事情:清理项目,将其全部删除,然后重新添加它,一个新的设备上运行...

我不知道什么code将有助于调试,但在这里,在我的清单申报和logcat的输出。如果别的东西可能是有用的让我知道。我真的失去了这里。

崩溃:

  E / AndroidRuntime(515):致命异常:主要
E / AndroidRuntime(515):了java.lang.RuntimeException:无法实例化服务
co.mosic.mosic.CommunicationService:抛出java.lang.ClassNotFoundException:co.mosic.mosic.CommunicationService
E / AndroidRuntime(515):在android.app.ActivityThread.handleCreateService(ActivityThread.java:2237)
E / AndroidRuntime(515):在android.app.ActivityThread.access $ 1600(ActivityThread.java:123)
E / AndroidRuntime(515):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1201)
E / AndroidRuntime(515):在android.os.Handler.dispatchMessage(Handler.java:99)
E / AndroidRuntime(515):在android.os.Looper.loop(Looper.java:137)
E / AndroidRuntime(515):在android.app.ActivityThread.main(ActivityThread.java:4424)
E / AndroidRuntime(515):在java.lang.reflect.Method.invokeNative(本机方法)
E / AndroidRuntime(515):在java.lang.reflect.Method.invoke(Method.java:511)
E / AndroidRuntime(515):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:784)
E / AndroidRuntime(515):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E / AndroidRuntime(515):在dalvik.system.NativeStart.main(本机方法)
E / AndroidRuntime(515):抛出java.lang.ClassNotFoundException:产生的原因co.mosic.mosic.CommunicationService
E / AndroidRuntime(515):在dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
E / AndroidRuntime(515):在java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E / AndroidRuntime(515):在java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E / AndroidRuntime(515):在android.app.ActivityThread.handleCreateService(ActivityThread.java:2234)
E / AndroidRuntime(515):10 ...更多

清单:

 <?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=co.mosic.mosic
    安卓版code =1
    机器人:=的versionName1.0>...<服务
    机器人:名字=CommunicationService。>
    &所述;意图滤光器>
        <作用机器人:名字=co.mosic.mosic.MStcServiceInet/>
    &所述; /意图滤光器>
< /服务>


解决方案

由于最近ADT插件库文件夹的更新,就必须改变,以代替LIB库。我最近碰到它几次。

I've read about a hundred problems of the same category, but none helped. I had a working application, then refactored the package name, and it compiled and ran. A week later I come back to work on it and get the ClassNotFoundException on launch. Worse yet, if I checkout a previous commit from the repo (one before any refactoring, where everything worked) that project raises the same error on launch (except with a different package name).

I've tried everything I can think of and I don't know how to track the problem down. I have done the obvious things: clean the project, delete it entirely and re-add it, run on a fresh device...

I'm not sure what code would be helpful to debug, but here's the declaration in my manifest and the logcat output. If something else might be useful let me know. I'm really lost here.

Crash:

E/AndroidRuntime(  515): FATAL EXCEPTION: main
E/AndroidRuntime(  515): java.lang.RuntimeException: Unable to instantiate service
co.mosic.mosic.CommunicationService: java.lang.ClassNotFoundException: co.mosic.mosic.CommunicationService
E/AndroidRuntime(  515):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2237)
E/AndroidRuntime(  515):    at android.app.ActivityThread.access$1600(ActivityThread.java:123)
E/AndroidRuntime(  515):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
E/AndroidRuntime(  515):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(  515):    at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(  515):    at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime(  515):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(  515):    at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(  515):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(  515):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(  515):    at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(  515): Caused by: java.lang.ClassNotFoundException: co.mosic.mosic.CommunicationService
E/AndroidRuntime(  515):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
E/AndroidRuntime(  515):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/AndroidRuntime(  515):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime(  515):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2234)
E/AndroidRuntime(  515):    ... 10 more

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="co.mosic.mosic"
    android:versionCode="1"
    android:versionName="1.0" >

...

<service 
    android:name=".CommunicationService" >
    <intent-filter>
        <action android:name="co.mosic.mosic.MStcServiceInet" /> 
    </intent-filter>
</service>

解决方案

Due to a recent update of the ADT plugin the library folder had to be changed to "libs" instead of lib. I came across it several times recently.

这篇关于无法实例化服务:ClassNotFoundException异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆