Android SLF4J: NoClassDefFoundError android.util.Log



我正在将现有的OSGi/Felix/iPOJO应用程序从windows移植到Android。该应用程序正在使用SLF4J。我已经将slf4j-android作为捆绑包部署。然而,我得到一个java.lang。NoClassDefFoundError: android.util.Log在我试图实例化记录器的行上。

SLF4J文档说我只需要在我的类路径上有SLF4J -android jar,不需要进一步的配置。(http://www.slf4j.org/android/)

我的记录器声明为:

private static final Logger logger = LoggerFactory.getLogger("DefaultActionManager");

堆栈跟踪提示的行是:

logger.info("Bound new action list for state " + state);
下面是完整的方法:
@Override
@Bind(aggregate = true)
public void bindActionList(final ActionList actionList) {
    final State state = actionList.getState();
    final ActionList replacedActionList = actionLists.put(state, actionList);
    logger.info("Bound new action list for state " + state);
    if (replacedActionList != null) {
        logger.warn(state + " previously had an action list associated with it. This new action list replaced it.");
    }
}

任何线索为什么我得到一个NoClassDefFoundError在android.util.Log当我引用记录器?

全栈跟踪:

{ERROR]  : The method bindActionList in the implementation class myCompany.DefaultActio
nManager throws an exception : android.util.Log
java.lang.NoClassDefFoundError: android.util.Log
 at org.slf4j.impl.AndroidLogger.info(AndroidLogger.java:151)
 at myCompany.DefaultActionManager.__bindActionList(DefaultActionManager.java:120)
 at myCompany.DefaultActionManager.bindActionList(DefaultActionManager.java)
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:511)
 at org.apache.felix.ipojo.util.Callback.call(Callback.java:260)
 at org.apache.felix.ipojo.handlers.dependency.DependencyCallback.callOnInstance(DependencyCa
llback.java:309)
 at org.apache.felix.ipojo.handlers.dependency.Dependency.invokeCallback(Dependency.java:315)
 at org.apache.felix.ipojo.handlers.dependency.Dependency.onObjectCreation(Dependency.java:28
0)
 at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.__M_onCreation(DependencyHan
dler.java:643)
 at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.onCreation(DependencyHandler
.java)
 at org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.java:870)
 at org.apache.felix.ipojo.util.Callback.call(Callback.java:233)
 at org.apache.felix.ipojo.util.Callback.call(Callback.java:193)
 at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallback.call(LifecycleCallba
ck.java:86)
 at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChan
ged(LifecycleCallbackHandler.java:162)
 at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(
LifecycleCallbackHandler.java)
 at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:472)
 at org.apache.felix.ipojo.InstanceManager.stateChanged(InstanceManager.java:1340)
 at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:497)
 at org.apache.felix.ipojo.HandlerManager.stateChanged(HandlerManager.java:239)
 at org.apache.felix.ipojo.Handler.setValidity(Handler.java:174)
 at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.__M_checkContext(DependencyH
andler.java:186)
 at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.checkContext(DependencyHandl
er.java)
 at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.__M_validate(DependencyHandl
er.java:149)
 at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.validate(DependencyHandler.j
ava)
 at org.apache.felix.ipojo.util.DependencyModel.validate(DependencyModel.java:642)
 at org.apache.felix.ipojo.util.DependencyModel.computeDependencyState(DependencyModel.java:3
10)
 at org.apache.felix.ipojo.util.DependencyModel.manageArrival(DependencyModel.java:399)
 at org.apache.felix.ipojo.util.DependencyModel.addedService(DependencyModel.java:335)
 at org.apache.felix.ipojo.util.Tracker$Tracked.trackAdding(Tracker.java:725)
 at org.apache.felix.ipojo.util.Tracker$Tracked.track(Tracker.java:686)
 at org.apache.felix.ipojo.util.Tracker$Tracked.serviceChanged(Tracker.java:647)
 at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispat
cher.java:932)
 at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java
:793)
 at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:543
)
 at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4260)
 at org.apache.felix.framework.Felix.registerService(Felix.java:3275)
 at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:346)
 at org.apache.felix.ipojo.IPojoContext.registerService(IPojoContext.java:385)
 at org.apache.felix.ipojo.handlers.providedservice.ProvidedService.registerService(ProvidedS
ervice.java:362)
 at org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler.__M_stateChanged(P
rovidedServiceHandler.java:509)
 at org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler.stateChanged(Provi
dedServiceHandler.java)
 at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:472)
 at org.apache.felix.ipojo.InstanceManager.stateChanged(InstanceManager.java:1340)
 at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:497)
 at org.apache.felix.ipojo.HandlerManager.stateChanged(HandlerManager.java:239)
 at org.apache.felix.ipojo.Handler.setValidity(Handler.java:174)
 at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.__M_checkContext(DependencyH
andler.java:186)
 at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.checkContext(DependencyHandl
er.java)
 at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.__M_validate(DependencyHandl
er.java:149)
 at org.apache.felix.ipojo.handlers.dependency.DependencyHandler.validate(DependencyHandler.j
ava)
 at org.apache.felix.ipojo.util.DependencyModel.validate(DependencyModel.java:642)
 at org.apache.felix.ipojo.util.DependencyModel.computeDependencyState(DependencyModel.java:3
10)
 at org.apache.felix.ipojo.util.DependencyModel.manageArrival(DependencyModel.java:399)
 at org.apache.felix.ipojo.util.DependencyModel.addedService(DependencyModel.java:335)
 at org.apache.felix.ipojo.util.Tracker$Tracked.trackAdding(Tracker.java:725)
 at org.apache.felix.ipojo.util.Tracker$Tracked.track(Tracker.java:686)
 at org.apache.felix.ipojo.util.Tracker$Tracked.serviceChanged(Tracker.java:647)
 at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispat
cher.java:932)
 at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java
:793)
 at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:543
)
 at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4260)
 at org.apache.felix.framework.Felix.registerService(Felix.java:3275)
 at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:346)
 at org.apache.felix.ipojo.IPojoContext.registerService(IPojoContext.java:385)
 at org.apache.felix.ipojo.handlers.providedservice.ProvidedService.registerService(ProvidedS
ervice.java:362)
 at org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler.__M_stateChanged(P
rovidedServiceHandler.java:509)
 at org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler.stateChanged(Provi
dedServiceHandler.java)
 at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:472)
 at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:354)
 at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:178)
 at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:301)
 at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:238)
 at org.apache.felix.ipojo.InstanceCreator$ManagedInstance.create(InstanceCreator.java:343)
 at org.apache.felix.ipojo.InstanceCreator.addInstance(InstanceCreator.java:89)
 at org.apache.felix.ipojo.Extender.parse(Extender.java:306)
 at org.apache.felix.ipojo.Extender.startManagementFor(Extender.java:237)
 at org.apache.felix.ipojo.Extender.access$600(Extender.java:52)
 at org.apache.felix.ipojo.Extender$CreatorThread.run(Extender.java:769)
 at java.lang.Thread.run(Thread.java:856)

检查你的框架是否正在导出android。util包。如果没有,配置Felix这样做(通过添加一个额外的包)。

还要检查android slf4j bundle是否正在导入android。util包。

克莱门特

相关内容

  • 没有找到相关文章

最新更新