algolia NoClassDefFoundError jayway / jsonpath / Predicate

时间:2018-04-17 12:48:49

标签: android json noclassdeffounderror algolia

我在构建项目时最近在运行时遇到了一个错误(它今天早上一直工作到现在)。该错误来自我使用名为Algolia Instant Search的库,这里是错误:

java.lang.NoClassDefFoundError: Failed resolution of: 
[Lcom/jayway/jsonpath/Predicate;     
at com.algolia.instantsearch.utils.
JSONUtils.getObjectFromJSONPath(JSONUtils.java    
at
com.algolia.instantsearch.utils.
JSONUtils.getStringFromJSONPath(JSONUtils.java:    
at
com.algolia.instantsearch.ui.views.
Hits$HitsAdapter.onBindViewHolder(Hits.java:    
at
com.algolia.instantsearch.ui.views.
Hits$HitsAdapter.onBindViewHolder(Hits.java:

等等,直到

04-17 12:27:05.422 20618-20618/com.sealstudios.iconnectonline 
E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find 
class "com.jayway.jsonpath.Predicate" on path: DexPathList[[zip file 
"/data/app/com.sealstudios.iconnectonline-1/base.apk", zip file 
"/data/app/com.sealstudios.iconnectonline-1/split_lib_dependencies_apk.apk", 
zip file "/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_0_apk.apk", 
zip file "/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_1_apk.apk", 
zip file "/data/app/com.sealstudios.iconnectonline-        
1/split_lib_slice_2_apk.apk", 
zip file "/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_3_apk.apk", 
zip file "/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_4_apk.apk", 
zip file "/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_5_apk.apk", 
zip file "/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_6_apk.apk", 
zip file "/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_7_apk.apk", 
zip file "/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_8_apk.apk", 
zip file "/data/app/com.sealstudios.iconnectonline-
1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=
[/data/app/com.sealstudios.iconnectonline-1/lib/x86, 
/data/app/com.sealstudios.iconnectonline-1/base.apk!/lib/x86, 
/data/app/com.sealstudios.iconnectonline-
1/split_lib_dependencies_apk.apk!/lib/x86, 
/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_0_apk.apk!/lib/x86, 
/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_1_apk.apk!/lib/x86, 
/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_2_apk.apk!/lib/x86, 
/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_3_apk.apk!/lib/x86, 
/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_4_apk.apk!/lib/x86, 
/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_5_apk.apk!/lib/x86, 
/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_6_apk.apk!/lib/x86, 
/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_7_apk.apk!/lib/x86, 
/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_8_apk.apk!/lib/x86, 
/data/app/com.sealstudios.iconnectonline- 
1/split_lib_slice_9_apk.apk!/lib/x86, 
/system/lib, /vendor/lib]]


at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)

我的问题基本上是,我能做些什么吗?回滚gradle版本,添加文件,如果是这样,或者我需要通知作者并等待修复

1 个答案:

答案 0 :(得分:1)

依赖关系管理中存在一个问题,导致传递依赖关系不会从v1.7.6暴露给v1.7.23。

release v1.7.24修正了错误。只需将您的依赖关系更新为

即可
public class CustomLinearLayoutManager extends LinearLayoutManager {

    private final float mShrinkAmount = 0.15f;
    private final float mShrinkDistance = 1.0f;

    public CustomLinearLayoutManager(Context context) {
        super(context);
    }

    @Override
    public int scrollVerticallyBy(int dy, @NonNull RecyclerView.Recycler recycler, @NonNull RecyclerView.State state) {
        int orientation = getOrientation();
        if (orientation == VERTICAL) {
            int scrolled = super.scrollVerticallyBy(dy, recycler, state);
            float midpoint = getHeight() / 2.0f;
            float d0 = 0.0f;
            float d1 = mShrinkDistance * midpoint;
            float s0 = 1.0f;
            float s1 = 1.0f - mShrinkAmount;
            // loop through active children and set scale of child
            for (int i = 0; i < getChildCount(); i++) {
                View child = getChildAt(i);
                float childMidpoint = (getDecoratedBottom(child) + getDecoratedTop(child)) / 2.0f;
                float d = Math.min(d1, Math.abs(midpoint - childMidpoint));
                float scale = s0 + (s1 - s0) * (d - d0) / (d1 - d0);
                child.setScaleX(scale);
                child.setScaleY(scale);
            }
            return scrolled;
        } else {
            return 0;
        }
    }

    @Override
    public int scrollHorizontallyBy(int dx, @NonNull RecyclerView.Recycler recycler, @NonNull RecyclerView.State state) {
        int orientation = getOrientation();
        if (orientation == HORIZONTAL) {
            int scrolled = super.scrollHorizontallyBy(dx, recycler, state);
            float midpoint = getWidth() / 2.0f;
            float d0 = 0.0f;
            float d1 = mShrinkDistance * midpoint;
            float s0 = 1.0f;
            float s1 = 1.0f - mShrinkAmount;
            // loop through active children and set scale of child
            for (int i = 0; i < getChildCount(); i++) {
                View child = getChildAt(i);
                float childMidpoint = (getDecoratedRight(child) + getDecoratedLeft(child)) / 2.0f;
                float d = Math.min(d1, Math.abs(midpoint - childMidpoint));
                float scale = s0 + (s1 - s0) * (d - d0) / (d1 - d0);
                child.setScaleX(scale);
                child.setScaleY(scale);
            }
            return scrolled;
        } else {
            return 0;
        }
    }

    @Override
    public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
        super.onLayoutChildren(recycler, state);
        scrollVerticallyBy(0, recycler, state);
    }
}

问题就会消失。