我想在我的应用中使用Algolia进行地理搜索。
当我将示例项目(icebnb)文件复制到我的项目时。
我已经通过堆栈溢出助手的帮助清除了即时搜索模块的一些错误错误。
当我打开活动(运行时)时会引发错误。
我正面临着这个错误并且长期受苦。请帮帮我。
09-27 14:44:57.244 29793-29793/com.google.tho.saw E/AndroidRuntime: FATAL EXCEPTION: main java.lang.ExceptionInInitializerError
at com.jayway.jsonpath.internal.ParseContextImpl.parse(ParseContextImpl.java:38)
at com.jayway.jsonpath.JsonPath.read(JsonPath.java:502)
at com.algolia.instantsearch.utils.JSONUtils.getObjectFromJSONPath(JSONUtils.java:40)
at com.algolia.instantsearch.utils.JSONUtils.getStringFromJSONPath(JSONUtils.java:22)
at com.algolia.instantsearch.ui.views.Hits$HitsAdapter.onBindViewHolder(Hits.java:458)
at com.algolia.instantsearch.ui.views.Hits$HitsAdapter.onBindViewHolder(Hits.java:398)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6356)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6389)
at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5335)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5598)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5440)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5436)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2224)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1551)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1511)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:595)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3583)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3312)
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1618)
at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:4702)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:791)
at android.view.Choreographer.doCallbacks(Choreographer.java:591)
at android.view.Choreographer.doFrame(Choreographer.java:560)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:777)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5317)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
at com.jayway.jsonpath.internal.JsonContext.<clinit>(JsonContext.java:41)
at com.jayway.jsonpath.internal.ParseContextImpl.parse(ParseContextImpl.java:38)
at com.jayway.jsonpath.JsonPath.read(JsonPath.java:502)
at com.algolia.instantsearch.utils.JSONUtils.getObjectFromJSONPath(JSONUtils.java:40)
at com.algolia.instantsearch.utils.JSONUtils.getStringFromJSONPath(JSONUtils.java:22)
at com.algolia.instantsearch.ui.views.Hits$HitsAdapter.onBindViewHolder(Hits.java:458)
at com.algolia.instantsearch.ui.views.Hits$HitsAdapter.onBindViewHolder(Hits.java:398)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6356)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6389)
at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5335)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5598)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5440)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5436)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2224)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1551)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1511)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:595)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3583)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3312)
at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1618)
at android.support.v7.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:4702)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:791)
at android.view.Choreographer.doCallbacks(Choreographer.java:591)
at android.view.Choreographer.doFrame(Choreographer.java:560)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:777)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5317)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:1)
您使用的是什么版本的InstantSearch Android / IceBNB?
运行current version of IceBNB按预期工作,我能够重现您情况的唯一方法是从InstantSearch手动删除 SLF4J:
compile ("com.algolia:instantsearch-android:$VERSION_INSTANTSEARCH") {
exclude group: "org.slf4j"
}
这会触发您报告的java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
。但除非你手动删除SLF4J
,否则你不需要任何东西让示例应用程序正常工作。
SLF4J
,则接受的答案的建议才有意义。 你能分享一个触发错误的设置吗?
答案 1 :(得分:0)
您缺少课程org.slf4j.LoggerFactory
的图书馆。
尝试根据 app/build.gradle
文件添加以下内容。
compile 'org.slf4j:slf4j-api:1.7.24'
compile 'org.slf4j:slf4j-simple:1.7.24'
OR
您还可以下载slf4j jar文件,然后将其包含在app / build.gradle中:
compile files('libs/slf4j.jar'); //You can change jar name here