1

我正在将现有的 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.");
    }
}

当我引用记录器时,为什么我在 android.util.Log 上收到 NoClassDefFoundError 的任何线索?

完整的堆栈跟踪:

{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)
4

1 回答 1

1

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

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

克莱门特

于 2013-04-27T14:46:59.803 回答